Methods Summary |
---|
javax.swing.JMenu | createColorMenu()
ActionListener a;
JMenuItem mi;
JMenu menu = new JMenu(getResourceString("color" + labelSuffix));
mi = new JMenuItem(resources.getString("Red"));
mi.setHorizontalTextPosition(JButton.RIGHT);
mi.setIcon(new ColoredSquare(Color.red));
a = new StyledEditorKit.ForegroundAction("set-foreground-red", Color.red);
//a = new ColorAction(se, Color.red);
mi.addActionListener(a);
menu.add(mi);
mi = new JMenuItem(resources.getString("Green"));
mi.setHorizontalTextPosition(JButton.RIGHT);
mi.setIcon(new ColoredSquare(Color.green));
a = new StyledEditorKit.ForegroundAction("set-foreground-green", Color.green);
//a = new ColorAction(se, Color.green);
mi.addActionListener(a);
menu.add(mi);
mi = new JMenuItem(resources.getString("Blue"));
mi.setHorizontalTextPosition(JButton.RIGHT);
mi.setIcon(new ColoredSquare(Color.blue));
a = new StyledEditorKit.ForegroundAction("set-foreground-blue", Color.blue);
//a = new ColorAction(se, Color.blue);
mi.addActionListener(a);
menu.add(mi);
return menu;
|
protected javax.swing.text.JTextComponent | createEditor()Create an editor to represent the given document.
StyleContext sc = new StyleContext();
DefaultStyledDocument doc = new DefaultStyledDocument(sc);
initDocument(doc, sc);
JTextPane p = new JTextPane(doc);
p.setDragEnabled(true);
//p.getCaret().setBlinkRate(0);
return p;
|
javax.swing.JComboBox | createFamilyChoices()
JComboBox b = new JComboBox();
String[] fonts = getToolkit().getFontList();
for (int i = 0; i < fonts.length; i++) {
b.addItem(fonts[i]);
}
return b;
|
protected javax.swing.JMenu | createMenu(java.lang.String key)Create a menu for the app. This is redefined to trap
a couple of special entries for now.
if (key.equals("color")) {
return createColorMenu();
}
return super.createMenu(key);
|
public javax.swing.Action[] | getActions()Fetch the list of actions supported by this
editor. It is implemented to return the list
of actions supported by the superclass
augmented with the actions defined locally.
Action[] defaultActions = {
new NewAction(),
new OpenAction(),
new SaveAction(),
new StyledEditorKit.FontFamilyAction("font-family-LucidaSans",
"Lucida Sans"),
};
Action[] a = TextAction.augmentList(super.getActions(), defaultActions);
return a;
|
protected java.lang.String | getResourceString(java.lang.String nm)Try and resolve the resource name in the local
resource file, and if not found fall back to
the superclass resource file.
String str;
try {
str = this.resources.getString(nm);
} catch (MissingResourceException mre) {
str = super.getResourceString(nm);
}
return str;
|
void | initDocument(javax.swing.text.DefaultStyledDocument doc, javax.swing.text.StyleContext sc)
Wonderland w = new Wonderland(doc, sc);
//HelloWorld h = new HelloWorld(doc, sc);
Icon alice = new ImageIcon(resources.getString("aliceGif"));
w.loadDocument();
|
public static void | main(java.lang.String[] args)
String vers = System.getProperty("java.version");
if (vers.compareTo("1.1.2") < 0) {
System.out.println("!!!WARNING: Swing must be run with a " +
"1.1.2 or higher version VM!!!");
}
JFrame frame = new JFrame();
frame.setTitle(resources.getString("Title"));
frame.setBackground(Color.lightGray);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add("Center", new Stylepad());
frame.addWindowListener(new AppCloser());
frame.pack();
frame.setSize(600, 480);
frame.show();
|