public Action colorAction = new AbstractAction("Font Color", new ImageIcon(
getClass().getResource("/img/color.png"))) {
public void actionPerformed(ActionEvent e) {
colorB_actionPerformed(e);
}
};
public void colorB_actionPerformed(ActionEvent e) {
Color c = JColorChooser.showDialog(getRightPanel(), "Font color",
Color.CYAN);
if (c == null)
return;
new StyledEditorKit.ForegroundAction("", c).actionPerformed(e);
}
Выше приведен код, который я использую для отображения диалога выбора цвета. Мой вопрос, я никогда даже не запускаю и не компилирую программу. А диалог выбора цвета появится автоматически?
public void linkActionB_actionPerformed(ActionEvent e) {
String value = JOptionPane.showInputDialog(getJPanel(), "Enter URL :");
String aTag = "<a";
aTag += " href=\"" + value + "\"";
aTag += ">" + value + "</a>";
if (editor.getCaretPosition() == document.getLength())
aTag += " ";
editor.replaceSelection("");
try {
editorKit.insertHTML(document, editor.getCaretPosition(), aTag, 0,
0, HTML.Tag.A);
} catch (Exception ex) {
ex.printStackTrace();
}
}
, а также диалог показа ссылки также появится автоматически, когда я все еще кодировал. Есть идеи?