home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Sample.bin
/
Stylepad.java
< prev
next >
Wrap
Text File
|
1998-11-02
|
38KB
|
929 lines
/*
A basic implementation of the JFrame class.
*/
import java.io.*;
import java.awt.*;
import java.util.*;
import java.text.*;
import java.awt.event.*;
import com.sun.java.swing.*;
import com.sun.java.swing.text.*;
import com.sun.java.swing.undo.*;
import com.sun.java.swing.event.*;
import com.symantec.itools.swing.actions.JActionButton;
import com.symantec.itools.swing.icons.ImageIcon;
import com.symantec.itools.swing.actions.JActionMenuItem;
import com.symantec.itools.swing.JToolBarSeparator;
public class Stylepad extends com.sun.java.swing.JFrame
{
String curFile=null;
String curFileDir=null;
public Stylepad()
{
// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
//{{INIT_CONTROLS
setJMenuBar(JMenuBar1);
setTitle("Stylepad");
getContentPane().setLayout(new BorderLayout(0,0));
setSize(474,377);
setVisible(false);
redColoredSquare.setFillColor(java.awt.Color.red);
//$$ redColoredSquare.move(0,0);
greenColoredSquare.setFillColor(java.awt.Color.green);
//$$ greenColoredSquare.move(0,0);
blueColoredSquare.setFillColor(java.awt.Color.blue);
//$$ blueColoredSquare.move(0,0);
try {
newIcon.setImageLocation(symantec.itools.net.RelativeURL.getURL("images/new.gif"));
}
catch (java.net.MalformedURLException error) { }
//$$ newIcon.move(0,0);
try {
openIcon.setImageLocation(symantec.itools.net.RelativeURL.getURL("images/open.gif"));
}
catch (java.net.MalformedURLException error) { }
//$$ openIcon.move(0,0);
try {
saveIcon.setImageLocation(symantec.itools.net.RelativeURL.getURL("images/save.gif"));
}
catch (java.net.MalformedURLException error) { }
//$$ saveIcon.move(0,0);
try {
cutIcon.setImageLocation(symantec.itools.net.RelativeURL.getURL("images/cut.gif"));
}
catch (java.net.MalformedURLException error) { }
//$$ cutIcon.move(0,0);
try {
copyIcon.setImageLocation(symantec.itools.net.RelativeURL.getURL("images/copy.gif"));
}
catch (java.net.MalformedURLException error) { }
//$$ copyIcon.move(0,0);
try {
pasteIcon.setImageLocation(symantec.itools.net.RelativeURL.getURL("images/paste.gif"));
}
catch (java.net.MalformedURLException error) { }
//$$ pasteIcon.move(0,0);
try {
boldIcon.setImageLocation(symantec.itools.net.RelativeURL.getURL("images/bold.gif"));
}
catch (java.net.MalformedURLException error) { }
//$$ boldIcon.move(0,0);
try {
italicIcon.setImageLocation(symantec.itools.net.RelativeURL.getURL("images/italic.gif"));
}
catch (java.net.MalformedURLException error) { }
//$$ italicIcon.move(0,0);
try {
underlineIcon.setImageLocation(symantec.itools.net.RelativeURL.getURL("images/underline.gif"));
}
catch (java.net.MalformedURLException error) { }
//$$ underlineIcon.move(0,0);
try {
leftIcon.setImageLocation(symantec.itools.net.RelativeURL.getURL("images/left.gif"));
}
catch (java.net.MalformedURLException error) { }
//$$ leftIcon.move(0,0);
try {
centerIcon.setImageLocation(symantec.itools.net.RelativeURL.getURL("images/center.gif"));
}
catch (java.net.MalformedURLException error) { }
//$$ centerIcon.move(0,0);
try {
rightIcon.setImageLocation(symantec.itools.net.RelativeURL.getURL("images/right.gif"));
}
catch (java.net.MalformedURLException error) { }
//$$ rightIcon.move(0,0);
newAction.setLongDescription("Create a new document");
newAction.setSmallIcon(newIcon);
newAction.setShortDescription("New");
newAction.setActionName("New");
//$$ newAction.move(0,0);
openAction.setLongDescription("Open An Existing Document");
openAction.setSmallIcon(openIcon);
openAction.setShortDescription("Open");
openAction.setActionName("Open");
//$$ openAction.move(0,0);
saveAction.setLongDescription("Save the current document");
saveAction.setSmallIcon(saveIcon);
saveAction.setShortDescription("Save");
saveAction.setActionName("Save");
//$$ saveAction.move(0,0);
cutAction.setLongDescription("Cut the selected text");
cutAction.setSmallIcon(cutIcon);
cutAction.setShortDescription("Cut");
cutAction.setActionName("Cut");
//$$ cutAction.move(0,0);
copyAction.setLongDescription("Copy the selected text");
copyAction.setSmallIcon(copyIcon);
copyAction.setShortDescription("Copy");
copyAction.setActionName("Copy");
//$$ copyAction.move(0,0);
pasteAction.setLongDescription("Paste text from the clipboard");
pasteAction.setSmallIcon(pasteIcon);
pasteAction.setShortDescription("Paste");
pasteAction.setActionName("Paste");
//$$ pasteAction.move(0,0);
undoAction.setEnabled(false);
undoAction.setLongDescription("Undo");
undoAction.setShortDescription("Undo");
undoAction.setActionName("Undo");
//$$ undoAction.move(0,0);
redoAction.setEnabled(false);
redoAction.setLongDescription("Redo");
redoAction.setShortDescription("Redo");
redoAction.setActionName("Redo");
//$$ redoAction.move(0,0);
boldAction.setLongDescription("Bold");
boldAction.setSmallIcon(boldIcon);
boldAction.setShortDescription("Bold");
boldAction.setActionName("Bold");
boldAction.setDefaultValue("Bold");
//$$ boldAction.move(0,0);
italicAction.setLongDescription("Italic");
italicAction.setSmallIcon(italicIcon);
italicAction.setShortDescription("Italic");
italicAction.setActionName("Italic");
italicAction.setDefaultValue("Italic");
//$$ italicAction.move(0,0);
underlineAction.setLongDescription("Underline");
underlineAction.setSmallIcon(underlineIcon);
underlineAction.setShortDescription("Underline");
underlineAction.setActionName("Underline");
underlineAction.setDefaultValue("Underline");
//$$ underlineAction.move(0,0);
leftAction.setSmallIcon(leftIcon);
//$$ leftAction.move(0,0);
centerAction.setSmallIcon(centerIcon);
//$$ centerAction.move(0,0);
rightAction.setSmallIcon(rightIcon);
//$$ rightAction.move(0,0);
exitAction.setLongDescription("Exit the application");
exitAction.setShortDescription("Exit");
exitAction.setActionName("Exit");
//$$ exitAction.move(0,0);
JScrollPane1.setOpaque(true);
getContentPane().add("Center", JScrollPane1);
JScrollPane1.setBounds(0,29,474,348);
JScrollPane1.getViewport().add(editor);
editor.setBounds(0,0,471,345);
JToolBar1.setAlignmentY(0.08F);
getContentPane().add("North", JToolBar1);
JToolBar1.setBounds(0,0,474,29);
JActionButton1.setActionCommand("New");
JActionButton1.setAction(newAction);
JToolBar1.add(JActionButton1);
JActionButton1.setBounds(16,4,51,23);
JActionButton2.setActionCommand("Open");
JActionButton2.setAction(openAction);
JToolBar1.add(JActionButton2);
JActionButton2.setBounds(67,4,57,23);
JActionButton3.setActionCommand("Save");
JActionButton3.setAction(saveAction);
JToolBar1.add(JActionButton3);
JActionButton3.setBounds(124,4,55,23);
JToolBar1.add(JToolBarSeparator1);
JToolBarSeparator1.setBounds(179,2,10,5);
JActionButton4.setActionCommand("Cut");
JActionButton4.setAction(cutAction);
JToolBar1.add(JActionButton4);
JActionButton4.setBounds(189,4,45,23);
JActionButton5.setActionCommand("Copy");
JActionButton5.setAction(copyAction);
JToolBar1.add(JActionButton5);
JActionButton5.setBounds(234,4,53,23);
JActionButton6.setActionCommand("Paste");
JActionButton6.setAction(pasteAction);
JToolBar1.add(JActionButton6);
JActionButton6.setBounds(287,4,59,23);
JToolBar1.add(JToolBarSeparator2);
JToolBarSeparator2.setBounds(346,2,10,5);
JActionButton7.setActionCommand("Bold");
JActionButton7.setAction(boldAction);
JToolBar1.add(JActionButton7);
JActionButton7.setBounds(356,4,51,23);
JActionButton8.setActionCommand("Italic");
JActionButton8.setAction(italicAction);
JToolBar1.add(JActionButton8);
JActionButton8.setBounds(407,4,53,23);
JActionButton9.setActionCommand("Underline");
JActionButton9.setAction(underlineAction);
JToolBar1.add(JActionButton9);
JActionButton9.setBounds(460,4,79,23);
JToolBar1.add(JToolBarSeparator3);
JToolBarSeparator3.setBounds(539,2,10,5);
JActionButton10.setAction(leftAction);
JToolBar1.add(JActionButton10);
JActionButton10.setBounds(549,4,21,23);
JActionButton11.setAction(centerAction);
JToolBar1.add(JActionButton11);
JActionButton11.setBounds(570,4,21,23);
JActionButton12.setAction(rightAction);
JToolBar1.add(JActionButton12);
JActionButton12.setBounds(591,4,21,23);
//$$ JMenuBar1.move(0,0);
fileMenu.setText("File");
fileMenu.setActionCommand("File");
fileMenu.setMnemonic((int)'F');
JMenuBar1.add(fileMenu);
JActionMenuItem1.setActionCommand("New");
JActionMenuItem1.setAction(newAction);
JActionMenuItem1.setAccelerator(com.sun.java.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, Event.CTRL_MASK));
JActionMenuItem1.setMnemonic((int)'N');
fileMenu.add(JActionMenuItem1);
JActionMenuItem2.setActionCommand("Open");
JActionMenuItem2.setAction(openAction);
JActionMenuItem2.setAccelerator(com.sun.java.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, Event.CTRL_MASK));
JActionMenuItem2.setMnemonic((int)'O');
fileMenu.add(JActionMenuItem2);
JActionMenuItem3.setActionCommand("Save");
JActionMenuItem3.setAction(saveAction);
JActionMenuItem3.setAccelerator(com.sun.java.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, Event.CTRL_MASK));
JActionMenuItem3.setMnemonic((int)'S');
fileMenu.add(JActionMenuItem3);
fileMenu.add(JSeparator1);
loadWonderland.setText("Load Wonderland");
loadWonderland.setActionCommand("Load Wonderland");
loadWonderland.setMnemonic((int)'L');
fileMenu.add(loadWonderland);
fileMenu.add(JSeparator5);
JActionMenuItem7.setActionCommand("Exit");
JActionMenuItem7.setAction(exitAction);
JActionMenuItem7.setMnemonic((int)'E');
fileMenu.add(JActionMenuItem7);
editMenu.setText("Edit");
editMenu.setActionCommand("Edit");
editMenu.setMnemonic((int)'E');
JMenuBar1.add(editMenu);
JActionMenuItem4.setActionCommand("Cut");
JActionMenuItem4.setAction(cutAction);
JActionMenuItem4.setAccelerator(com.sun.java.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, Event.CTRL_MASK));
JActionMenuItem4.setMnemonic((int)'U');
editMenu.add(JActionMenuItem4);
JActionMenuItem5.setActionCommand("Copy");
JActionMenuItem5.setAction(copyAction);
JActionMenuItem5.setAccelerator(com.sun.java.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, Event.CTRL_MASK));
JActionMenuItem5.setMnemonic((int)'O');
editMenu.add(JActionMenuItem5);
JActionMenuItem6.setActionCommand("Paste");
JActionMenuItem6.setAction(pasteAction);
JActionMenuItem6.setAccelerator(com.sun.java.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, Event.CTRL_MASK));
JActionMenuItem6.setMnemonic((int)'P');
editMenu.add(JActionMenuItem6);
editMenu.add(JSeparator2);
JActionMenuItem8.setActionCommand("Undo");
JActionMenuItem8.setAction(undoAction);
JActionMenuItem8.setAccelerator(com.sun.java.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, Event.CTRL_MASK));
editMenu.add(JActionMenuItem8);
JActionMenuItem9.setActionCommand("Redo");
JActionMenuItem9.setAction(redoAction);
JActionMenuItem9.setAccelerator(com.sun.java.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, Event.SHIFT_MASK|Event.CTRL_MASK));
editMenu.add(JActionMenuItem9);
colorMenu.setText("Color");
colorMenu.setActionCommand("Color");
colorMenu.setMnemonic((int)'C');
JMenuBar1.add(colorMenu);
redMenu.setIcon(redColoredSquare);
redMenu.setHorizontalTextPosition(com.sun.java.swing.SwingConstants.RIGHT);
redMenu.setText("Red");
redMenu.setActionCommand("jmenuItem");
colorMenu.add(redMenu);
greenMenu.setIcon(greenColoredSquare);
greenMenu.setHorizontalTextPosition(com.sun.java.swing.SwingConstants.RIGHT);
greenMenu.setText("Green");
greenMenu.setActionCommand("Green");
colorMenu.add(greenMenu);
blueMenu.setIcon(blueColoredSquare);
blueMenu.setHorizontalTextPosition(com.sun.java.swing.SwingConstants.RIGHT);
blueMenu.setText("Blue");
blueMenu.setActionCommand("Blue");
colorMenu.add(blueMenu);
fontMenu.setText("Font");
fontMenu.setActionCommand("Font");
fontMenu.setMnemonic((int)'O');
JMenuBar1.add(fontMenu);
dialogFtMenu.setText("Dialog");
dialogFtMenu.setActionCommand("Dialog");
fontMenu.add(dialogFtMenu);
helveticaFtMenu.setText("Helvetica");
helveticaFtMenu.setActionCommand("Helvetica");
fontMenu.add(helveticaFtMenu);
timesFtMenu.setText("Times New Roman");
timesFtMenu.setActionCommand("Times New Roman");
fontMenu.add(timesFtMenu);
courierFtMenu.setText("Courier");
courierFtMenu.setActionCommand("Courier");
fontMenu.add(courierFtMenu);
fontMenu.add(JSeparator3);
ftSize8Menu.setText("8");
ftSize8Menu.setActionCommand("8");
fontMenu.add(ftSize8Menu);
ftSize12Menu.setText("12");
ftSize12Menu.setActionCommand("12");
fontMenu.add(ftSize12Menu);
ftSize14Menu.setText("14");
ftSize14Menu.setActionCommand("14");
fontMenu.add(ftSize14Menu);
ftSize18Menu.setText("18");
ftSize18Menu.setActionCommand("18");
fontMenu.add(ftSize18Menu);
ftSize24Menu.setText("24");
ftSize24Menu.setActionCommand("24");
fontMenu.add(ftSize24Menu);
fontMenu.add(JSeparator4);
JActionMenuItem10.setActionCommand("Bold");
JActionMenuItem10.setAction(boldAction);
fontMenu.add(JActionMenuItem10);
JActionMenuItem11.setActionCommand("Italic");
JActionMenuItem11.setAction(italicAction);
fontMenu.add(JActionMenuItem11);
JActionMenuItem12.setActionCommand("Underline");
JActionMenuItem12.setAction(underlineAction);
fontMenu.add(JActionMenuItem12);
//}}
editor.getDocument().addUndoableEditListener(undoHandler);
//remove labels from toolbars, and add tooltips
JActionButton1.setText("");
JActionButton1.setToolTipText((String)JActionButton1.getAction().getValue(Action.LONG_DESCRIPTION));
JActionButton2.setText("");
JActionButton2.setToolTipText((String)JActionButton2.getAction().getValue(Action.LONG_DESCRIPTION));
JActionButton3.setText("");
JActionButton3.setToolTipText((String)JActionButton3.getAction().getValue(Action.LONG_DESCRIPTION));
JActionButton4.setText("");
JActionButton4.setToolTipText((String)JActionButton4.getAction().getValue(Action.LONG_DESCRIPTION));
JActionButton5.setText("");
JActionButton5.setToolTipText((String)JActionButton5.getAction().getValue(Action.LONG_DESCRIPTION));
JActionButton6.setText("");
JActionButton6.setToolTipText((String)JActionButton6.getAction().getValue(Action.LONG_DESCRIPTION));
JActionButton7.setText("");
JActionButton7.setToolTipText((String)JActionButton7.getAction().getValue(Action.LONG_DESCRIPTION));
JActionButton8.setText("");
JActionButton8.setToolTipText((String)JActionButton8.getAction().getValue(Action.LONG_DESCRIPTION));
JActionButton9.setText("");
JActionButton9.setToolTipText((String)JActionButton9.getAction().getValue(Action.LONG_DESCRIPTION));
JActionButton10.setText("");
JActionButton10.setToolTipText((String)JActionButton10.getAction().getValue(Action.LONG_DESCRIPTION));
JActionButton11.setText("");
JActionButton11.setToolTipText((String)JActionButton11.getAction().getValue(Action.LONG_DESCRIPTION));
JActionButton12.setText("");
JActionButton12.setToolTipText((String)JActionButton12.getAction().getValue(Action.LONG_DESCRIPTION));
//{{INIT_MENUS
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
this.addWindowListener(aSymWindow);
SymAction lSymAction = new SymAction();
exitAction.addActionListener(lSymAction);
newAction.addActionListener(lSymAction);
openAction.addActionListener(lSymAction);
saveAction.addActionListener(lSymAction);
cutAction.addActionListener(lSymAction);
copyAction.addActionListener(lSymAction);
pasteAction.addActionListener(lSymAction);
undoAction.addActionListener(lSymAction);
redoAction.addActionListener(lSymAction);
boldAction.addActionListener(lSymAction);
italicAction.addActionListener(lSymAction);
underlineAction.addActionListener(lSymAction);
leftAction.addActionListener(lSymAction);
centerAction.addActionListener(lSymAction);
rightAction.addActionListener(lSymAction);
redMenu.addActionListener(lSymAction);
greenMenu.addActionListener(lSymAction);
blueMenu.addActionListener(lSymAction);
dialogFtMenu.addActionListener(lSymAction);
helveticaFtMenu.addActionListener(lSymAction);
timesFtMenu.addActionListener(lSymAction);
courierFtMenu.addActionListener(lSymAction);
ftSize8Menu.addActionListener(lSymAction);
ftSize12Menu.addActionListener(lSymAction);
ftSize14Menu.addActionListener(lSymAction);
ftSize18Menu.addActionListener(lSymAction);
ftSize24Menu.addActionListener(lSymAction);
loadWonderland.addActionListener(lSymAction);
//}}
}
void updateUndoStatus()
{
undoAction.setEnabled(undo.canUndo());
undoAction.setActionName(undo.getUndoPresentationName());
redoAction.setEnabled(undo.canRedo());
redoAction.setActionName(undo.getRedoPresentationName());
}
class UndoHandler implements UndoableEditListener {
/**
* Messaged when the Document has created an edit, the edit is
* added to <code>undo</code>, an instance of UndoManager.
*/
public void undoableEditHappened(UndoableEditEvent e)
{
undo.addEdit(e.getEdit());
updateUndoStatus();
}
}
UndoableEditListener undoHandler = new UndoHandler();
UndoManager undo = new UndoManager();
static public void main(String args[])
{
Stylepad sp = new Stylepad();
sp.setLocation(50,50);
sp.setVisible(true);
}
//{{DECLARE_CONTROLS
ColoredSquare redColoredSquare = new ColoredSquare();
ColoredSquare greenColoredSquare = new ColoredSquare();
ColoredSquare blueColoredSquare = new ColoredSquare();
com.symantec.itools.swing.icons.ImageIcon newIcon = new com.symantec.itools.swing.icons.ImageIcon();
com.symantec.itools.swing.icons.ImageIcon openIcon = new com.symantec.itools.swing.icons.ImageIcon();
com.symantec.itools.swing.icons.ImageIcon saveIcon = new com.symantec.itools.swing.icons.ImageIcon();
com.symantec.itools.swing.icons.ImageIcon cutIcon = new com.symantec.itools.swing.icons.ImageIcon();
com.symantec.itools.swing.icons.ImageIcon copyIcon = new com.symantec.itools.swing.icons.ImageIcon();
com.symantec.itools.swing.icons.ImageIcon pasteIcon = new com.symantec.itools.swing.icons.ImageIcon();
com.symantec.itools.swing.icons.ImageIcon boldIcon = new com.symantec.itools.swing.icons.ImageIcon();
com.symantec.itools.swing.icons.ImageIcon italicIcon = new com.symantec.itools.swing.icons.ImageIcon();
com.symantec.itools.swing.icons.ImageIcon underlineIcon = new com.symantec.itools.swing.icons.ImageIcon();
com.symantec.itools.swing.icons.ImageIcon leftIcon = new com.symantec.itools.swing.icons.ImageIcon();
com.symantec.itools.swing.icons.ImageIcon centerIcon = new com.symantec.itools.swing.icons.ImageIcon();
com.symantec.itools.swing.icons.ImageIcon rightIcon = new com.symantec.itools.swing.icons.ImageIcon();
BasicAction newAction = new BasicAction();
BasicAction openAction = new BasicAction();
BasicAction saveAction = new BasicAction();
BasicAction cutAction = new BasicAction();
BasicAction copyAction = new BasicAction();
BasicAction pasteAction = new BasicAction();
BasicAction undoAction = new BasicAction();
BasicAction redoAction = new BasicAction();
BasicAction boldAction = new BasicAction();
BasicAction italicAction = new BasicAction();
BasicAction underlineAction = new BasicAction();
BasicAction leftAction = new BasicAction();
BasicAction centerAction = new BasicAction();
BasicAction rightAction = new BasicAction();
BasicAction exitAction = new BasicAction();
com.sun.java.swing.JScrollPane JScrollPane1 = new com.sun.java.swing.JScrollPane();
com.sun.java.swing.JTextPane editor = new com.sun.java.swing.JTextPane();
com.sun.java.swing.JToolBar JToolBar1 = new com.sun.java.swing.JToolBar();
com.symantec.itools.swing.actions.JActionButton JActionButton1 = new com.symantec.itools.swing.actions.JActionButton();
com.symantec.itools.swing.actions.JActionButton JActionButton2 = new com.symantec.itools.swing.actions.JActionButton();
com.symantec.itools.swing.actions.JActionButton JActionButton3 = new com.symantec.itools.swing.actions.JActionButton();
com.symantec.itools.swing.JToolBarSeparator JToolBarSeparator1 = new com.symantec.itools.swing.JToolBarSeparator();
com.symantec.itools.swing.actions.JActionButton JActionButton4 = new com.symantec.itools.swing.actions.JActionButton();
com.symantec.itools.swing.actions.JActionButton JActionButton5 = new com.symantec.itools.swing.actions.JActionButton();
com.symantec.itools.swing.actions.JActionButton JActionButton6 = new com.symantec.itools.swing.actions.JActionButton();
com.symantec.itools.swing.JToolBarSeparator JToolBarSeparator2 = new com.symantec.itools.swing.JToolBarSeparator();
com.symantec.itools.swing.actions.JActionButton JActionButton7 = new com.symantec.itools.swing.actions.JActionButton();
com.symantec.itools.swing.actions.JActionButton JActionButton8 = new com.symantec.itools.swing.actions.JActionButton();
com.symantec.itools.swing.actions.JActionButton JActionButton9 = new com.symantec.itools.swing.actions.JActionButton();
com.symantec.itools.swing.JToolBarSeparator JToolBarSeparator3 = new com.symantec.itools.swing.JToolBarSeparator();
com.symantec.itools.swing.actions.JActionButton JActionButton10 = new com.symantec.itools.swing.actions.JActionButton();
com.symantec.itools.swing.actions.JActionButton JActionButton11 = new com.symantec.itools.swing.actions.JActionButton();
com.symantec.itools.swing.actions.JActionButton JActionButton12 = new com.symantec.itools.swing.actions.JActionButton();
com.sun.java.swing.JMenuBar JMenuBar1 = new com.sun.java.swing.JMenuBar();
com.sun.java.swing.JMenu fileMenu = new com.sun.java.swing.JMenu();
com.symantec.itools.swing.actions.JActionMenuItem JActionMenuItem1 = new com.symantec.itools.swing.actions.JActionMenuItem();
com.symantec.itools.swing.actions.JActionMenuItem JActionMenuItem2 = new com.symantec.itools.swing.actions.JActionMenuItem();
com.symantec.itools.swing.actions.JActionMenuItem JActionMenuItem3 = new com.symantec.itools.swing.actions.JActionMenuItem();
com.sun.java.swing.JSeparator JSeparator1 = new com.sun.java.swing.JSeparator();
com.sun.java.swing.JMenuItem loadWonderland = new com.sun.java.swing.JMenuItem();
com.sun.java.swing.JSeparator JSeparator5 = new com.sun.java.swing.JSeparator();
com.symantec.itools.swing.actions.JActionMenuItem JActionMenuItem7 = new com.symantec.itools.swing.actions.JActionMenuItem();
com.sun.java.swing.JMenu editMenu = new com.sun.java.swing.JMenu();
com.symantec.itools.swing.actions.JActionMenuItem JActionMenuItem4 = new com.symantec.itools.swing.actions.JActionMenuItem();
com.symantec.itools.swing.actions.JActionMenuItem JActionMenuItem5 = new com.symantec.itools.swing.actions.JActionMenuItem();
com.symantec.itools.swing.actions.JActionMenuItem JActionMenuItem6 = new com.symantec.itools.swing.actions.JActionMenuItem();
com.sun.java.swing.JSeparator JSeparator2 = new com.sun.java.swing.JSeparator();
com.symantec.itools.swing.actions.JActionMenuItem JActionMenuItem8 = new com.symantec.itools.swing.actions.JActionMenuItem();
com.symantec.itools.swing.actions.JActionMenuItem JActionMenuItem9 = new com.symantec.itools.swing.actions.JActionMenuItem();
com.sun.java.swing.JMenu colorMenu = new com.sun.java.swing.JMenu();
com.sun.java.swing.JMenuItem redMenu = new com.sun.java.swing.JMenuItem();
com.sun.java.swing.JMenuItem greenMenu = new com.sun.java.swing.JMenuItem();
com.sun.java.swing.JMenuItem blueMenu = new com.sun.java.swing.JMenuItem();
com.sun.java.swing.JMenu fontMenu = new com.sun.java.swing.JMenu();
com.sun.java.swing.JMenuItem dialogFtMenu = new com.sun.java.swing.JMenuItem();
com.sun.java.swing.JMenuItem helveticaFtMenu = new com.sun.java.swing.JMenuItem();
com.sun.java.swing.JMenuItem timesFtMenu = new com.sun.java.swing.JMenuItem();
com.sun.java.swing.JMenuItem courierFtMenu = new com.sun.java.swing.JMenuItem();
com.sun.java.swing.JSeparator JSeparator3 = new com.sun.java.swing.JSeparator();
com.sun.java.swing.JMenuItem ftSize8Menu = new com.sun.java.swing.JMenuItem();
com.sun.java.swing.JMenuItem ftSize12Menu = new com.sun.java.swing.JMenuItem();
com.sun.java.swing.JMenuItem ftSize14Menu = new com.sun.java.swing.JMenuItem();
com.sun.java.swing.JMenuItem ftSize18Menu = new com.sun.java.swing.JMenuItem();
com.sun.java.swing.JMenuItem ftSize24Menu = new com.sun.java.swing.JMenuItem();
com.sun.java.swing.JSeparator JSeparator4 = new com.sun.java.swing.JSeparator();
com.symantec.itools.swing.actions.JActionMenuItem JActionMenuItem10 = new com.symantec.itools.swing.actions.JActionMenuItem();
com.symantec.itools.swing.actions.JActionMenuItem JActionMenuItem11 = new com.symantec.itools.swing.actions.JActionMenuItem();
com.symantec.itools.swing.actions.JActionMenuItem JActionMenuItem12 = new com.symantec.itools.swing.actions.JActionMenuItem();
//}}
//{{DECLARE_MENUS
//}}
class SymWindow extends java.awt.event.WindowAdapter
{
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == Stylepad.this)
notepad_windowClosing(event);
}
}
void notepad_windowClosing(java.awt.event.WindowEvent event)
{
exitAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,"exit"));
}
class SymAction implements java.awt.event.ActionListener
{
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource();
if (object == exitAction)
exitAction_actionPerformed(event);
else if (object == newAction)
newAction_actionPerformed(event);
else if (object == openAction)
openAction_actionPerformed(event);
else if (object == saveAction)
saveAction_actionPerformed(event);
else if (object == cutAction)
cutAction_actionPerformed(event);
else if (object == copyAction)
copyAction_actionPerformed(event);
else if (object == pasteAction)
pasteAction_actionPerformed(event);
else if (object == undoAction)
undoAction_actionPerformed(event);
else if (object == redoAction)
redoAction_actionPerformed(event);
else if (object == boldAction)
boldAction_actionPerformed(event);
else if (object == italicAction)
italicAction_actionPerformed(event);
else if (object == underlineAction)
underlineAction_actionPerformed(event);
else if (object == leftAction)
leftAction_actionPerformed(event);
else if (object == centerAction)
centerAction_actionPerformed(event);
else if (object == rightAction)
rightAction_actionPerformed(event);
else if (object == redMenu)
redMenu_actionPerformed(event);
else if (object == greenMenu)
greenMenu_actionPerformed(event);
else if (object == blueMenu)
blueMenu_actionPerformed(event);
else if (object == dialogFtMenu)
dialogFtMenu_actionPerformed(event);
else if (object == helveticaFtMenu)
helveticaFtMenu_actionPerformed(event);
else if (object == timesFtMenu)
timesFtMenu_actionPerformed(event);
else if (object == courierFtMenu)
courierFtMenu_actionPerformed(event);
else if (object == ftSize8Menu)
ftSize8Menu_actionPerformed(event);
else if (object == ftSize12Menu)
ftSize12Menu_actionPerformed(event);
else if (object == ftSize14Menu)
ftSize14Menu_actionPerformed(event);
else if (object == ftSize18Menu)
ftSize18Menu_actionPerformed(event);
else if (object == ftSize24Menu)
ftSize24Menu_actionPerformed(event);
else if (object == loadWonderland)
loadWonderland_actionPerformed(event);
}
}
void exitAction_actionPerformed(java.awt.event.ActionEvent event)
{
System.exit(0);
}
void newAction_actionPerformed(java.awt.event.ActionEvent event)
{
Document oldDoc = editor.getDocument();
if(oldDoc != null)
{
oldDoc.removeUndoableEditListener(undoHandler);
}
editor.setDocument(new DefaultStyledDocument());
editor.getDocument().addUndoableEditListener(undoHandler);
undo.discardAllEdits();
updateUndoStatus();
setTitle("Untitled");
curFile=null;
curFileDir=null;
}
void openAction_actionPerformed(java.awt.event.ActionEvent event)
{
try
{
FileDialog fd = new FileDialog(this);
fd.setMode(FileDialog.LOAD);
fd.setVisible(true);
String theFile = fd.getFile();
String theFileDir = fd.getDirectory();
if ( (theFile == null) || (theFile.equals("")))
{
//no selected file so abort
return;
}
File f=new File(theFileDir, theFile);
if(!f.exists())
{ //file not there, abort
return;
}
Document oldDoc = editor.getDocument();
if(oldDoc != null)
{
oldDoc.removeUndoableEditListener(undoHandler);
}
setTitle(theFile);
FileInputStream fin = new FileInputStream(f);
ObjectInputStream in=new ObjectInputStream(fin);
editor.setDocument((Document)in.readObject());
in.close();
fin.close();
editor.getDocument().addUndoableEditListener(undoHandler);
undo.discardAllEdits();
updateUndoStatus();
curFile = theFile;
curFileDir = theFileDir;
setTitle(curFile);
}
catch(Exception e)
{
e.printStackTrace();
}
}
void saveAction_actionPerformed(java.awt.event.ActionEvent event)
{
try
{
String text = editor.getText();
if (curFile==null)
{
FileDialog fd = new FileDialog(this);
fd.setMode(FileDialog.SAVE);
fd.setVisible(true);
String theFile=fd.getFile();
String theFileDir=fd.getDirectory();
if ( (theFile == null) || (theFile.equals("")))
{
//no selected file so abort
return;
}
curFile=theFile;
curFileDir=theFileDir;
}
File f = new File(curFileDir, curFile);
FileOutputStream out = new FileOutputStream(f);
ObjectOutputStream ostrm = new ObjectOutputStream(out);
ostrm.writeObject(editor.getDocument());
ostrm.close();
out.close();
setTitle(curFile);
}
catch(Exception e)
{
e.printStackTrace();
}
}
void cutAction_actionPerformed(java.awt.event.ActionEvent event)
{
editor.cut();
}
void copyAction_actionPerformed(java.awt.event.ActionEvent event)
{
editor.copy();
}
void pasteAction_actionPerformed(java.awt.event.ActionEvent event)
{
editor.paste();
}
void undoAction_actionPerformed(java.awt.event.ActionEvent event)
{
try
{
undo.undo();
}
catch (Exception e)
{
e.printStackTrace();
}
updateUndoStatus();
}
void redoAction_actionPerformed(java.awt.event.ActionEvent event)
{
try
{
undo.redo();
}
catch (Exception e)
{
e.printStackTrace();
}
updateUndoStatus();
}
void boldAction_actionPerformed(java.awt.event.ActionEvent event)
{
StyledEditorKit sek= (StyledEditorKit)editor.getEditorKit();
MutableAttributeSet attr = sek.getInputAttributes();
boolean bold = (StyleConstants.isBold(attr)) ? false : true;
StyleConstants.setBold(attr, bold);
editor.setCharacterAttributes(attr, false);
}
void italicAction_actionPerformed(java.awt.event.ActionEvent event)
{
StyledEditorKit sek= (StyledEditorKit)editor.getEditorKit();
MutableAttributeSet attr = sek.getInputAttributes();
boolean italic = (StyleConstants.isItalic(attr)) ? false : true;
StyleConstants.setItalic(attr, italic);
editor.setCharacterAttributes(attr, false);
}
void underlineAction_actionPerformed(java.awt.event.ActionEvent event)
{
StyledEditorKit sek= (StyledEditorKit)editor.getEditorKit();
MutableAttributeSet attr = sek.getInputAttributes();
boolean underline = (StyleConstants.isUnderline(attr)) ? false : true;
StyleConstants.setUnderline(attr, underline);
editor.setCharacterAttributes(attr, false);
}
void leftAction_actionPerformed(java.awt.event.ActionEvent event)
{
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setAlignment(attr, StyleConstants.ALIGN_LEFT);
int p0 = editor.getSelectionStart();
int p1 = editor.getSelectionEnd();
StyledDocument doc = (StyledDocument)editor.getDocument();
doc.setParagraphAttributes(p0, p1 - p0, attr, true);
}
void centerAction_actionPerformed(java.awt.event.ActionEvent event)
{
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setAlignment(attr, StyleConstants.ALIGN_CENTER);
int p0 = editor.getSelectionStart();
int p1 = editor.getSelectionEnd();
StyledDocument doc = (StyledDocument)editor.getDocument();
doc.setParagraphAttributes(p0, p1 - p0, attr, true);
}
void rightAction_actionPerformed(java.awt.event.ActionEvent event)
{
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setAlignment(attr, StyleConstants.ALIGN_RIGHT);
int p0 = editor.getSelectionStart();
int p1 = editor.getSelectionEnd();
StyledDocument doc = (StyledDocument)editor.getDocument();
doc.setParagraphAttributes(p0, p1 - p0, attr, true);
}
void redMenu_actionPerformed(java.awt.event.ActionEvent event)
{
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setForeground(attr, Color.red);
editor.setCharacterAttributes(attr, false);
}
void greenMenu_actionPerformed(java.awt.event.ActionEvent event)
{
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setForeground(attr, Color.green);
editor.setCharacterAttributes(attr, false);
}
void blueMenu_actionPerformed(java.awt.event.ActionEvent event)
{
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setForeground(attr, Color.blue);
editor.setCharacterAttributes(attr, false);
}
void dialogFtMenu_actionPerformed(java.awt.event.ActionEvent event)
{
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setFontFamily(attr, "Dialog");
editor.setCharacterAttributes(attr, false);
}
void helveticaFtMenu_actionPerformed(java.awt.event.ActionEvent event)
{
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setFontFamily(attr, "Helvetica");
editor.setCharacterAttributes(attr, false);
}
void timesFtMenu_actionPerformed(java.awt.event.ActionEvent event)
{
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setFontFamily(attr, "TimesRoman");
editor.setCharacterAttributes(attr, false);
}
void courierFtMenu_actionPerformed(java.awt.event.ActionEvent event)
{
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setFontFamily(attr, "Courier");
editor.setCharacterAttributes(attr, false);
}
void ftSize8Menu_actionPerformed(java.awt.event.ActionEvent event)
{
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setFontSize(attr, 8);
editor.setCharacterAttributes(attr, false);
}
void ftSize12Menu_actionPerformed(java.awt.event.ActionEvent event)
{
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setFontSize(attr, 12);
editor.setCharacterAttributes(attr, false);
}
void ftSize14Menu_actionPerformed(java.awt.event.ActionEvent event)
{
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setFontSize(attr, 14);
editor.setCharacterAttributes(attr, false);
}
void ftSize18Menu_actionPerformed(java.awt.event.ActionEvent event)
{
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setFontSize(attr, 18);
editor.setCharacterAttributes(attr, false);
}
void ftSize24Menu_actionPerformed(java.awt.event.ActionEvent event)
{
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setFontSize(attr, 24);
editor.setCharacterAttributes(attr, false);
}
void loadWonderland_actionPerformed(java.awt.event.ActionEvent event)
{
StyleContext sc = new StyleContext();
DefaultStyledDocument doc = new DefaultStyledDocument(sc);
Wonderland wonder = new Wonderland(doc,sc);
wonder.loadDocument();
editor.setDocument(doc);
}
}