打包成可执行jar。并删除无效的代码
parent
a662cf5068
commit
e1915db378
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,45 +0,0 @@
|
|||||||
package com.docus.sw.fenpan;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
/**
|
|
||||||
* @author EdwinD
|
|
||||||
* @create 2020.08.19 上午 08:31
|
|
||||||
* @desc Swing
|
|
||||||
**/
|
|
||||||
public class JFrameDemo1 {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new JFrameDemo1().init();
|
|
||||||
}
|
|
||||||
|
|
||||||
// init()初始化。
|
|
||||||
public void init() {
|
|
||||||
JFrame jFrame = new JFrame("这是我们的JFrame窗口。");
|
|
||||||
jFrame.setVisible(true);
|
|
||||||
jFrame.setBackground(Color.BLUE);
|
|
||||||
jFrame.setBounds(100, 100, 1024, 900);
|
|
||||||
jFrame.setLayout(new FlowLayout());
|
|
||||||
|
|
||||||
|
|
||||||
Panel panel2 = new Panel();
|
|
||||||
panel2.setLayout(new FlowLayout());
|
|
||||||
|
|
||||||
JLabel jl=new JLabel();
|
|
||||||
jl.setBounds(10,50,500,300);
|
|
||||||
|
|
||||||
JTextField jtf =new JTextField();
|
|
||||||
jtf.setBounds(10,10,150,30);
|
|
||||||
panel2.add(jtf);
|
|
||||||
|
|
||||||
JButton jButton2 = new JButton("启动");
|
|
||||||
panel2.add(jButton2);
|
|
||||||
|
|
||||||
jFrame.add(panel2);
|
|
||||||
|
|
||||||
|
|
||||||
// 关闭事件
|
|
||||||
jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
|||||||
package com.docus.sw.fenpan;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class MainJFrame extends JFrame {
|
|
||||||
|
|
||||||
|
|
||||||
public void init(){
|
|
||||||
JFrame jFrame = new JFrame("这是我们的JFrame窗口。");
|
|
||||||
jFrame.setVisible(true);
|
|
||||||
jFrame.setBackground(Color.BLUE);
|
|
||||||
jFrame.setBounds(0, 0, 1324, 900);
|
|
||||||
MigLayout layout = new MigLayout("wrap 2");
|
|
||||||
JPanel panel = new JPanel(layout);
|
|
||||||
panel.setVisible(true);
|
|
||||||
panel.add(new JLabel("Name"));
|
|
||||||
panel.add(new JTextField(""), "growx");
|
|
||||||
panel.add(new JLabel("Age"));
|
|
||||||
panel.add(new JTextField(""), "growx");
|
|
||||||
panel.add(new JLabel("Address"));
|
|
||||||
panel.add(new JTextArea(5, 20), "growx");
|
|
||||||
panel.add(new Button("提交"));
|
|
||||||
panel.add(new Button("关闭"));
|
|
||||||
jFrame.add(panel);
|
|
||||||
// 关闭事件
|
|
||||||
jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new MainJFrame().init();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
package com.docus.sw.fenpan;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class MyJFrame extends JFrame {
|
|
||||||
JPanel center =new JPanel();
|
|
||||||
public MyJFrame()throws IOException {
|
|
||||||
init();
|
|
||||||
this.setVisible(true);
|
|
||||||
}
|
|
||||||
private void init(){
|
|
||||||
this.setSize(800,600);
|
|
||||||
this.setTitle("随机小游戏");
|
|
||||||
this.setLocationRelativeTo(null);
|
|
||||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
this.setLayout(null); //设置为空布局
|
|
||||||
this.setResizable(false);
|
|
||||||
this.setBackground(Color.BLUE);
|
|
||||||
|
|
||||||
JLabel jl=new JLabel();
|
|
||||||
jl.setBounds(10,50,500,300);
|
|
||||||
|
|
||||||
JTextField jtf =new JTextField(); //文本框
|
|
||||||
jtf.setBounds(10,10,150,30);
|
|
||||||
|
|
||||||
JButton jb=new JButton("搜索"); //鼠标单击监听器
|
|
||||||
jb.setBounds(180,10,60,30);
|
|
||||||
jb.addActionListener(
|
|
||||||
(ActionListener) ->{
|
|
||||||
String text =jtf.getText();
|
|
||||||
jl.setText(text+"是个难得的人才");
|
|
||||||
});
|
|
||||||
jtf.addActionListener((ActionEvent e)->{ //常用键enter 用addActionListener
|
|
||||||
jb.doClick();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.add(jl);
|
|
||||||
this.add(jtf);
|
|
||||||
this.add(jb);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
|
||||||
new MyJFrame().init();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue