U E D R , A S I H C RSS

Convert App Into Applet/상욱

~cpp 
import java.awt.event.*;
import javax.swing.*;

public class Applet1 extends JApplet implements ActionListener {

	JButton button1;
	JButton button2;

	public void init() {
		
		button1 = new JButton("BUTTON1");
		button1.addActionListener(this);

		button2 = new JButton("BUTTON2");
		button2.addActionListener(this);

		JPanel panel = new JPanel();
		panel.add(button1);
		panel.add(button2);

		getContentPane().add(panel);

	}

	public void actionPerformed(ActionEvent ae) {
		if (ae.getSource() == button1) {
			JOptionPane.showMessageDialog(
				this,
				"Dialog 1",
				"1",
				JOptionPane.YES_NO_OPTION,
				null);
		} else if (ae.getSource() == button2) {
			JOptionPane.showMessageDialog(
				this,
				"Dialog 2",
				"2",
				JOptionPane.YES_NO_OPTION,
				null);
		}
	}
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:00
Processing time 0.0093 sec