佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1134|回复: 2

Java 问题。。各位java高手,能够帮帮忙么?

[复制链接]
发表于 14-4-2007 12:32 AM | 显示全部楼层 |阅读模式
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
import javax.swing.border.*;
import java.awt.event.*;
import java.io.*;


public class WebUseEvaluationSystem extends JFrame implements ActionListener
{
    //static JFrame bingkai = new JFrame("Website Usability Evaluation System");
            JTabbedPane jtpTAB= new JTabbedPane();
            //declare label
            JLabel jlbname = new JLabel("Name");
            JLabel jlbcompany = new JLabel("Company");
            JLabel jlbemail = new JLabel("email add");
            JLabel jlbCDKEY = new JLabel("CD-KEY");

            //declare textfield
            JTextField jtfname = new JTextField(12);
            JTextField jtfcompany = new JTextField(12);
            JTextField jtfemail = new JTextField(12);
            JTextField jtfCDKEY = new JTextField(12);

            //declare button
            JButton jbtok = new JButton ("OK");
            JButton jbtcancel = new JButton("Cancel");

            //declaration for tabbed pane
            JTabbedPane jtpControl = new JTabbedPane();

            //declaration for JFileChooser
            JFileChooser jfcDialog = new JFileChooser();

            Container c = getContentPane();




        WebUseEvaluationSystem()
        {
            EtchedBorder edge = new EtchedBorder(EtchedBorder.RAISED);//button border
            Container contain= getContentPane();
            JPanel PANEL1 = new JPanel();
            PANEL1.setLayout(new GridLayout(4,5,6,6));
            PANEL1.add(jlbname);
            PANEL1.add(jtfname);
            PANEL1.add(jlbcompany);
            PANEL1.add(jtfcompany);
            PANEL1.add(jlbemail);
            PANEL1.add(jtfemail);
            PANEL1.add(jlbCDKEY);
             PANEL1.add(jtfCDKEY);

            contain.setLayout(new BorderLayout());
            contain.add(PANEL1,BorderLayout.CENTER);
            JPanel PANEL2 = new JPanel();
            PANEL2.add(jbtok);
            PANEL2.add(jbtcancel);
            contain.add(PANEL2,BorderLayout.SOUTH);
            PANEL2.setBorder(edge);//add button border

            //c.add(jtpControl,BorderLayout.CENTER);
            jfcDialog.setCurrentDirectory(new File("."));


            jtfemail.addActionListener(this);
             jtfname.addActionListener(this);
            jtfcompany.addActionListener(this);
            jtfCDKEY.addActionListener(this);

         }
         public void actionPerformed(ActionEvent e)
         {
            if (e.getSource() == jbtok)

                WebUseEvaluationSystem.main_menu();
            else
                System.exit(0);


         }

         public static void main_menu()
         {
             EtchedBorder edge = new EtchedBorder(EtchedBorder.RAISED);
             JButton jbtwebuse_evaluation = new JButton ("Web Usability Evaluation");
             JButton jbtcheck_list = new JButton ("Checklist");
             JButton jbtresult = new JButton ("Result");
             JPanel menu = new JPanel();
             menu.setLayout(new GridLayout(4,5,6,6));
             menu.add(jbtwebuse_evaluation);
             menu.add(jbtcheck_list);
             menu.add(jbtresult);
             getContentPane().add(menu,BorderLayout.CENTER);
             menu.setBorder(edge);

         }


    public static void main(String[] args)
    {
         String username;
         int CDkey;
         String organazation;

        WebUseEvaluationSystem bingkai = new WebUseEvaluationSystem();

        bingkai.setTitle("Website Usability Evaluation System");
        bingkai.setSize(650,450);
        bingkai.setVisible(true);
        bingkai.setDefaultCloseOperation(bingkai.EXIT_ON_CLOSE);

         //method to set the frame to popup at the center screen
        Dimension saizSkrin = Toolkit.getDefaultToolkit().getScreenSize();

        int lebarSkrin = saizSkrin.width;
        int panjangSkrin = saizSkrin.height;

        Dimension saizBingkai = bingkai.getSize();
        int x = (lebarSkrin - saizBingkai.width)/2;
        int y = (panjangSkrin - saizBingkai.height)/2;

        bingkai.setLocation(x,y);
        bingkai.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));


        checklist check = new checklist();
        check.visual_criteria();
        check.functionality_criteria();
        check.control_criteria();
        check.navigation_criteria();

        result res = new result();
        res.check_result();

        webuse_evaluation web = new webuse_evaluation();
        web.web_measurement();
        web.web_analyzation();




    }
}
    class checklist
    {
        checklist()
        {
        }
            public void visual_criteria()
            {

            }

            public void navigation_criteria()
            {
            }

            public void functionality_criteria()
            {
            }

            public void control_criteria()
            {
            }
    }

    class result
    {
        result()
        {
        }
            public void check_result()
            {
            }
    }

    class webuse_evaluation
    {
        webuse_evaluation()
        {
        }
            public void web_measurement()
            {
            }

            public void web_analyzation()
            {
            }

    }
当我要click "ok"钮时,怎么link不到另一个interface?compile的时候显示non-static method getContentPane() cannot be referenced from a static context。各位java高手,能够帮帮忙么?
小弟感激不尽。。
回复

使用道具 举报


ADVERTISEMENT

发表于 14-4-2007 02:12 AM | 显示全部楼层
觉得你不该在static function里呼唤non static function咯。。
你该instantiate一个obj,在呼唤那个obj的method..

WebUseEvaluationSystem abc= new WebUseEvaluationSystem();
abc.getContentPane();



我没学过java不知对不。。呵呵。。
回复

使用道具 举报

发表于 14-4-2007 11:27 PM | 显示全部楼层
  1. public static void main_menu()
复制代码

这个没有必要announce成static吧?

  1. public Container getContentPane()
复制代码


不是static method当然不能在static method内call。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 9-9-2025 12:42 AM , Processed in 0.123676 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表