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);
}
以上是我用來顯示顏色選擇器對話框的代碼。我的問題是,我從來沒有開始運行或編譯程序。但顏色選擇器對話框會自動出現?Swing JDialog框出現嗎?
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();
}
}
以及顯示鏈接對話框也會自動出現,當我還在編碼時。任何想法?
我使用eclipse可視化編輯器打開它。這是正常的,如果用可視化編輯器打開,那麼對話框會自動彈出?因爲當我用java編輯器打開它時,對話框不會彈出。 – user236501