import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
public Main() {
setTitle("Open Challenge 9");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container rizz = getContentPane();
rizz.setLayout(new BorderLayout());
JPanel top = new JPanel();
top.setLayout(new FlowLayout());
top.setBackground(Color.LIGHT_GRAY);
String[] str = {"Open","Read","Close"};
for(int i=0;i<str.length;i++)
top.add(new JButton(str[i]));
// much cooler version of:
// top.add(new JButton("Open"));
// top.add(new JButton("Read"));
// top.add(new JButton("Close"));
JPanel middle = new JPanel();
middle.setLayout(null);
JLabel first = new JLabel("Hello");
first.setBounds(50, 50, 100, 40);
JLabel sec = new JLabel("Love");
sec.setBounds(850, 450, 100, 40);
JLabel third = new JLabel("Java");
third.setBounds(170, 600, 100, 40);
middle.add(first);
middle.add(sec);
middle.add(third);
rizz.add(top, BorderLayout.NORTH);
rizz.add(middle, BorderLayout.CENTER);
setSize(1000, 800);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
top of page
기능을 테스트하려면 라이브 사이트로 이동하세요.
GUI 3: border / flow / null layout
GUI 3: border / flow / null layout
댓글 0개
좋아요
댓글(0)
bottom of page