Page 2 of 2 FirstFirst 12
Results 21 to 26 of 26
  1. #21
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,038
    Rep Power
    8

    Default Re: I get this enormous error message....

    Wow tolls your answer to this post goes way over my head....
    Let me try to grab an understanding of what you are saying.
    But at first you are right there is a design problem!
    (btw did you pull the two classes through the compiler?)

    I start to understand how to do single class applications well.
    The stuff subject to this post forms part of a larger learning project of mine.
    There are several series of classes involved that should work together!
    (as I said before it is a larger application that assigns a 100 practice rooms to
    conservatory students on the bases of calendar schedule of the academic year).

    Of the two classes presented here, the last class builds the calendar panel from the
    month september to september (leap year included) were each day panel can be colored and click-selected (I did it all myself by studying the calendar api). The next class will create three dialogs to set the 1) weekly time schedule 2) mayor academic vacations 3) single free days (by clicking on each day panel).

    Here is already an interesting design question: what class should be the base class?

    I thought to begin with a sequence of the three dialogs and after the fields are filled and the date/ time combos are set I will read them out, al together, and paint the calendar panels of the next following class! But maybe I am wrong and should first start with the calendar class and let each dialog of the next class come logically out of the calendar class, right?

    What is really confusing to me is that you say that I did not initialize the dialog2 object:

    "That listener closes 'dialog1' and then (in the object representing dialog1) creates a dialog2.
    That dialog2 has its own 'dialog2' attribute...that is not initialized."

    Since I say on the first button push:

    dialog1.setVisible(false);
    dialog2 = new CalenderDialog("DIALOG2");
    System.out.println("OK2 " + dialog2);
    dialog2.setBounds(300, 300, 760, 520);
    dialog2.setModal(true);
    dialog2.setVisible(true);
    dialog2.setDefaultCloseOperation(JDialog.HIDE_ON_C LOSE);
    System.out.println("OK3 " + dialog2);

    The second dialog appears even on the screen and functions but when I like to close it, it is if it is not present (kind of creepy, right). The last line of the code (ok3) even most of the time does not print, which is even more weird to me!

    It might have something to do with the fact that there are two objects and I or Java (probably me) do not know where we really at, right?
    (this is the part that obviously goes over my head…..)

    please help me out this java-twilight-zone….
    Last edited by willemjav; 05-24-2013 at 11:05 AM.

  2. #22
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,038
    Rep Power
    8

    Default Re: I get this enormous error message....

    So I have figured out the following:

    -There is the calendar panel class (CalenderPanel) and a second class that creates the several
    dialogs (CalenderDialog);
    -I created a third, base, class (SetCalendarScreen) that will manage the other two classes;

    would this be the way to start (the OK button will make the created dialogs1/2 invisible/ visible):

    Java Code:
     public static void main(String[] args) {
           SetCalendarScreen calframe = new SetCalendarScreen();
        }
    
    
         public SetCalendarScreen() {
           
           calenderpanel = new  CalenderPanel();
           calenderpanel.setBounds(30, 30, 1700, 900);
           calenderpanel.setTitle("Calendar Window");
           calenderpanel.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
           calenderpanel.setVisible(true);
           calenderpanel.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
           dialog1 = new CalenderDialog("DIALOG1");
           dialog1.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
           dialog1.setBounds(300, 300, 520, 350);
           dialog1.setTitle("dialog 1");
           dialog1.setModal(true);
           dialog1.setVisible(true);
    
           dialog2 = new CalenderDialog("DIALOG2");
           dialog2.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
           dialog2.setBounds(300, 300, 520, 350);
           dialog2.setTitle("dialog 2");
           dialog2.setModal(true);
           dialog2.setVisible(true);
           
           BListener = new ButtonListener();
           
           dialog1.getOkButton().addActionListener(BListener);
           dialog1.getOkButton().setActionCommand("OK1");
           dialog2.getOkButton().addActionListener(BListener);
           dialog1.getOkButton().setActionCommand("OK2");
           
           dialog1.getChButton().addActionListener(BListener);
           dialog1.getChButton().setActionCommand("CH1");
           dialog2.getChButton().addActionListener(BListener);
           dialog2.getChButton().setActionCommand("CH2");
    
        }
    Last edited by willemjav; 05-24-2013 at 06:15 PM.

  3. #23
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,038
    Rep Power
    8

    Default Re: I get this enormous error message....

    The two objects of the class that creates the dialogs will take care of the internal stuff
    of the checkbox, field and the combos.
    I only need a reference of the OK button at the base class:
    Java Code:
    public JButton getOkButton() { // the reference of the OK and Chancel button
            return okb;           
        }
    public JButton getChButton() {
            return  chancelb;
        }
    to disappear and appear the first and second dialog
    and finally read out (in sequence) the data of the first
    dialog and the second dialog to paint the 365 day panels
    of the calendar screen (a frame)....

    Would this be a good java programming approach?
    Last edited by willemjav; 05-24-2013 at 04:52 PM.

  4. #24
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,038
    Rep Power
    8

    Default Re: I get this enormous error message....

    the actionlistener would be this, but is not working....

    Java Code:
     private class ButtonListener implements ActionListener {
            public void actionPerformed(ActionEvent e)  {
                String cmd = e.getActionCommand();
    
                if (cmd.equals("CH1")) {
                  System.out.println("CHANCEL1 ");
                 
                }
    
                if (cmd.equals("CH2")) {
                  System.out.println("CHANCEL2 ");
                 
                }
    
                if (cmd.equals("OK1")) {
    
                        System.out.println("OK1 ");
                      
                }
                
                if (cmd.equals("OK2")) {
    
                        System.out.println("OK2 ");
                       
                }          
            }
        }

  5. #25
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,038
    Rep Power
    8

    Default Re: I get this enormous error message....

    The constructor of the dialog class (dialog1/ dialog2) sets
    Container contentPane = getContentPane();
    contentPane.add(createDialogPanel());

    and the createDialogPanel() returns a filled JPanel...

    there must be something wrong?

  6. #26
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,038
    Rep Power
    8

    Default Re: I get this enormous error message....

    in order to paint the 365 panels of a calendar screen I need to set two dialogs in sequence.
    The two dialogs are very similar so they are objects of the same class of which the keywords
    dialog1 and dialog2 makes the difference.
    So I need to do the following:
    1) dialog1 = new CalenderDialog("DIALOG1"); -> set some checkboxes and combos and push ok
    2) dialog2 = new CalenderDialog("DIALOG2"); -> set some checkboxes, combos and textfields and push ok
    3) read out both objects and paint the calendar panel
    I have the different parts (the dialog class and the calendar class)
    But can not put this idea together!

Page 2 of 2 FirstFirst 12

Similar Threads

  1. help me with this error message
    By joel7 in forum New To Java
    Replies: 1
    Last Post: 11-27-2012, 08:10 AM
  2. Need help with error message!
    By cstampar in forum New To Java
    Replies: 2
    Last Post: 12-04-2011, 07:52 PM
  3. Error Message
    By Bimz in forum New To Java
    Replies: 2
    Last Post: 09-11-2011, 01:01 PM
  4. Error Message????
    By Cubba27 in forum New To Java
    Replies: 11
    Last Post: 11-21-2009, 02:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •