Hi.
This is a snapshot of my code:
public class sysinfoHooshi implements ActionListener{ class Info{ public String name; public String version; public String arch; public double ramUtil; public double CPUUtil; }; JTextField tf = new JTextField(""); JTextField tf2 = new JTextField(""); JDialog dialog = new JDialog(); /****************Query dialog variables*******************/ JDialog quesryDialog = new JDialog(); JCheckBox chkCPUUtil = new JCheckBox("CPU utilization"); JCheckBox chkRAMUtil = new JCheckBox("RAM utilization"); JCheckBox chkVersion = new JCheckBox("Version of the OS"); JCheckBox chkArch = new JCheckBox("Processor architecture"); JCheckBox chkName = new JCheckBox("Operating system name"); boolean nameChecked, versionChecked, archChecked, CPUChecked, RAMChecked; /*********************************************************/ public void simulate()throws Exception{ this.showDialog(); int simTime = Integer.parseInt( tf.getText() );; int interval = Integer.parseInt( tf2.getText() ); int queueSize = 60*simTime/interval; System.out.println( queueSize ); Info[] queue = new Info[queueSize]; int pos = 0; for(int i=0;i<queueSize;++i) queue[i] = new Info(); for(int i=0;i<queueSize;++i) { TimeUnit.SECONDS.sleep(interval); OperatingSystemMXBean osBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); queue[pos].name = System.getProperty("os.name"); queue[pos].version = System.getProperty("os.version"); queue[pos].arch = System.getProperty("os.arch"); // queue[pos].ramUtil =100-( osBean.getFreePhysicalMemorySize()/osBean.getTotalPhysicalMemorySize() ) * 100; // queue[pos].CPUUtil = ( osBean.getSystemCpuLoad() ) * 100; ++pos; }//end for showQueryDialog(); chkName.addItemListener = (new ItemListener() { public void itemStateChanged( ItemEvent e) { e.getStateChenge()==1 ? nameChecked=true :nameChecked = false;} }); chkVersion.addItemListener = (new ItemListener() { public void itemStateChanged( ItemEvent e) { e.getStateChenge()==1 ? versionChecked=true :versionChecked = false;} }); chkArch.addItemListener = (new ItemListener() { public void itemStateChanged( ItemEvent e) { e.getStateChenge()==1 ? archChecked=true :archChecked = false;} }); chkCPUUtil.addItemListener = (new ItemListener() { public void itemStateChanged( ItemEvent e) { e.getStateChenge()==1 ? CPUChecked=true :CPUChecked = false;} }); chkRAMUtil.addItemListener = (new ItemListener() { public void itemStateChanged( ItemEvent e) { e.getStateChenge()==1 ? RAMChecked=true :RAMChecked = false;} }); }//end simulate() public void showDialog() { ... public void actionPerformed(ActionEvent e) { ... } public void showQueryDialog() { ... } /* public void showResults(Info queue) { String results = ""; if(nameChecked) results += queue[i].name; if(archChecked) } */ public static void main(String args[]) throws Exception{ ... } // end main }// end class
What are the unexpected type errors?
EDIT: The compiller specifically hints at e.getStateChanged() == 1, but it is used in the example on http://www.tutorialspoint.com/swing/swing_jcheckbox.htm without any problems(I compiled that successfelly)