-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode 109.txt
33 lines (25 loc) · 1.05 KB
/
code 109.txt
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
import java.awt.*;
import javax.swing.*;
public class JFrameWithExplicitContentPane extends JFrame {
private Container container1 = getContentPane();
private JButton btnThisButton = new JButton("Click Here");
// if you wanted to define your own colour ?
// Color someColor = new Color(r, g, b);
Color someColor = new Color(255, 255, 255);
// Color someColor = new Color(r, g, b, transparency); // value from 0.0 to 1.0 //0.0 transparent 1.0 opaque
public JFrameWithExplicitContentPane() {
setSize(250, 300);
container1.setLayout(new FlowLayout());
container1.add(btnThisButton);
container1.setBackground(Color.YELLOW); //Page 795 for other color constants
btnThisButton.setBackground(Color.RED);
btnThisButton.setForeground(Color.WHITE);
}
}
//********************************************************************************************
public class UsePanes1
public static void main(String[] args){
JFrameWithExplicitContentPane frMain = new JFrameWithExplicitContentPane();
frmMain.setVisible(true);
}
}