java GUI点击一个按钮怎么跳转到下一个窗口 20
1个回答
2017-08-21
展开全部
packageAction;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.*;publicclassDemo1{JFrameframe=newJFrame();JLabellabel=newJLabel("文本几行");JTextFieldtext=newJTextField();JButtonbut=newJButton("确定");publicDemo1(){frame.setLayout(null);frame.setSize(300,200);label.setBounds(50,10,70,20);text.setBounds(110,10,80,20);but.setBounds(200,10,80,20);but.addActionListener(newListener());frame.add(label);frame.add(text);frame.add(but);frame.setVisible(true);}classListenerimplementsActionListener{publicvoidactionPerformed(ActionEvente){if(e.getSource()==but){Demo2.k=Integer.parseInt(text.getText());newDemo2();}}}publicstaticvoidmain(String[]args){newDemo1();}}packageAction;importjava.awt.GridLayout;importjavax.swing.JButton;importjavax.swing.JFrame;classDemo2{staticintk;JFrameframe=newJFrame();publicDemo2(){frame.setLayout(null);frame.setLayout(newGridLayout(k,1,3,3));for(inti=0;i
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询