JOptionPane
에서 아이콘을 제거하는 방법?JOptionPane에서 아이콘 제거
ImageIcon icon = new ImageIcon(image);
JLabel label = new JLabel(icon);
int result = JOptionPane.showConfirmDialog((Component) null, label, "ScreenPreview", JOptionPane.OK_CANCEL_OPTION);
JOptionPane
에서 아이콘을 제거하는 방법?JOptionPane에서 아이콘 제거
ImageIcon icon = new ImageIcon(image);
JLabel label = new JLabel(icon);
int result = JOptionPane.showConfirmDialog((Component) null, label, "ScreenPreview", JOptionPane.OK_CANCEL_OPTION);
직접 메시지의 모양과 느낌을 지정하여 그것을 할 수 있습니다.
코드가 없으면 아이콘이없는 "PLAIN_MESSAGE"스타일을 사용하지만 코드는 기본값을 사용합니다. 구성 요소의 동작은 변경되지 않습니다.
JOptionPane.showConfirmDialog(null, label, "ScreenPreview", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
상세 정보 : http://docs.oracle.com/javase/6/docs/api/javax/swing/JOptionPane.html
이 (검은 색 '스플래시 이미지'반대) 아래 투명한 아이콘을 사용하여 매우 편리합니다. 옵션 창은 표시 방법과 관련하여 '흔들리는 공간'을 제공하지만 두 가지를 변경하면 대신 JDialog
을 사용하는 것이 더 쉬워집니다.
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
class IconFree {
public static void main(String[] args) {
Runnable r = new Runnable() {
@Override
public void run() {
// A transparent image is invisible by default.
Image image = new BufferedImage(
1, 1, BufferedImage.TYPE_INT_ARGB);
JPanel gui = new JPanel(new BorderLayout());
// ..while an RGB image is black by default.
JLabel clouds = new JLabel(new ImageIcon(new BufferedImage(
250, 100, BufferedImage.TYPE_INT_RGB)));
gui.add(clouds);
JOptionPane.showConfirmDialog(null, gui, "Title",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE,
new ImageIcon(image));
}
};
// Swing GUIs should be created and updated on the EDT
// http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html
SwingUtilities.invokeLater(r);
}
}
JOptionPane.PLAIN_MESSAGE ? – mishik
http://stackoverflow.com/a/10489515/2381006 –
@mishik : JOptionPane.PLAIN_MESSAGE가 허용하지 않습니다. 확인 취소 버튼. –