Java Panel Example

// JP.java
//
//
 
import java.lang.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
 
public class JP extends JPanel implements ActionListener
{
	JP()
	{
		JFrame frame = new JFrame("My Frame");
		frame.addWindowListener(
				new WindowAdapter() {
					public void windowClosing(WindowEvent e) {
						System.exit(0);
					}
				}
			);
		frame.setSize(500, 500);
		frame.setLayout(new FlowLayout());
		JButton quit = new JButton("Quit");
		quit.addActionListener(this);
		frame.add(quit);
		frame.setVisible(true);
	}
 
	public void actionPerformed(ActionEvent e) {
		System.exit(1);
	}
 
	public static void main(String[] args)
	{
		JP j = new JP();
		System.out.println(j.toString());
	}
}

start

javapanel.txt · Last modified: 2014/10/26 01:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0