U E D R , A S I H C RSS

Button/영동

음... 참고 한다는게 예제를 거의 베끼다시피 해버렸네요.
베꼈다고 꼭 나쁜건 아닙니다 다만 모든 라인을 다 이해만 했다면 됩니다 --상규

~cpp 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class JOptionPaneTest extends JFrame implements ActionListener {
	JButton 버튼1, 버튼2 ;
	Icon 아이콘;
	Font font;
	public JOptionPaneTest() {
		super("JOptionPaneTest");

		버튼1 = new JButton("1번");
		버튼1.addActionListener(this);
		버튼2 = new JButton("2번");
		버튼2.addActionListener(this);
		   
		아이콘 = new ImageIcon("aaa.jpg");

		JPanel panel = new JPanel();
		panel.add(버튼1);
		panel.add(버튼2);
		
		getContentPane().add(panel);
	}
	public void actionPerformed(ActionEvent ae) {
		if (ae.getSource() == 버튼1) {
			JOptionPane.showMessageDialog(
				this,
				"1번",
				"1번선택",
				JOptionPane.YES_NO_OPTION,
				아이콘);
		} else if (ae.getSource() == 버튼2) {
			Object res =
				JOptionPane.showInputDialog(
					this,
					"2번",
					"2번선택",
					JOptionPane.QUESTION_MESSAGE,
					아이콘,
					new Object[] { "2-1", "2-2", "2-3" },
					"2-1");
			JOptionPane.showMessageDialog(
				this,
				"선택한 것:  " + res,
				"선택결과",
				JOptionPane.INFORMATION_MESSAGE,
				아이콘);
		}
	}
	public static void main(String[] args) {
		JFrame.setDefaultLookAndFeelDecorated(true);
		JDialog.setDefaultLookAndFeelDecorated(true);
		JFrame f = new JOptionPaneTest();
		f.setSize(200, 150);
		f.setVisible(true);
	}
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:40
Processing time 0.0105 sec