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);
}
위의 코드는 Color chooser 대화 상자를 표시하는 데 사용되는 코드입니다. 내 질문은, 나는 심지어 프로그램을 실행하거나 컴파일을 시작하지 않는다는 것이다. 하지만 색상 선택기 대화 상자가 자동으로 나타 납니까?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