473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

jcheckbox problems (revised)

hello, i am making a hall pass program for my computer programming class. i am having issues with my jcheckboxes. first off. this file reads from a .txt that just has
greg
john
joe
54343
45777
33444

in it. after the user puts in a correct id number, it displays 4 checkboxes to where they want to go. bathroom, office, nurse, and other. once the user clicks one of the checkboxes, it will remove all the stuff from the panel, and add the name of the person and the time they left. the problem i am having is when the user clicks the checkbox , nothing happens. run this for yourself and see for yourself what happens (if you want of course) this is my final assignment for computer programming and i need help bad lol. i have added an itemlistener, that when the checkbox is selected a boolean = true, then in the actionevents, when the "submit" button is pressed, and the id is correct, and the checkbox boolean is true, it removes all the stuff and puts in all the new elements. i want to say that only the bathroom checkbox has the stuff that it should have to make it work , like added the name and time to the second screen after the 4 checkboxes. also i would like to add that this program compiles just fine, just nothing happens when i click the checkboxes. THANKS IN ADVANCED






Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. import java.util.Calendar;
  5. import java.text.SimpleDateFormat;
  6. import java.lang.Object;
  7. import java.io.*;
  8. import javax.swing.event.*;
  9. import javax.swing.JCheckBox;
  10.  
  11. public class main implements ActionListener
  12. {
  13.         JFrame f1,f2;
  14.         JPanel p1,p2,p3,p4;
  15.         String id,enterstring,name,namestring,idstring,str;
  16.         GP g1;
  17.         JRadioButton bathroom,office,nurse,other;
  18.         JButton submit,returnbutton;
  19.         JTextField idnumber;
  20.         JLabel idprompt,what,time,namelabel;
  21.         boolean show,bathroomb,officeb,nurseb,otherb;
  22.         int idnum,counter;
  23.         SimpleDateFormat sdf;
  24.        String[] namearray; 
  25.        int[] idarray;
  26.        int a,b,idint,enter,teacher;
  27.      public main()
  28.     {   
  29.         teacher = 1234567890;
  30.          bathroomb = false;
  31.          officeb = false;
  32.          nurseb = false;
  33.          otherb = false;
  34.         namearray = new String[3];
  35.         idarray = new int[3];
  36.      sdf = new SimpleDateFormat("yyyy.MM.dd G 'at' hh:mm:ss z");  
  37.        show=true;
  38.         a=0;
  39.         b=0;
  40.         namelabel = new JLabel("");
  41.        bathroom = new JRadioButton("Bathroom");
  42.         bathroom.setMnemonic(KeyEvent.VK_C);
  43.         bathroom.setSelected(false);
  44.         bathroom.addActionListener(this);
  45.         counter = 1;
  46.        office = new JRadioButton("Office");
  47.        office.setMnemonic(KeyEvent.VK_C);
  48.         office.setSelected(false);
  49.          office.addActionListener(this);
  50.        nurse = new JRadioButton("Nurse");
  51.         nurse.setMnemonic(KeyEvent.VK_C);
  52.         nurse.setSelected(false);
  53.          nurse.addActionListener(this);
  54.        other = new JRadioButton("Other");
  55.         other.setMnemonic(KeyEvent.VK_C);
  56.         other.setSelected(false);
  57.          other.addActionListener(this);
  58.         idprompt = new JLabel("Enter ID Number");
  59.         idnumber = new JTextField(14);
  60.         f1 = new JFrame("Hall Pass");
  61.           f1.setSize(550,200);        
  62.         Container c1 = f1.getContentPane();
  63.         time = new JLabel("left at "+sdf.format(new java.util.Date(System.currentTimeMillis())));
  64.         id = "123";
  65.         p1 = new JPanel();
  66.         p1.setSize(500,150);
  67.         p1.setLayout(new BorderLayout());
  68.  
  69.           what = new JLabel("");
  70.  
  71.        bathroom.addItemListener(new Item());
  72.        other.addItemListener(new Item());
  73.         nurse.addItemListener(new Item());
  74.         office.addItemListener(new Item());
  75.         returnbutton = new JButton("Return");
  76.         returnbutton.addActionListener(this);
  77.         submit = new JButton("Submit");
  78.         submit.addActionListener(this);
  79.  
  80.         p2 = new JPanel();  //panel to add JLabel and TextField
  81.  
  82.         g1 = new GP();    
  83.          p1.add(g1,BorderLayout.CENTER);
  84.  
  85.                   //g1.setBackground(new RGB(255, 255, 255));
  86.        g1.add(idprompt);
  87.        g1.add(idnumber);
  88.         p2.add(submit);
  89.         g1.add(what);
  90.  
  91.         p1.add(p2,BorderLayout.SOUTH);      //adds p2 to south (Bottom) Graphics Panel will be added to Center    
  92.         c1.add(p1);
  93.  
  94.  
  95.         f1.show();
  96.  
  97.  
  98.     }
  99.  
  100.     public static void main(String[] args)    
  101.    {
  102.       main m = new main();
  103.    }
  104.  
  105.  
  106.  
  107.  
  108.     public class Item implements ItemListener{
  109.  
  110.        public void itemStateChanged(ItemEvent evt) {
  111.  
  112.             if (evt.getStateChange() == ItemEvent.SELECTED) {
  113.  
  114.  
  115.              if (bathroom.isSelected()){
  116.  
  117.                  bathroomb = true;
  118.                  System.out.println(bathroomb);
  119.                 }
  120.              if (office.isSelected()){
  121.  
  122.                  officeb = true;
  123.                 }    
  124.              if (nurse.isSelected()){
  125.  
  126.  
  127.                  nurseb = true;
  128.                 }  
  129.              if (other.isSelected()){   
  130.                  otherb = true;
  131.  
  132.                 }
  133.         }
  134.  
  135.  
  136.  
  137.  
  138.  
  139.         }
  140.     }
  141.  
  142.       public void actionPerformed (ActionEvent event)
  143.       {
  144.   try {
  145.         BufferedReader in = new BufferedReader(new FileReader("names.txt"));
  146.  
  147.         if (event.getSource() == returnbutton)
  148.         {
  149.             f1.show();
  150.  
  151.  
  152.         }
  153.  
  154.        //idnum = Integer.Parseint(enter);
  155.  
  156.  
  157.         if (event.getSource() == submit)
  158.         {
  159.  
  160.        for(int i=0; i<6; i++){
  161.     str = in.readLine().trim() ;
  162.        if(i<3){
  163.           namearray[a] = str;
  164.           a++;
  165.         }else{
  166.             idarray[b] = Integer.parseInt(str);
  167.             b++;
  168.          }
  169. }
  170.  
  171.  
  172.  
  173.         in.close();
  174.  
  175.  
  176.  
  177.            enterstring = idnumber.getText();
  178.            enter = Integer.parseInt(enterstring);
  179.            for(int b = 0;  b< 3; b++)
  180.            {
  181.                //number 1
  182.            if (enter==idarray[0])
  183.            {
  184.                  g1.remove(idnumber);
  185.                  p1.remove(submit);
  186.                  g1.remove(what);
  187.                  g1.remove(idprompt);
  188.                   p2.remove(submit);
  189.                   namelabel.setText(namearray[0]);
  190.                   g1.add(namelabel);
  191.                  g1.add(bathroom);
  192.                  g1.add(office);
  193.                  g1.add(nurse);
  194.                  g1.add(other);
  195.                                       f1.dispose();
  196.                       f1.show(); 
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.                //  nurse.addItemListener(new ItemListener() {
  205.  
  206.                     if (bathroomb == true){
  207.                         g1.remove(namelabel);     
  208.                  g1.remove(namelabel);
  209.                  g1.remove(bathroom);
  210.                  g1.remove(office);
  211.                  g1.remove(nurse);
  212.                  g1.remove(other);
  213.                       g1.setBackground(Color.red);
  214.                       p2.add(returnbutton);
  215.                       namelabel.setText(namearray[0]+" is currently using the pass the time left was ");
  216.                        g1.add(namelabel);
  217.                        g1.add(time);
  218.                      f1.dispose();
  219.                       f1.show();
  220.                     }
  221.                     else             
  222.  
  223.  
  224.  
  225.  
  226.  
  227.                   if (officeb == true){
  228.                        g1.remove(namelabel);     
  229.                  g1.remove(namelabel);
  230.                  g1.remove(bathroom);
  231.                  g1.remove(office);
  232.                  g1.remove(nurse);
  233.                  g1.remove(other);
  234.                       g1.setBackground(Color.red);
  235.  
  236.                       p2.add(returnbutton);
  237.                       namelabel.setText(namearray[0]+" is currently using the pass the time left was ");
  238.                        g1.add(namelabel);
  239.                        g1.add(time);
  240.                       f1.dispose();
  241.                       f1.show();
  242.  
  243.                     }
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.                   if (nurseb == true){
  254.  
  255.                        g1.setBackground(Color.red);
  256.  
  257.                       p2.add(returnbutton);
  258.                       namelabel.setText(namearray[0]+" is currently using the pass the time left was ");
  259.                        g1.add(namelabel);
  260.                        g1.add(time);
  261.  
  262.  
  263.  
  264.                     }
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.                   if (otherb == true){
  272.  
  273.                        g1.setBackground(Color.red);
  274.  
  275.                       p2.add(returnbutton);
  276.                       namelabel.setText(namearray[0]+" is currently using the pass the time left was ");
  277.                        g1.add(namelabel);
  278.                        g1.add(time);
  279.  
  280.  
  281.                     }
  282.  
  283.  
  284.                 }
  285.                  else{
  286.              what.setText("Incorrect Login");
  287.             }
  288.  
  289.  
  290.  
  291.  
  292.               //g1.setBackground(Color.red);
  293.  
  294.              // p2.add(returnbutton);
  295.  
  296.              // g1.add(time);
  297.               f1.dispose();
  298.               f1.show();
  299.             }
  300.  
  301.  
  302.         //number 2
  303.         if (enter==teacher)
  304.         {
  305.             f1.dispose();
  306.         }
  307.           if (enter == idarray[1])
  308.            {
  309.                  g1.remove(idnumber);
  310.                  p1.remove(submit);
  311.                  g1.remove(what);
  312.                  g1.remove(idprompt);
  313.               g1.setBackground(Color.red);
  314.               p2.remove(submit);
  315.               p2.add(returnbutton);
  316.                namelabel.setText(namearray[1]);
  317.              g1.add(namelabel);
  318.               g1.add(time);
  319.               f1.dispose();
  320.               f1.show();
  321.             }
  322.  
  323.             else{
  324.              what.setText("Incorrect Login");
  325.             }
  326.         }
  327.           if (enter == idarray[2])
  328.            {
  329.                  g1.remove(idnumber);
  330.                  p1.remove(submit);
  331.                  g1.remove(what);
  332.                  g1.remove(idprompt);
  333.               g1.setBackground(Color.red);
  334.               p2.remove(submit);
  335.               p2.add(returnbutton);
  336.                namelabel.setText(namearray[2]);
  337.              g1.add(namelabel);
  338.               g1.add(time);
  339.               f1.dispose();
  340.               f1.show();
  341.             }
  342.  
  343.             else{
  344.              what.setText("Incorrect Login");
  345.             }
  346.  
  347.  
  348.             idnumber.setText(null);
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.           g1.repaint();
  357.  } catch (IOException e) {
  358.     }
  359.         }
  360.     }
  361.  
  362.  
  363.  
  364.  
  365.  class GP extends JPanel  //graphics panel
  366.  
  367. {
  368.  
  369.  
  370.     public GP()
  371.      {      
  372.  
  373.  
  374.  
  375.  
  376.         setBackground(Color.green);
  377.  
  378.      }
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.     public void paint(Graphics g)
  386.     {
  387.      super.paint(g);
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.     }
  395.  
  396. }
Nov 1 '07 #1
8 1660
r035198x
13,262 8TB
Well, I don't see any JCheckBoxes in the code except in the import statements.
But then again it's 0004 here so I could be due for some sleep ...
Nov 1 '07 #2
Your right there isnt any, i just changed it and it still does the same thing with the checkboxes
Nov 2 '07 #3
i really need your help
Nov 2 '07 #4
hello, i am making a hall pass program for my computer programming class. i am having issues with my jcheckboxes. first off. this file reads from a .txt that just has
greg
john
joe
54343
45777
33444

in it. after the user puts in a correct id number, it displays 4 checkboxes to where they want to go. bathroom, office, nurse, and other. once the user clicks one of the checkboxes, it will remove all the stuff from the panel, and add the name of the person and the time they left. the problem i am having is when the user clicks the checkbox , nothing happens. run this for yourself and see for yourself what happens (if you want of course) this is my final assignment for computer programming and i need help bad lol. i have added an itemlistener, that when the checkbox is selected a boolean = true, then in the actionevents, when the "submit" button is pressed, and the id is correct, and the checkbox boolean is true, it removes all the stuff and puts in all the new elements. i want to say that only the bathroom checkbox has the stuff that it should have to make it work , like added the name and time to the second screen after the 4 checkboxes. also i would like to add that this program compiles just fine, just nothing happens when i click the checkboxes. THANKS IN ADVANCED

Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. import java.util.Calendar;
  5. import java.text.SimpleDateFormat;
  6. import java.lang.Object;
  7. import java.io.*;
  8. import javax.swing.event.*;
  9. import javax.swing.JCheckBox;
  10.  
  11. public class main implements ActionListener
  12. {
  13.         JFrame f1,f2;
  14.         JPanel p1,p2,p3,p4;
  15.         String id,enterstring,name,namestring,idstring,str;
  16.         GP g1;
  17.         JCheckBox bathroom,office,nurse,other;
  18.         JButton submit,returnbutton;
  19.         JTextField idnumber;
  20.         JLabel idprompt,what,time,namelabel;
  21.         boolean show,bathroomb,officeb,nurseb,otherb;
  22.         int idnum,counter;
  23.         SimpleDateFormat sdf;
  24.         String select;
  25.        String[] namearray; 
  26.        int[] idarray;
  27.        int a,b,idint,enter,teacher;
  28.      public main()
  29.     {   
  30.         teacher = 1234567890;
  31.          bathroomb = false;
  32.          officeb = false;
  33.          nurseb = false;
  34.          otherb = false;
  35.         namearray = new String[3];
  36.         idarray = new int[3];
  37.      sdf = new SimpleDateFormat("yyyy.MM.dd G 'at' hh:mm:ss z");  
  38.        show=true;
  39.         a=0;
  40.         b=0;
  41.         select = "unselected";
  42.         namelabel = new JLabel("");
  43.        bathroom = new JCheckBox("Bathroom");
  44.         bathroom.setMnemonic(KeyEvent.VK_C);
  45.         bathroom.setSelected(false);
  46.         bathroom.addActionListener(this);
  47.         counter = 1;
  48.        office = new JCheckBox("Office");
  49.        office.setMnemonic(KeyEvent.VK_C);
  50.         office.setSelected(false);
  51.          office.addActionListener(this);
  52.        nurse = new JCheckBox("Nurse");
  53.         nurse.setMnemonic(KeyEvent.VK_C);
  54.         nurse.setSelected(false);
  55.          nurse.addActionListener(this);
  56.        other = new JCheckBox("Other");
  57.         other.setMnemonic(KeyEvent.VK_C);
  58.         other.setSelected(false);
  59.          other.addActionListener(this);
  60.         idprompt = new JLabel("Enter ID Number");
  61.         idnumber = new JTextField(14);
  62.         f1 = new JFrame("Hall Pass");
  63.           f1.setSize(550,200);        
  64.         Container c1 = f1.getContentPane();
  65.         time = new JLabel("left at "+sdf.format(new java.util.Date(System.currentTimeMillis())));
  66.         id = "123";
  67.         p1 = new JPanel();
  68.         p1.setSize(500,150);
  69.         p1.setLayout(new BorderLayout());
  70.  
  71.           what = new JLabel("");
  72.  
  73.        bathroom.addItemListener(new Item());
  74.        other.addItemListener(new Item());
  75.         nurse.addItemListener(new Item());
  76.         office.addItemListener(new Item());
  77.         returnbutton = new JButton("Return");
  78.         returnbutton.addActionListener(this);
  79.         submit = new JButton("Submit");
  80.         submit.addActionListener(this);
  81.  
  82.         p2 = new JPanel();  //panel to add JLabel and TextField
  83.  
  84.         g1 = new GP();    
  85.          p1.add(g1,BorderLayout.CENTER);
  86.  
  87.                   //g1.setBackground(new RGB(255, 255, 255));
  88.        g1.add(idprompt);
  89.        g1.add(idnumber);
  90.         p2.add(submit);
  91.         g1.add(what);
  92.  
  93.         p1.add(p2,BorderLayout.SOUTH);      //adds p2 to south (Bottom) Graphics Panel will be added to Center    
  94.         c1.add(p1);
  95.  
  96.  
  97.         f1.show();
  98.  
  99.  
  100.     }
  101.  
  102.     public static void main(String[] args)    
  103.    {
  104.       main m = new main();
  105.    }
  106.  
  107.  
  108.  
  109.  
  110.     public class Item implements ItemListener{
  111.  
  112.        public void itemStateChanged(ItemEvent evt) {
  113.  
  114.             if (evt.getStateChange() == ItemEvent.SELECTED) {
  115.  
  116.  
  117.              if (bathroom.isSelected()){
  118.                  select.equals("selected");
  119.                  bathroomb = true;
  120.                  System.out.println(bathroomb);
  121.                 }
  122.              if (office.isSelected()){
  123.  
  124.                  officeb = true;
  125.                 }    
  126.              if (nurse.isSelected()){
  127.  
  128.  
  129.                  nurseb = true;
  130.                 }  
  131.              if (other.isSelected()){   
  132.                  otherb = true;
  133.  
  134.                 }
  135.         }
  136.  
  137.  
  138.  
  139.  
  140.  
  141.         }
  142.     }
  143.  
  144.       public void actionPerformed (ActionEvent event)
  145.       {
  146.   try {
  147.         BufferedReader in = new BufferedReader(new FileReader("names.txt"));
  148.  
  149.         if (event.getSource() == returnbutton)
  150.         {
  151.             f1.show();
  152.  
  153.  
  154.         }
  155.  
  156.        //idnum = Integer.Parseint(enter);
  157.  
  158.  
  159.         if (event.getSource() == submit)
  160.         {
  161.  
  162.        for(int i=0; i<6; i++){
  163.     str = in.readLine().trim() ;
  164.        if(i<3){
  165.           namearray[a] = str;
  166.           a++;
  167.         }else{
  168.             idarray[b] = Integer.parseInt(str);
  169.             b++;
  170.          }
  171. }
  172.  
  173.  
  174.  
  175.         in.close();
  176.  
  177.  
  178.  
  179.            enterstring = idnumber.getText();
  180.            enter = Integer.parseInt(enterstring);
  181.            for(int b = 0;  b< 3; b++)
  182.            {
  183.                //number 1
  184.            if (enter==idarray[0])
  185.            {
  186.                  g1.remove(idnumber);
  187.                  p1.remove(submit);
  188.                  g1.remove(what);
  189.                  g1.remove(idprompt);
  190.                   p2.remove(submit);
  191.                   namelabel.setText(namearray[0]);
  192.                   g1.add(namelabel);
  193.                  g1.add(bathroom);
  194.                  g1.add(office);
  195.                  g1.add(nurse);
  196.                  g1.add(other);
  197.                                       f1.dispose();
  198.                       f1.show(); 
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.                //  nurse.addItemListener(new ItemListener() {
  207.  
  208.                     if (select.equals("selected")){
  209.                         System.out.println("TESTWTF");
  210.                         g1.remove(namelabel);     
  211.                  g1.remove(namelabel);
  212.                  g1.remove(bathroom);
  213.                  g1.remove(office);
  214.                  g1.remove(nurse);
  215.                  g1.remove(other);
  216.                       g1.setBackground(Color.red);
  217.                       p2.add(returnbutton);
  218.                       g1.add(namelabel);
  219.                       namelabel.setText(namearray[0]+" is currently using the pass the time left was ");
  220.  
  221.                        g1.add(time);
  222.                      f1.dispose();
  223.                       f1.show();
  224.                       bathroomb=false;
  225.                     }
  226.                     else             
  227.  
  228.  
  229.  
  230.  
  231.  
  232.                   if (officeb == true){
  233.                        g1.remove(namelabel);     
  234.                  g1.remove(namelabel);
  235.                  g1.remove(bathroom);
  236.                  g1.remove(office);
  237.                  g1.remove(nurse);
  238.                  g1.remove(other);
  239.                       g1.setBackground(Color.red);
  240.  
  241.                       p2.add(returnbutton);
  242.                       namelabel.setText(namearray[0]+" is currently using the pass the time left was ");
  243.                        g1.add(namelabel);
  244.                        g1.add(time);
  245.                       f1.dispose();
  246.                       f1.show();
  247.  
  248.                     }
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.                   if (nurseb == true){
  259.  
  260.                        g1.setBackground(Color.red);
  261.  
  262.                       p2.add(returnbutton);
  263.                       namelabel.setText(namearray[0]+" is currently using the pass the time left was ");
  264.                        g1.add(namelabel);
  265.                        g1.add(time);
  266.  
  267.  
  268.  
  269.                     }
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.                   if (otherb == true){
  277.  
  278.                        g1.setBackground(Color.red);
  279.  
  280.                       p2.add(returnbutton);
  281.                       namelabel.setText(namearray[0]+" is currently using the pass the time left was ");
  282.                        g1.add(namelabel);
  283.                        g1.add(time);
  284.  
  285.  
  286.                     }
  287.  
  288.  
  289.                 }
  290.                  else{
  291.              what.setText("Incorrect Login");
  292.             }
  293.  
  294.  
  295.  
  296.  
  297.               //g1.setBackground(Color.red);
  298.  
  299.              // p2.add(returnbutton);
  300.  
  301.              // g1.add(time);
  302.               f1.dispose();
  303.               f1.show();
  304.             }
  305.  
  306.  
  307.         //number 2
  308.         if (enter==teacher)
  309.         {
  310.             f1.dispose();
  311.         }
  312.           if (enter == idarray[1])
  313.            {
  314.                  g1.remove(idnumber);
  315.                  p1.remove(submit);
  316.                  g1.remove(what);
  317.                  g1.remove(idprompt);
  318.               g1.setBackground(Color.red);
  319.               p2.remove(submit);
  320.               p2.add(returnbutton);
  321.                namelabel.setText(namearray[1]);
  322.              g1.add(namelabel);
  323.               g1.add(time);
  324.               f1.dispose();
  325.               f1.show();
  326.             }
  327.  
  328.             else{
  329.              what.setText("Incorrect Login");
  330.             }
  331.         }
  332.           if (enter == idarray[2])
  333.            {
  334.                  g1.remove(idnumber);
  335.                  p1.remove(submit);
  336.                  g1.remove(what);
  337.                  g1.remove(idprompt);
  338.               g1.setBackground(Color.red);
  339.               p2.remove(submit);
  340.               p2.add(returnbutton);
  341.                namelabel.setText(namearray[2]);
  342.              g1.add(namelabel);
  343.               g1.add(time);
  344.               f1.dispose();
  345.               f1.show();
  346.             }
  347.  
  348.             else{
  349.              what.setText("Incorrect Login");
  350.             }
  351.  
  352.  
  353.             idnumber.setText(null);
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.           g1.repaint();
  362.  } catch (IOException e) {
  363.     }
  364.         }
  365.     }
  366.  
  367.  
  368.  
  369.  
  370.  class GP extends JPanel  //graphics panel
  371.  
  372. {
  373.  
  374.  
  375.     public GP()
  376.      {      
  377.  
  378.  
  379.  
  380.  
  381.         setBackground(Color.green);
  382.  
  383.      }
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.     public void paint(Graphics g)
  391.     {
  392.      super.paint(g);
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.     }
  400.  
  401. }
Nov 2 '07 #5
r035198x
13,262 8TB
Ok. Let's start by clearing the basics first. Start by changing this code

Expand|Select|Wrap|Line Numbers
  1. catch (IOException e) {
  2. //If an exception is thrown nothing is done
  3.         }
to

Expand|Select|Wrap|Line Numbers
  1. catch (IOException e) {
  2.       e.printStackTrace();
  3. //now if an exception is thrown the trace is displayed to the screen
  4.         }
Do this everywhere in the code where you put in the catch blocks and run it. This is just to make sure no exceptions are being thrown.
In general you should not gobble up exceptions by using empty catch blocks.
Nov 2 '07 #6
ok i did that , no nothing was printed
Nov 2 '07 #7
r035198x
13,262 8TB
ok i did that , no nothing was printed
Well I just copied and pasted your code into my editor.
There's simply no exception handling in the whole thing.
You are reading from a text file and assuming that
1.) The file is always going to be available
2.) The file will always contain more than 6 lines
3.) The file will always have numbers from line 4 - 6
Such things needs to be checked for by the code not just assumed.
After that you do lots of adding and removing from a frame before calling it's dispose method on it! That most certainly isn't the clever way of going about things.

P.S I never got to see the JCheckboxes on the frame at all.
Nov 3 '07 #8
JosAH
11,448 Expert 8TB
If there's a choice of one out of many, shouldn't the choice be represented by
JRadioButtons in a ButtonGroup instead?

kind regards,

Jos
Nov 3 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: ^ | last post by:
Hi group, I've become interested in Python a while ago and just converted a simple perl script to python. The script is very simple, it generates a list of found virusses from some maillog files...
17
by: Shailesh Humbad | last post by:
I just posted an article I wrote called ASP Speed Tricks. It covers techniques to optimize output of database data in HTML, for both simple tables and complex tables. More advanced ASP authors...
4
by: Bryan R. Meyer | last post by:
Hello Everyone, I've been working with CSS trying to understand it and incorporate it into a revised version of my web page. I've noticed a few problems which perhaps someone could shed some...
0
by: Luis Angel Rodríguez Castro | last post by:
Hi, I'm trying to use a Entity replacement with a DTD file, and I'm getting this error while processing with the "XmlValidatingReader" component: "The parameter entity replacement text must...
26
by: CBFalconer | last post by:
I have modified my ggets utility, to simplify the code and reduce the requirements on the standard library. The external action is totally unchanged, so there is no real need for anyone to...
1
by: monica73174 | last post by:
I have migrated a vb.net program to vb 2005. I am going nuts trying to fix this. There is a splash screen that fades in and then in the background some sub procedures are taking place. Here...
10
by: lancer6238 | last post by:
Hi all, I'm having programs reading from files. I have a text file "files.txt" that contains the names of the files to be opened, i.e. the contents of files.txt are Homo_sapiens.fa...
8
Nepomuk
by: Nepomuk | last post by:
Hi everyone! I'm experiencing a very annoying problem - I have a few JCheckBoxes, which the user should not be able to select or deselect (it's done automatically). However, I don't seem to be able...
1
by: carlos123 | last post by:
if (bathroom.isSelected()){ bathroom is a jcheckbox, why doesnt that work.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.