java双击添加文本框_java图形界面 怎么文本框要用鼠标点一下才出来
該樓層疑似違規已被系統折疊?隱藏此樓查看此樓
import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.util.*;
public class BuildMaze extends JFrame implements ActionListener{private JButton random,Return,display,choice;private ImageIcon icon;private JPanel panel,northpanel,centerpanel,southpanel;private JLabel label,label1;private JTextField txt1,txt2;?? private int num1,num2;?? private JRadioButton[] one,zeor;?? private JTextField[][] text;public BuildMaze(){Init();?? ???? this.setMinimumSize(new Dimension(700,600));?? setLocation(200,200);????? this.setTitle("建立迷宮"); this.add(panel);?? this.pack();?? this.setVisible(true);?? this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}public void Init(){icon = new ImageIcon ("111.gif"); panel = new JPanel(); northpanel = new JPanel();centerpanel = new JPanel();southpanel = new JPanel();panel.setLayout(new BorderLayout());?? random = new JButton("自動建立",icon);?? Return = new JButton("返回菜單",icon);?? display = new JButton ("顯示迷宮",icon);?? choice = new JButton("確定");?? ??? label = new JLabel("請輸入迷宮矩陣的行數和列數:");?? txt1 = new JTextField(2);?? txt2 = new JTextField(2);?? ???? panel.setBackground (Color.white);??? southpanel.add(random);?? southpanel.add(Return);?? northpanel.add(label);?? northpanel.add(txt1);?? northpanel.add(txt2);?? northpanel.add(choice);?? southpanel.add(display);; ???? txt1.addActionListener (this);?? txt2.addActionListener (this);?? random.addActionListener (this);?? Return.addActionListener (this);?? display.addActionListener (this);?? choice.addActionListener (this);?? panel.add(northpanel,BorderLayout.NORTH);?? panel.add(centerpanel,BorderLayout.CENTER);?? panel.add(southpanel,BorderLayout.SOUTH);}public void actionPerformed (ActionEvent event){ ?? if (event.getSource()==random) System.out.println("b"); else if (event.getSource()==display) { JFrame displayMaze = new DisplayMaze();}else if (event.getSource()==choice){ String text1 = txt1.getText(); String text2 = txt2.getText(); num1 = Integer.parseInt (text1); num2 = Integer.parseInt (text2); text = new JTextField[num1][num2]; //centerpanel.removeAll();?? centerpanel.setLayout (null);?? centerpanel.setBackground(Color.black); for(int i=0;i
總結
以上是生活随笔為你收集整理的java双击添加文本框_java图形界面 怎么文本框要用鼠标点一下才出来的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux查看tcp络连接日志,Linu
- 下一篇: linux内核mtd分区,linux-k