|
/******************************************************************************
Copyright (C) 2005 MakeLogic
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Date : 14th December 2005
Authors : MakeLogic
Design : Ujjwal
Developer : Dharma
********************************************************************************/
package com.makeLogic.utils;
import com.makeLogic.Tail;
import java.awt.Container;
import java.beans.PropertyVetoException;
import java.io.File;
import java.util.Hashtable;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;
import com.makeLogic.utils.MLEditorListener;
/**
* This class will create its own InternalFrame which extends <br>
* from JInternalFrame.It will act as a container for JEditorPane <br>
* and JScrollPane.
*
*/
public class MLInternalFrame extends JInternalFrame
{
//..Variables Declaration
JScrollPane scrollPane;
JEditorPane editorPane;
Container container;
boolean changed;
//..constructor
MLInternalFrame(Container container,File selectedFile,StringBuffer fileContents)
{
//.. creates an JInternalFrame with the follwing path and it is resizable,closable,maximizable,iconfiable
super(selectedFile.getAbsolutePath(),true,true,true,true);
//..Set the default action for the close box click
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.container=container;
//..initailizes the changed flag to false
changed = false;
//..Gets the Component of the InternalFrame
JComponent contentPane=(JComponent)this.getContentPane();
//.. sets the file contents to the editorPane
//..EditorPane
editorPane=new JEditorPane();
//..make the EditorPane to Editable
editorPane.setEditable(true);
//..add the filecontents to the EditorPane
editorPane.setText(new String(fileContents));
// adds the documentListener to the EditorPane
editorPane.getDocument().addDocumentListener(new MLEditorListener(this));
//.. adds the scrollPane to the MLInternalFrame
scrollPane=new JScrollPane(editorPane);
contentPane.add(scrollPane);
//.. makes the size of the MLInternalFrame to the size of the container
this.reshape(0,0,container.getWidth(),container.getHeight());
//..makes the internalFrame to Visible
this.show();
//.. Adds the MLInternalFrame to the container
container.add(this);
container.validate();
//.. makes the currently opened InternalFrame to the front
try
{
//..makes the currentFrame Active
this.setSelected(true);
}
catch(PropertyVetoException pve)
{
//pve.printStackTrace();
JOptionPane.showMessageDialog(Tail.tailMDI,pve.getMessage(),"MakeLogic:FileMenu",JOptionPane.ERROR_MESSAGE);
}
}
//..Accessor method for the changed flag
public boolean getChanged()
{
return changed;
}
//..Mutator method for the changed flag
public void setChanged(boolean changed)
{
this.changed = changed;
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Founder of MakeLogic - A Mobile Solutions and XML Web Services Company. B-Tech engineer from India's reputed IITs.
Designed and Authored products like MicroGraphs, MakeLogic VersionManager and MakeLogic Device Broker. Pls see http://www.makelogic.com
MakeLogic is a strategic business partner of Microsoft, Sun, IBM, HP and Citrix.
Contact : madanuuk@makelogic.com OR +91 - 40 - 55322433