U E D R , A S I H C RSS

JTD Study/두번째과제/상욱

소스

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

public class HelloWorld extends JApplet implements ActionListener {
	private JButton button1;
	private GridBagLayout gl;
	private GridBagConstraints gc;
	
	public void init() {
		gl = new GridBagLayout();
		gc = new GridBagConstraints();				
		this.setLayout(gl);
		
		this.addButton();
	}	
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == button1) {
			JOptionPane.showMessageDialog(null, "Hello, World");
		}
		
	}
	public void addButton() {
		button1 = new JButton("Click!");
		button1.addActionListener(this);
		
		gc.gridx = 0;
		gc.gridy = 0;
		gc.gridwidth = 0;
		gc.gridheight = 1;
		gc.weightx = 1;
		gc.weighty = 1;
		gl.setConstraints(button1, gc);
		this.add(button1);
	}
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:29
Processing time 0.0068 sec