demoflowlayout.java
来自「基于netbeans的java桌面应用程序合集」· Java 代码 · 共 43 行
JAVA
43 行
/*
* DemoFlowLayout.java
*
* Created on 2007年7月31日, 下午9:16
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package org.Adam;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
/**
*
* @author Administrator
*/
public class DemoFlowLayout extends JFrame implements ActionListener{
JButton buttonAction;
/** Creates a new instance of DemoFlowLayout */
public DemoFlowLayout() {
this.setLayout(new FlowLayout());
buttonAction=new JButton("动作按钮");
buttonAction.addActionListener(this);
this.add(buttonAction);
this.setBounds(150,150,350,120);
this.setTitle("FlowLayout完整示例");
this.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==buttonAction){
JButton buttonCommon=new JButton("普通按钮");
this.add(buttonCommon);
this.validate();
}
}
public static void main(String[] args) {
new DemoFlowLayout().setVisible(true);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?