Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java GUI 设计 » SWT  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 在SWT中,如何点击一个按钮跳转到另外一个窗口?监听事件如何编写?
zf00110011





发贴: 14
积分: 0
于 2006-05-16 19:34 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
在SWT中,如何点击一个按钮跳转到另外一个窗口?监听事件如何编写?


作者 Re:在SWT中,如何点击一个按钮跳转到另外一个窗口?监听事件如何编写? [Re:zf00110011]
zf00110011





发贴: 14
积分: 0
于 2006-05-17 18:53 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
看来还是自己看书看的太少了,现在已经解决了。
主窗口:
。。。。。。
final Button button = new Button(shell, SWT.NONE);
    button.setText("button1");
    button.setBounds(115, 125, 105, 30);
    button.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(SelectionEvent e){
        HelloWorldone one = new HelloWorldone();
        one.open();
      }
    });
。。。。。。

被调用的窗口:
。。。。。。
  public void open() {
    final Display display = Display.getDefault();
    final Shell shell = new Shell();
    shell.setSize(500, 375);
    shell.setText("SWT Application");
    //

    shell.open();
    shell.layout();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
  }
。。。。。。。



作者 Re:在SWT中,如何点击一个按钮跳转到另外一个窗口?监听事件如何编写? [Re:zf00110011]
mmqq





发贴: 3
积分: 0
于 2006-06-08 09:40 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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(".\\66.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(".\\56.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();
}}

一个完整的程序



作者 Re:在SWT中,如何点击一个按钮跳转到另外一个窗口?监听事件如何编写? [Re:zf00110011]
gywinner





发贴: 1
积分: 0
于 2008-02-12 20:23 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
学习了,我是刚刚才学习java的



flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923