楼上的弓虽啊,007?哈~在线等ing

解决方案 »

  1.   

    JOptionPane.showConfirmDialog(this, "email地址文件有错误",
                                             "出现错误", JOptionPane.PLAIN_MESSAGE) ;
    这个算么
      

  2.   

    楼上的,这个不算,喉喉,我说的是JFrame
      

  3.   

    建议你看看JAVA自带的DEMO程序!
      

  4.   

    程序太场了 没时间看啊!
    建议去看看 SWING吧
      

  5.   

    写个JFrame派生类。
    在你要用的地方new一个就行。
      

  6.   

    To:射天狼
    老大,我上周末才开始学java滴,以前一点也不知道,这几天光看demo了
    swing也看了不少
    不过好象还没看懂啊,汗.....
    还有人嫌我写的程序长,这才几行啊,汗.....
      

  7.   

    对,楼上的说得没错,如果显示不了设置 setVisible(true)
      

  8.   

    JFrame jframe=new JFrame();
    jframe.setSize(new Dimension(640, 480));
    jframe.setVisible(true);
      

  9.   

    哪一位给个完整的代码啊,我刚看了几天java,对整体把握太模糊,程序总出错拜托拜托各位了
      

  10.   

    放在init()方法中,最好是放在该方法的最后
      

  11.   

    老大,呜呜呜,还是不行啊,我索性把我现在的代码全贴上来吧,有两个文件
    一个是designer.java,一个是toolbox.java
    toolbox是定义了一个简单的JFrame扩展类
    Designer.java如下:
    package module;/**
     * @author Administrator
     *
     * TODO To change the template for this generated type comment go to
     * Window - Preferences - Java - Code Style - Code Templates
     */import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.io.BufferedInputStream;
    public class Designer extends JApplet implements ActionListener{
    //ActionListener actlsnr;
    ImageIcon formatIcon;
        ImageIcon controIcon;
        ToolBox toolbox;
    protected String formatButtonFilename = "/images/format.gif";
    protected String controlButtonFilename = "/images/control.gif";
    public Designer(){

    }
    public void init(){
    try{
    javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        createGUI();
                        toolbox = new ToolBox();
                    }
                });
    }catch(Exception e){

    }
    }
    private void createGUI(){
    JFrame.setDefaultLookAndFeelDecorated(true);
    formatIcon = loadImage(formatButtonFilename);
    controIcon = loadImage(controlButtonFilename);
    JButton btnFormat = new JButton("版式",formatIcon);
    JButton btnControl = new JButton("控件",controIcon);
    btnFormat.addActionListener(this);
    btnControl.addActionListener(this);
    btnFormat.setActionCommand("shwotoolbox");
    JPanel panel1= new JPanel(new FlowLayout());
    panel1.setLayout(new GridLayout(2,1)); panel1.add(btnFormat);
    panel1.add(btnControl);
    panel1.setPreferredSize(new Dimension(100, 20));
    add(panel1);

    }
        public void actionPerformed(ActionEvent e) {
            if ("shwotoolbox".equals(e.getActionCommand())) {
             toolbox.setVisible(true);
            } 
        }
    public void run(){

    }

    protected ImageIcon loadImage(String imageName) {
            String path = imageName ;
            int MAX_IMAGE_SIZE = 2400;  //Change this to the size of
                                        //your biggest image, in bytes.
            int count = 0;
            BufferedInputStream imgStream = new BufferedInputStream(
               this.getClass().getResourceAsStream(path));
            if (imgStream != null) {
                byte buf[] = new byte[MAX_IMAGE_SIZE];
                try {
                    count = imgStream.read(buf);
                    imgStream.close();
                } catch (java.io.IOException ioe) {
                    System.err.println("Couldn't read stream from file: " + path);
                    return null;
                }
                if (count <= 0) {
                    System.err.println("Empty file: " + path);
                    return null;
                }
                return new ImageIcon(Toolkit.getDefaultToolkit().createImage(buf));
            } else {
                System.err.println("Couldn't find file: " + path);
                return null;
            }
        }
    }
    ToolBox.java如下:/*
     * Created on 2005-3-30
     *
     * TODO To change the template for this generated file go to
     * Window - Preferences - Java - Code Style - Code Templates
     */
    package module;/**
     * @author Administrator
     *
     * TODO To change the template for this generated type comment go to
     * Window - Preferences - Java - Code Style - Code Templates
     */
    import java.awt.*;
    import javax.swing.*;public class ToolBox extends JFrame{
    public ToolBox(){
    String[] columnNames = {"First Name",
                "Last Name",
                "Sport",
                "# of Years",
                "Vegetarian"};
    Object[][] data = {
    {"Mary", "Campione",
    "Snowboarding", new Integer(5), new Boolean(false)},
    {"Alison", "Huml",
    "Rowing", new Integer(3), new Boolean(true)},
    {"Kathy", "Walrath",
    "Knitting", new Integer(2), new Boolean(false)},
    {"Sharon", "Zakhour",
    "Speed reading", new Integer(20), new Boolean(true)},
    {"Philip", "Milne",
    "Pool", new Integer(10), new Boolean(false)}
    };
    JTable table = new JTable(data, columnNames);
    table.setPreferredScrollableViewportSize(new Dimension(400, 70));
    JScrollPane scrollPane = new JScrollPane(table);
    this.getContentPane().add(scrollPane);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.pack();

    //this.setVisible(true);
    }
    }出现的问题还是跟以前一样啊,在eclipse里面调试可以,点击第一个按纽,toolbox就能显示出来了
    在网页里面就是不行啊.郁闷啊,郁闷啊,郁闷啊.................
      

  12.   

    问题解决了,还是不结贴
    没有这一句就可以
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);