/*
* Created on Nov 3, 2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package org.eclipsebook.ch06;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
* @author Steven Holzner
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class Ch06_03 extends JFrame {
Panel p;
public Ch06_03()
{
super("Swing application");
Container contentPane = getContentPane();
p = new Panel();
contentPane.add(p);
}
public static void main(String args[])
{
final JFrame f = new Ch06_03();
f.setBounds(100, 100, 300, 300);
f.setVisible(true);
f.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
class Panel extends JPanel
{
Panel()
{
setBackground(Color.white);
}
public void paintComponent (Graphics g)
{
super.paintComponent(g);
g.drawString("Hello from Eclipse!", 60, 100);
}
}
|