導航:首頁 > 編程語言 > 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如何跳轉頁面跳轉頁面相關的資料

熱點內容
路由器搭橋遠端伺服器地址是什麼 瀏覽:515
編譯動態庫時會連接依賴庫嗎 瀏覽:706
淘寶手機加密是隨機的嗎 瀏覽:672
解壓包子怎麼裝飾 瀏覽:585
四個數湊24演算法 瀏覽:676
哪一種不是vi編譯器的模式 瀏覽:168
xp在此處打開命令窗口 瀏覽:128
代碼編譯運行用什麼軟體 瀏覽:997
動態庫在程序編譯時會被連接到 瀏覽:760
python超簡單編程 瀏覽:259
獲取命令方 瀏覽:976
怎樣製作文件夾和圖片 瀏覽:60
調研編譯寫信息 瀏覽:861
python馮諾依曼 瀏覽:419
同時安裝多個app有什麼影響 瀏覽:254
奧術殺戮命令宏 瀏覽:184
用sdes加密明文字母e 瀏覽:361
單片機原理及應用試題 瀏覽:425
易語言開啟指定文件夾 瀏覽:40
馬思純參加密室大逃脫 瀏覽:322