⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testchangelayout.java

📁 java绘图 java awt 经典绘图的例子,对于初学awt模块的人非常有帮助.
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package swing;import java.awt.BorderLayout;import java.awt.Container;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JPanel;/** * * @author zhaolin */public class TestChangeLayout extends JFrame {    JButton jb1 = new JButton("1");    JButton jb2 = new JButton("2");    JButton jb3 = new JButton("3");    JButton jb4 = new JButton("4");    JButton jb5 = new JButton("5");    Container c = new JPanel();    Container control = new JPanel();    JButton jbFlowLayout = new JButton("流式布局");    JButton jbBorderLayout = new JButton("边框布局");    public TestChangeLayout() {        c.add(jb1);        c.add(jb2);        c.add(jb3);        c.add(jb4);        c.add(jb5);        control.add(jbFlowLayout);        control.add(jbBorderLayout);        jbFlowLayout.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                //c.removeAll();                c.setLayout(new FlowLayout());                c.add(jb1);                c.add(jb2);                c.add(jb3);                c.add(jb4);                c.add(jb5);                c.validate();            }        });        jbBorderLayout.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                //c.removeAll();                c.setLayout(new BorderLayout());                c.add(jb1,"North");                c.add(jb2,"South");                c.add(jb3,"Center");                c.add(jb4,"West");                c.add(jb5,"East");                c.validate();            }        });        this.getContentPane().add(c);        this.getContentPane().add(control, "South");        this.pack();        this.setVisible(true);    }    public static void main(String[] args) {        new TestChangeLayout();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -