继承、封装、多态、
面板
import javax.swing.*;
import java.awt.*;
public class Jpanel extends JFrame {
public Jpanel() {
Container container = this.getContentPane();
container.setLayout(new GridLayout(2,1,10,10));//later function is intended
JPanel panel = new JPanel(new GridLayout(1,3));
JPanel panel2 = new JPanel(new GridLayout(1,3));
JPanel panel3 = new JPanel(new GridLayout(1,3));
JPanel panel4 = new JPanel(new GridLayout(1,3));
panel.add(new Button("1"));
panel.add(new Button("1"));
panel.add(new Button("1"));
container.add(panel);
this.setVisible(true);
this.setSize(500,500);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new Jpanel();
}
}
JScrollPanel
import javax.swing.*;
import java.awt.*;
public class JScorllDemo extends JFrame {
public JScorllDemo() {
Container container = this.getContentPane();
//TextArea
JTextArea textArea = new JTextArea(20,50);
textArea.setText("welcome to kuangshen java");
container.add(textArea);
//Scroll Panel
JScrollPane scrollPane = new JScrollPane(textArea);
container.add(scrollPane);
this.setVisible(true);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
this.setBounds(100,100,300,300);
}
public static void main(String[] args) {
new JScorllDemo();
}
}