-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path53 .BorderLayout.java
More file actions
64 lines (48 loc) · 1.48 KB
/
53 .BorderLayout.java
File metadata and controls
64 lines (48 loc) · 1.48 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
package test;
import java.util.Arrays;
import java.util.Scanner;
//import javax.swing.*;
//import java.lang.Math;
//import java.util.Random;
//import java.io.IOException;
//import java.util.Arrays;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//import java.util.HashMap;
import java.io.*;
import java.util.*;
//import javax.sound.sampled.*;
import java.awt.*; // abstract window toolkit
import javax.swing.*;
import javax.imageio.ImageIO;
public class main{
// BorderLayout .
// BorderLayout :
//
public static void main(String[] args) {
// TODO Auto-generated method stub
// Declare the Scanner library
Scanner scanner = new Scanner(System.in);
// createframe, size, title
JFrame frame = new JFrame();
frame.setSize(300,200);
frame.setTitle("BorderLayout");
// create new panelwith borderlayout manager
JPanel panel = new JPanel(new BorderLayout());
//create component buttons and add to the main panel
JButton top = new JButton("Top");
JButton bottom = new JButton("Bottom");
JButton left = new JButton("Left");
JButton right = new JButton("Right");
JButton center = new JButton("Center");
// add the buttons to panel with the borderlayout constraints
panel.add(top, BorderLayout.NORTH);
panel.add(left, BorderLayout.WEST);
panel.add(center, BorderLayout.CENTER);
panel.add(right, BorderLayout.EAST);
panel.add(bottom, BorderLayout.SOUTH);
frame.add(panel);
frame.setVisible(true);
}
}