frame为什么声明为 static 的?
frame为什么声明为 static 的? 好像 只有 int 等值类型 才可以吧
import javax.swing.*;
public class Applicant
{ static JFrame frame; JPanel panel;
JLabel labelAppID;
JLabel labelAppName;
JLabel labelAppAddress;
JLabel labelAppPosition;
//variables for data entry controls
JTextField textAppID;
JTextField textAppName;
JTextField textAppAddress;
JComboBox comboAppPosition;
public Applicant()
{ //Create a panel
panel = new JPanel();
labelAppID = new JLabel("Applicant ID");
labelAppName = new JLabel("Name");
labelAppAddress = new JLabel("Address");
labelAppPosition = new JLabel("Position");
//Initializing JTextField
textAppID = new JTextField(5);
textAppName = new JTextField(30);
textAppAddress = new JTextField(30);
String []C ={"China","india","English","American"};
JList l=new JList (C);
l.setSelectionMode(2);//0only single,1 continuous-shift key,2 any sequence- ctrl key
String position[] = { "Manager","Executive", "Associate"};
comboAppPosition = new JComboBox(position);
frame.getContentPane().add(panel);
panel.add(labelAppID);
panel.add(textAppID);
//Adding controls for Applicant name
panel.add(labelAppName);
panel.add(textAppName);
//Adding controls for Applicant Address
panel.add(labelAppAddress);
panel.add(textAppAddress);
//Adding controls for Applicant Position
panel.add(labelAppPosition);
panel.add(comboAppPosition);
panel.add(l);
}
public static void main(String args[])
{
frame = new JFrame("Applicant Details");
//making the frame visible
Applicant appObject;
appObject = new Applicant();
frame.setVisible(true);
frame.setSize(300,300);
}
}