@leeappelbaum/

graphics01

Java Swing

No description

fork
loading
Files
  • Main.java
  • nohup.out
  • solution.class
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.awt.event.*; 
import java.awt.*; 
import javax.swing.*;

class solution extends JFrame { 
  
    // JFrame 
    static JFrame f; 
  
    // JButton 
    static JButton b, b1, b2; 
  
    // label to diaplay text 
    static JLabel l; 
  
    // main class 
    public static void main(String[] args) 
    { 
        // create a new frame to stor text field and button 
        f = new JFrame("panel"); 
  
        // create a label to display text 
        l = new JLabel("panel label"); 
  
        // create a new buttons 
        b = new JButton("button1"); 
        b1 = new JButton("button2"); 
        b2 = new JButton("button3"); 
  
        // create a panel to add buttons 
        JPanel p = new JPanel(); 
  
        // add buttons and textfield to panel 
        p.add(b); 
        p.add(b1); 
        p.add(b2); 
        p.add(l); 
  
        // setbackground of panel 
        p.setBackground(Color.red); 
  
        // add panel to frame 
        f.add(p); 
  
        // set the size of frame 
        f.setSize(300, 300); 
  
        f.show(); 
    } 
}