lab12
This commit is contained in:
30
lab/lab12/Question1/MyFrame.java
Normal file
30
lab/lab12/Question1/MyFrame.java
Normal file
@@ -0,0 +1,30 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class MyFrame extends JFrame {
|
||||
public MyFrame() {
|
||||
// init frame
|
||||
setSize(400, 300);
|
||||
setTitle("MyFrame");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
// craete components
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new FlowLayout(FlowLayout.CENTER));
|
||||
JButton button1 = new JButton("left");
|
||||
JButton button2 = new JButton("right");
|
||||
|
||||
// set layout
|
||||
panel.add(button1);
|
||||
panel.add(button2);
|
||||
add(panel, BorderLayout.PAGE_START);
|
||||
|
||||
// MyPanel object
|
||||
MyPanel mp = new MyPanel(new FlowLayout(FlowLayout.CENTER));
|
||||
add(mp, BorderLayout.CENTER);
|
||||
|
||||
// done
|
||||
setVisible(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user