Assignemnt #43: A Frame with a Panel with Writing on it
Code
/// Name: Cassie
/// Period: 6
/// Program Name: A Frame with a Panel with Writing on It
/// File Name: Panel.java
/// Date Finished: 11/13/2015
import javax.swing.*;
import java.awt.*;
class Panel
{
public static void main( String[] args )
{
Frame613 f = new Frame613();
f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
f.setVisible(true);
}
}
class Frame613 extends JFrame
{
public Frame613()
{
setTitle( "PUPPIES!" );
setSize(300, 200);
setLocation(100, 200);
Panel1613 panel = new Panel1613();
Container cp = getContentPane();
cp.add(panel);
}
}
class Panel1613 extends JPanel
{
public void paintComponent( Graphics g )
{
super.paintComponent(g);
g.drawString( "I like PUPPIES" , 75, 100);
}
}
Picture of the output