新聞中心
這篇文章將為大家詳細講解有關(guān)java怎么實現(xiàn)窗口跳轉(zhuǎn),小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
為玉樹等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及玉樹網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為網(wǎng)站設(shè)計制作、成都做網(wǎng)站、玉樹網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
假如有兩個frame,分別為frame1,frame2,frame1加個按鈕實現(xiàn)跳轉(zhuǎn).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("跳轉(zhuǎn)");
this.add(jb);
jb.addActionListener(this);//加入事件監(jiān)聽
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();
}
}
關(guān)于“java怎么實現(xiàn)窗口跳轉(zhuǎn)”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
本文標題:java怎么實現(xiàn)窗口跳轉(zhuǎn)
網(wǎng)頁鏈接:http://fisionsoft.com.cn/article/ghhopc.html