查看: 1134|回复: 2
|
Java 问题。。各位java高手,能够帮帮忙么?
[复制链接]
|
|
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高手,能够帮帮忙么?
小弟感激不尽。。 |
|
|
|
|
|
|
|
发表于 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
|
显示全部楼层
- public static void main_menu()
复制代码
这个没有必要announce成static吧?
- public Container getContentPane()
复制代码
不是static method当然不能在static method内call。 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|