// this will soon be replaced
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;
}
void initDocument(DefaultStyledDocument doc, StyleContext sc) {
Wonderland w = new Wonderland(doc, sc);
w.loadDocument();
}
JComboBox<String> createFamilyChoices() {
JComboBox<String> b = new JComboBox<>();
String[] fontNames = GraphicsEnvironment.getLocalGraphicsEnvironment().
getAvailableFontFamilyNames(); for (String fontName : fontNames) {
b.addItem(fontName);
}
return b;
}
/** *Trystoreadafilewhichisassumedtobea *serializationofadocument.
*/ class OpenAction extends AbstractAction {
String file = fileDialog.getFile(); if (file == null) {
return;
}
String directory = fileDialog.getDirectory();
File f = new File(directory, file); if (f.exists()) { try {
FileInputStream fin = new FileInputStream(f);
ObjectInputStream istrm = new ObjectInputStream(fin);
Document doc = (Document) istrm.readObject(); if (getEditor().getDocument() != null) {
getEditor().getDocument().removeUndoableEditListener(
undoHandler);
}
getEditor().setDocument(doc);
doc.addUndoableEditListener(undoHandler);
resetUndoManager();
frame.setTitle(file);
validate();
} catch (IOException io) { // should put in status panel
System.err.println("IOException: " + io.getMessage());
} catch (ClassNotFoundException cnf) { // should put in status panel
System.err.println("Class not found: " + cnf.getMessage());
}
} else { // should put in status panel
System.err.println("No such file: " + f);
}
}
}
/** *Trystowritethedocumentasaserialization.
*/ class SaveAction extends AbstractAction {
SaveAction() { super(saveAction);
}
@Override publicvoid actionPerformed(ActionEvent e) {
Frame frame = getFrame(); if (fileDialog == null) {
fileDialog = new FileDialog(frame);
}
fileDialog.setMode(FileDialog.SAVE);
fileDialog.setVisible(true);
String file = fileDialog.getFile(); if (file == null) {
return;
}
String directory = fileDialog.getDirectory();
File f = new File(directory, file); try {
FileOutputStream fstrm = new FileOutputStream(f);
ObjectOutput ostrm = new ObjectOutputStream(fstrm);
ostrm.writeObject(getEditor().getDocument());
ostrm.flush();
frame.setTitle(f.getName());
} catch (IOException io) { // should put in status panel
System.err.println("IOException: " + io.getMessage());
}
}
}
/** *Createsanemptydocument.
*/ class NewAction extends AbstractAction {
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.