导航:首页 > 编程语言 > java如何跳转页面跳转页面

java如何跳转页面跳转页面

发布时间:2022-09-12 05:26:22

1. java按一下按钮就能跳到另一个界面怎么实现

java实现的简单登录页面,从一个按钮点击后跳转的页面的jframe写法:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class jb{
public static void main(String args[]){
JFrame f=new JFrame("点我跳转");
Container contentPane=f.getContentPane();
contentPane.setLayout(new GridLayout(1,2));
Icon icon=new ImageIcon("b.jpg");
JLabel label2=new JLabel("a",icon,JLabel.CENTER);
label2.setHorizontalTextPosition(JLabel.CENTER);
contentPane.setLayout(new FlowLayout( FlowLayout.CENTER,10,10));
JButton bb=new JButton("图片");
bb.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JFrame bf=new JFrame("新窗体");
Icon icon=new ImageIcon("enter.jpg");
JLabel label2=new JLabel(icon);
bf.getContentPane().add(label2);
bf.setSize(300,360);
bf.show();
}});
contentPane.add(label2);
contentPane.add(bb);
f.pack();
f.show();
}}

2. JAVA怎么简单的跳转界面

JButton不是有触发事件吗,如单击或双击事件呀,
先在zhu.java中,
ci
frame
=
new
ci();
单击JButton后
frame.setVisuable(true);

3. 在java web开发中,凡是能实现页面跳转的方法有哪些具体列出这些方法的实现语句

一、跳转到新页面,并且是在新窗口中打开页面:
function openHtml()
{
//do someghing here...
window.open("xxxx.html");
}
window是一个javascript对象,可以用它的open方法,需要注意的是,如果这个页面不是一相相对路径,那么要加“http://”,比如:
function openHtml()
{
window.open("http://www..com");
}

二、在本页面窗口中跳转:
function totest2()
{
window.location.assign("test2.html");
}
如果直接使用location.assgin()也可以,但是window.location.assign()更合理一些,当前窗口的location对象的assign()方法。
另外,location对象还有一个方法replace()也可以做页面跳转,它跟assign()方法的区别在于:
replace() 方法不会在 History 对象中生成一个新的纪录。当使用该方法时,新的 URL 将覆盖 History 对象中的当前纪录。

4. java界面跳转

jButton.addActionListener(newjava.awt.event.ActionListener(){
publicvoidactionPerformed(java.awt.event.ActionEvente){
newGUI();
}
其中GUI为你所想显示的界面.jButton是你所声明的按纽对象.

5. java中如何做到界面的跳转

假如有两个frame,分别为frame1,frame2,frame1加个按钮实现跳转.frame1代码如下
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class frame1 extends JFrame implements ActionListener{

/**
* @param args
*/
private JButton jb;
public frame1()
{
this.setSize(300, 200);
this.setLocation(300, 400);
jb=new JButton("跳转");
this.add(jb);
jb.addActionListener(this);//加入事件监听
this.setVisible(true);

}
public static void main(String[] args) {
// TODO Auto-generated method stub
frame1 frame=new frame1();

}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==jb)
{
this.dispose();//点击按钮时frame1销毁,new一个frame2
new frame2();
}
}

}

frame2是个单纯的界面
import javax.swing.JButton;
import javax.swing.JFrame;

public class frame2 extends JFrame{

/**
* @param args
*/
public frame2()
{

this.setSize(300, 200);
this.setLocation(300, 400);

this.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
frame2 frame=new frame2();
}

}

6. java怎么实现窗口跳转

完整程序没那个功夫,如果你说的是Swing开发的话,通常是在点击按钮的时候把当前窗口的对象传递给即将打开的子窗口,并在子窗口的onload事件中控制父窗口的显示状态。

7. java中如何做到界面的跳转

假如有两个frame,分别为frame1,frame2,frame1加个按钮实现跳转.frame1代码如下
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class frame1 extends JFrame implements ActionListener{

/**
* @param args
*/
private JButton jb;
public frame1()
{
this.setSize(300, 200);
this.setLocation(300, 400);
jb=new JButton("跳转");
this.add(jb);
jb.addActionListener(this);//加入事件监听
this.setVisible(true);

}
public static void main(String[] args) {
// TODO Auto-generated method stub
frame1 frame=new frame1();

}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==jb)
{
this.dispose();//点击按钮时frame1销毁,new一个frame2
new frame2();
}
}

}

frame2是个单纯的界面
import javax.swing.JButton;
import javax.swing.JFrame;

public class frame2 extends JFrame{

/**
* @param args
*/
public frame2()
{

this.setSize(300, 200);
this.setLocation(300, 400);

this.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
frame2 frame=new frame2();
}

}

8. java程序中如何实现单击页面a中的按钮跳转到页面b

java程序中的jsp页面点击按钮跳转到页面b的方式如下:
1.jsp页面的方式如下:<a href="....b.jsp">跳转</a>
response.sendRedirect("b.jsp")
<jsp:forward page="b.jsp"/>
2.在swing里,给button加一个监听器,然后在监听事件中打开另一个页面。
在jsp或是静态网页里,onclick=“JavaScript:window.location=’xx‘”

9. 在java,在静态页面中的input标签中,如何实现点击跳转到后台页面的事件,并

咨询记录 · 回答于2021-11-19

阅读全文

与java如何跳转页面跳转页面相关的资料

热点内容
华为交换机dhcp配置命令 浏览:315
androidbitmap缩小 浏览:271
单片机串口控制灯 浏览:84
大讯云服务器安装视频 浏览:784
华为算法领先世界 浏览:654
linux路由重启 浏览:566
php的模板编程 浏览:320
编译器原理与实现书 浏览:709
dos选择命令 浏览:17
apm固件编译到单片机 浏览:121
联通深蓝卡都包含什么app 浏览:264
如何判断网络服务器正常 浏览:651
路由器搭桥远端服务器地址是什么 浏览:517
编译动态库时会连接依赖库吗 浏览:709
淘宝手机加密是随机的吗 浏览:675
解压包子怎么装饰 浏览:587
四个数凑24算法 浏览:679
哪一种不是vi编译器的模式 浏览:171
xp在此处打开命令窗口 浏览:130
代码编译运行用什么软件 浏览:1000