java中怎么由一个界面跳到另一个界面??

2025-01-04 15:35:52
推荐回答(2个)
回答1:

package Action;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Demo1 {
JFrame frame=new JFrame();
JLabel label=new JLabel("文本几行");
JTextField text=new JTextField();
JButton but=new JButton("确定");
public Demo1()
{
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(new Listener());
frame.add(label);
frame.add(text);
frame.add(but);
frame.setVisible(true);
}
class Listener implements ActionListener{
public void actionPerformed(ActionEvent e){
if(e.getSource()==but){
Demo2.k=Integer.parseInt(text.getText());
new Demo2();
}
}
}
public static void main(String[] args){
new Demo1();
}
}

package Action;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
class Demo2 {
static int k;
JFrame frame=new JFrame();
public Demo2(){
frame.setLayout(null);
frame.setLayout(new GridLayout(k,1,3,3));
for(int i=0;i JButton but=new JButton("按钮");
frame.add(but);
}
frame.setSize(300, 200);
frame.setVisible(true);
}
}

回答2:

行得通,跳转页面你会吧


<%
for(int i = 0; i < n; i++){
%>


<%
}
%>

就是在页面循环打印tr,n是多少,打印多少次