Assignment #43 and A Frame with a Panel with Writing on It
Code
/// Name: Brendan Baird
/// Period: 6
/// Program Name: A Frame with a Panel with Writing on It
/// File Name: Prog43.java
/// Date Finished: 10/7/2015
import javax.swing.*;
import java.awt.*;
public class Prog43
{
public static void main(String[] args)
{
Frame43 f = new Frame43();
f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
f.setVisible(true);
}
}
class Frame43 extends JFrame
{
public Frame43()
{
setTitle("43 rocks!");
setSize(300,200);
setLocation(100,200);
Panel143 panel = new Panel143();
Container cp = getContentPane();
cp.add(panel);
}
}
class Panel143 extends JPanel
{
public void paintComponent( Graphics g )
{
super.paintComponent(g);
g.drawString("Hi",75,100);
}
}
Picture of the output