Z:\Faculty\cindricbb\000work\CSC120\Java\lec18_s23\src\MUPanel.java |
1
2 import java.awt.*;
3 import javax.swing.*;
4
5 public class MUPanel extends JPanel {
6
7
8
9
10
11
12 public MUPanel() {
13 setLayout(null);
14 setPreferredSize(new Dimension(800, 300));
15 setName("Mount Union Java Program");
16 setUp();
17 setBackground(Color.WHITE);
18
19
20
21
22
23 }
24
25 @Override
26 public void paintComponent(Graphics g) {
27 super.paintComponent(g);
28
29
30
31 g.setFont( new Font("SansSerif", Font.PLAIN, 24));
32 g.drawString("Look in Java Console for answers", 50, 160);
33
34
35 }
36
37
38
39
40
41
42
43
44
45
46 public void setUp() {
47 for (Component c: getComponents())
48 c.setSize(c.getPreferredSize());
49 JFrame f = new JFrame(getName());
50 f.setContentPane(this);
51 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
52 f.pack();
53 f.setVisible(false);
54 }
55
56 public static void main(String args[]){new MUPanel();}
57
58 }
59