Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 20 of 20

Thread: Why is my JFrame not showing components such as JComboBoxes

  1. #1
    Member
    Join Date
    Sep 2014
    Posts
    31
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Why is my JFrame not showing components such as JComboBoxes

    HI, I would really appreciate it if someone could look through my code and find out (what i can't) why and where my code is going wrong, Problem is my JFrame is not showing anything, point me in the right direction please thanks (Perhaps test it in your own IDE on your own PCs/laptop)

    // Project: RestaurantBillCalculator.java Calculates a table's bill.
     
    // Import statements for different classes
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JComponent;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import java.util.ArrayList;
    import java.awt.Container;
    import javax.swing.BorderFactory;
    import java.awt.Font;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.ResultSetMetaData;
    import java.sql.ResultSet;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JOptionPane;
     
     
     
     
    public class RestaurantBillCalculator extends JFrame
    {
       static final String DATABASE_URL = "jdbc:mysql://localhost/restaurant";
       static final String DATABASE_USERNAME = "root";
       static final String DATABASE_PASSWORD = "password"; 
     
       // JLabel for Restaurant
       private JLabel restaurantJLabel;
     
       // JPanel to display waiter information
       private JPanel waiterJPanel;
     
       // JLabel and JTextField for table number
       private JLabel tableNumberJLabel;
       private JTextField tableNumberJTextField;
     
       // JLabel and JTextField for waiter name
       private JLabel waiterNameJLabel;
       private JTextField waiterNameJTextField;
     
       // JPanel to display menu items
       private JPanel menuItemsJPanel;
     
       // JLabel and JComboBox for beverage
       private JLabel beverageJLabel;
       private JComboBox beverageJComboBox;
     
       // JLabel and JComboBox for appetizer
       private JLabel appetizerJLabel;
       private JComboBox appetizerJComboBox;
     
       // JLabel and JComboBox for main course
       private JLabel mainCourseJLabel;
       private JComboBox mainCourseJComboBox;
     
       // JLabel and JComboBox for dessert
       private JLabel dessertJLabel;
       private JComboBox dessertJComboBox;
     
       // JButton for calculate bill
       private JButton calculateBillJButton;
     
       // JLabel and JTextField for subtotal
       private JLabel subtotalJLabel;
       private JTextField subtotalJTextField;
     
       // JLabel and JTextField for tax
       private JLabel taxJLabel;
       private JTextField taxJTextField;
     
       // JLabel and JTextField for total
       private JLabel totalJLabel;
       private JTextField totalJTextField;
     
       // constant for tax rate
       private final static double TAX_RATE = 0.05;
     
       // declare instance variables for database processing
       private Connection myConnection;
       private Statement myStatement;
       private ResultSet myResultSet;
     
       // declare instance variable ArrayList to hold bill items
        private ArrayList billItems = new ArrayList();
     
        // Constructor
       public RestaurantBillCalculator( String databaseUserName, String databasePassword )
       {
         try 
         {
             myConnection = DriverManager.getConnection
            (DATABASE_URL, DATABASE_USERNAME, DATABASE_PASSWORD);
     
             myStatement = myConnection.createStatement();
     
             myResultSet = myStatement.executeQuery(DATABASE_URL);
         }
         catch ( SQLException sqlException )
          {
             sqlException.printStackTrace();
             System.exit( 1 );
          } // end catch
         finally
         {
             try
             {
                 myResultSet.close();
                 myStatement.close();
                 myConnection.close();
             } // end of try block
     
             catch ( SQLException SQLexception )
             {
                SQLexception.printStackTrace();
             } // end catch block
         } // end of finally
     
       } // end constructor
     
       // create and position GUI components; register event handlers
       private void createUserInterface()
       {
          // get content pane for attaching GUI components
          Container contentPane = getContentPane();
     
          // enable explicit positioning of GUI components 
          contentPane.setLayout( null );
     
          // set up restaurantJLabel
          restaurantJLabel = new JLabel("Restaurant");
          restaurantJLabel.setFont(new Font("Times New Roman", Font.BOLD, 14));
          restaurantJLabel.setBounds(30, 50, 100, 100);
     
          waiterJPanel = new JPanel();
          waiterJPanel.setLayout(null);
          waiterJPanel.setBounds(20, 50, 100, 100);
          waiterJPanel.setBorder(BorderFactory.createTitledBorder
          (BorderFactory.createEtchedBorder(),"Waiter Information"));
     
          menuItemsJPanel = new JPanel();
          menuItemsJPanel.setLayout(null);
          menuItemsJPanel.setBounds(20, 50, 200, 200);
          waiterJPanel.setBorder(BorderFactory.createTitledBorder
         (BorderFactory.createEtchedBorder(),"Menu Items"));
     
     
          calculateBillJButton = new JButton("Calculate Button");
          calculateBillJButton.setLayout(null);
          calculateBillJButton.setBounds(250, 250, 50, 50);
     
    //     public void actionPerformed( ActionEvent event)
    //     {
    //        calculateBillJButtonActionPerformed( event );
    //     } 
    //     
          subtotalJLabel = new JLabel("Sub Total");
          subtotalJTextField = new JTextField();
     
          taxJLabel = new JLabel("Tax");
          taxJTextField = new JTextField();
     
          totalJLabel = new JLabel("Total");
          totalJTextField = new JTextField();
     
          // **** TODO ****** set properties of application's window
     
          // **** TODO ****** ensure database connection is closed
          // **** TODO ****** when user quits application
          addWindowListener(
     
             new WindowAdapter()anonymous inner class
             {
                //  event handler called when close button is clicked
                public void windowClosing( WindowEvent event )
                {
                   frameWindowClosing( event );
                }
     
             } //  end anonymous inner class
     
          ); // end addWindowListener
     
       } // end method createUserInterface
     
       // **** TODO ****** set up waiterJPanel
       private void createWaiterJPanel()
       {
          // set up waiterJPanel
          waiterJPanel = new JPanel();
          waiterJPanel.setLayout( null );
          waiterJPanel.setBounds( 20, 152, 232, 152 );
          waiterJPanel.setBorder( BorderFactory.createTitledBorder( 
          BorderFactory.createEtchedBorder(), "Waiter Information" ) );
     
          // set up tableNumberJLabel
          tableNumberJLabel = new JLabel();
          tableNumberJLabel.setBounds( 8, 24, 80, 24 );
          tableNumberJLabel.setText( "Table Number:" );
          waiterJPanel.add( tableNumberJLabel );
     
          // set up tableNumberJTextField
          tableNumberJTextField = new JTextField();
          tableNumberJTextField.setBounds(10, 30, 90, 30);
          waiterJPanel.add( tableNumberJTextField );
     
          // set up waiterNameJLabel
          waiterNameJLabel = new JLabel();
          waiterNameJLabel.setBounds( 8, 24, 80, 24 );
          waiterNameJLabel.setText( "Waiter Name:" );
          waiterJPanel.add( waiterNameJLabel );
     
          // set up waiterNameJTextField
          waiterNameJTextField = new JTextField();
          waiterNameJTextField.setBounds(10, 30, 90, 30);
          waiterJPanel.add( waiterNameJTextField );
       } // end method createWaiterJPanel
     
     
        // create menuItemsJPanel
       private void createMenuItemsJPanel()
       {
          //  set up menuItemsJPanel
          menuItemsJPanel = new JPanel();
          menuItemsJPanel.setBounds( 20, 152, 232, 152 );
          menuItemsJPanel.setBorder( BorderFactory.createTitledBorder( 
             BorderFactory.createEtchedBorder(), "Menu Items" ) );
          menuItemsJPanel.setLayout( null );
    //*******************************************************************
          //  set up beverageJLabel
          beverageJLabel = new JLabel();
          beverageJLabel.setBounds( 8, 24, 80, 24 );
          beverageJLabel.setText( "Beverage:" );
          menuItemsJPanel.add( beverageJLabel );
     
          // set up beverageJComboBox
          beverageJComboBox = new JComboBox();
          beverageJComboBox.setBounds( 88, 24, 128, 25 );
          menuItemsJPanel.add( beverageJComboBox );
          beverageJComboBox.addItemListener(
     
             new ItemListener()  // **** TODO ****** anonymous inner class
             {
                // **** TODO ****** event handler called when item in beverageJComboBox
                // **** TODO ****** is selected
                public void itemStateChanged( ItemEvent event )
                {
                   beverageJComboBoxItemStateChanged( event );
                }
     
             } // end anonymous inner class
     
          ); // end addItemListener
     
          // add items to beverageJComboBox
          beverageJComboBox.addItem("Minerals");
          beverageJComboBox.addItem("Tea");
          beverageJComboBox.addItem("Coffee");
          beverageJComboBox.addItem("Minerla Water");
          beverageJComboBox.addItem("Fruit Juice");
          beverageJComboBox.addItem("Milk");
    //******************************************************************
          // set up appetizerJLabel
          appetizerJLabel = new JLabel();
          appetizerJLabel.setBounds( 8, 24, 80, 24 );
          appetizerJLabel.setText( "Appetizer:" );
          menuItemsJPanel.add( appetizerJLabel );
     
          // set up appetizerJComboBox
          appetizerJComboBox = new JComboBox();
          appetizerJComboBox.setBounds( 88, 24, 128, 25 );
          menuItemsJPanel.add( appetizerJComboBox );
          beverageJComboBox.addItemListener(
     
             new ItemListener()  // **** TODO ****** anonymous inner class
             {
                // **** TODO ****** event handler called when item in beverageJComboBox
                // **** TODO ****** is selected
                public void itemStateChanged( ItemEvent event )
                {
                   appetizerJComboBoxItemStateChanged( event );
                }
     
             } // end anonymous inner class
          ); // end addItemListener
     
          // add items to appetizerJComboBox
          appetizerJComboBox.addItem("Chicken Wings");
          appetizerJComboBox.addItem("Pate and Toast");
          appetizerJComboBox.addItem("Potato Skins");
          appetizerJComboBox.addItem("Nachos");
          appetizerJComboBox.addItem("Garlic Mushrooms");
          appetizerJComboBox.addItem("SeaFood Cocktail");
          appetizerJComboBox.addItem("Brie Cheese");
    //****************************************************************
          // set up mainCourseJLabel
          mainCourseJLabel = new JLabel();
          mainCourseJLabel.setBounds( 8, 24, 80, 24 );
          mainCourseJLabel.setText( "Main Course:" );
          menuItemsJPanel.add( mainCourseJLabel );
     
          // set up mainCourseJComboBox
          mainCourseJComboBox = new JComboBox();
          mainCourseJComboBox.setBounds( 88, 24, 128, 25 );
          menuItemsJPanel.add( mainCourseJComboBox );
          mainCourseJComboBox.addItemListener(
     
          new ItemListener()  // **** TODO ****** anonymous inner class
             {
                // **** TODO ****** event handler called when item in beverageJComboBox
                // **** TODO ****** is selected
                public void itemStateChanged( ItemEvent event )
                {
                   mainCourseJComboBoxItemStateChanged( event );
                }
     
             } // end anonymous inner class
          ); // end addItemListener
     
          // add items to mainCourseJComboBox
          mainCourseJComboBox.addItem("Seafood Alfredo");
          mainCourseJComboBox.addItem("Chicken Alfredo");
          mainCourseJComboBox.addItem("Lasagne");
          mainCourseJComboBox.addItem("Turkey Club");
          mainCourseJComboBox.addItem("Lobster Pie");
          mainCourseJComboBox.addItem("Rib Steak");
          mainCourseJComboBox.addItem("Scampi");
          mainCourseJComboBox.addItem("Turkey & Ham");
          mainCourseJComboBox.addItem("Chicken Kiev");
     //**********************************************************
     
          // set up dessertJLabel
          dessertJLabel = new JLabel();
          dessertJLabel.setBounds( 8, 24, 80, 24 );
          dessertJLabel.setText( "Main Course:" );
          menuItemsJPanel.add( dessertJLabel );
     
          // set up dessertJComboBox
          dessertJComboBox = new JComboBox();
          dessertJComboBox.setBounds( 88, 24, 128, 25 );
          menuItemsJPanel.add( dessertJComboBox );
          dessertJComboBox.addItemListener(
     
          new ItemListener()  // **** TODO ****** anonymous inner class
             {
                // **** TODO ****** event handler called when item in beverageJComboBox
                // **** TODO ****** is selected
                public void itemStateChanged( ItemEvent event )
                {
                   dessertJComboBoxItemStateChanged( event );
                }
     
             } // end anonymous inner class
     
          ); // end addItemListener
     
             // add items to dessertJComboBox
          dessertJComboBox.addItem("Apple Pie");
          dessertJComboBox.addItem("Sundae");
          dessertJComboBox.addItem("Carrot Cake");
          dessertJComboBox.addItem("Mud Pie");
          dessertJComboBox.addItem("Pavlova");
     
       } // end method createMenuItemsJPanel
     //********************************************************************   
     
       // add items to JComboBox
       private void loadCategory(
          String category, JComboBox categoryJComboBox )
       {
          loadCategory("beverage", beverageJComboBox);
          loadCategory("appetizer", appetizerJComboBox);
          loadCategory("main course", mainCourseJComboBox);
          loadCategory("dessert", dessertJComboBox);
     
          try
          {
             myResultSet = myStatement.executeQuery("SELECT name FROM" + 
             "Menu WHERE category = "" + category + ");
     
             while(myResultSet.next())
             {
                 categoryJComboBox.addItem(myResultSet.getString("name"));
             }
             myResultSet.close();
          } // end try block
          catch ( SQLException SQLexception )
            {
                SQLexception.printStackTrace();
                System.out.println("Cannot load Categories");
            } // end catch block         
     
       } // end method loadCategory
     
       // user select beverage
       private void beverageJComboBoxItemStateChanged( ItemEvent event )
       {
           // select an item
           if(event.getStateChange() == ItemEvent.SELECTED)
           {
              billItems.add((String)beverageJComboBox.getSelectedItem());
           }
     
       } // end of beverageJComboBoxItemStateChanged
     
     
       // user select appetizer
       private void appetizerJComboBoxItemStateChanged( ItemEvent event )
       {
           if(event.getStateChange() == ItemEvent.SELECTED)
           {
              billItems.add((String)appetizerJComboBox.getSelectedItem());
           }
     
       } // end method appetizerJComboBoxItemStateChanged
     
       // user select main course
       private void mainCourseJComboBoxItemStateChanged( 
          ItemEvent event )
       {
           if(event.getStateChange() == ItemEvent.SELECTED)
           {
              billItems.add((String)mainCourseJComboBox.getSelectedItem());
           }
     
     
       } // end method mainCourseJComboBoxItemStateChanged
     
       // user select dessert
       private void dessertJComboBoxItemStateChanged( ItemEvent event )
       {
           if(event.getStateChange() == ItemEvent.SELECTED)
           {
              billItems.add((String)dessertJComboBox.getSelectedItem());
           }
     
       } // end method dessertJComboBoxItemStateChanged
     
       // user click Calculate Bill JButton
       private void calculateBillJButtonActionPerformed( 
          ActionEvent event )
       {
       String tableNumber = tableNumberJTextField.getText().trim();
       String waiterName = waiterNameJTextField.getText().trim();
     
       if (tableNumber.length() == 0 || waiterName.length() == 0)
        {
           JOptionPane.showInputDialog("Information in Table Number and Waiter Name "
                   + "must be entered");
        }
       else
       {
     
       }
     
     
       }// end method calculateBillJButtonActionPerformed
     
       // **** TODO ****** calculate subtotal
       private double calculateSubtotal()
       {
          return 0;
     
       } // end method calculateSubtotal
     
       // **** TODO ****** user close window
       private void frameWindowClosing( WindowEvent event )
       {
     
       }  // end method frameWindowClosing
     
       // **** TODO ****** method main
       public static void main( String[] args ) 
       {
         JFrame createUserInterface = new JFrame();
         createUserInterface.setSize(500, 500);
         createUserInterface.setVisible(true);
         createUserInterface.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
         createUserInterface.setLocationRelativeTo(null);
     
     
          // **** TODO ****** check command-line arguments
          if ( args.length == 2 )
          {
             // **** TODO ****** get command-line arguments
             String databaseUserName = args[ 0 ];
             String databasePassword = args[ 1 ];
     
             // **** TODO ****** create new RestaurantBillCalculator
             RestaurantBillCalculator application = new RestaurantBillCalculator ( 
             databaseUserName, databasePassword );
     
     
          }
          else
          {
             System.out.println( "Usage: java " + 
                "RestaurantBillCalculator databaseUserName databasePassword" );
          }
     
       } // end method main
     
    } // end class RestaurantBillCalculator


  2. #2
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    Could you show me the line where you actually add any components to your frame?

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    This is way too much code to write before doing any testing and way too much code to post to determine why you are unable to display a JFrame.

    Your code has errors. Are you getting error messages when you compile and/or run the code? You should be. Post your errors or other indications of bad behavior.

    What's up with this line ( ~line 177 ):

    new WindowAdapter()anonymous inner class

    That's not a valid Java statement.

  4. #4
    Member
    Join Date
    Sep 2014
    Posts
    31
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    You see this is what i am not sure about, have i actually added anything to the frame, when I compile this, a window does appear but nothing in it, I'm not sure where i have went wrong here.

    --- Update ---

    You see i am taking this step by step according to the brief i have been given, im not worried about the WindowsAdapter part you are referring to just yet. I think my code is okay just a small disconnection somewhere hence why i am asking why no components are showing within the JFrame

  5. #5
    Member
    Join Date
    Sep 2014
    Posts
    31
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    ScreenHunter_40 Sep. 04 21.47.jpg

    This is what its like when i compile, when i hit the x on the JFrame, BUild Successful appears in my output area :/

  6. #6
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    To add something to a JFrame you need to call the method add() on the content pane of the frame.
    I can not find any place in your program where you are doing that (might be because you posted a huge amount of code).

    Perhaps start with something smaller, just a frame with a single button or a label maybe. Once you got that working you can then try something bigger.

  7. #7
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    contentPane.setLayout( null );
    a) I recommend NEVER using a null layout
    b) I recommend answering the question posed in post #2

  8. #8
    Member
    Join Date
    Sep 2014
    Posts
    31
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    Quote Originally Posted by copeg View Post
    a) I recommend NEVER using a null layout
    b) I recommend answering the question posed in post #2
    Unfortunately i have to use Null Layout, lecturer wants it for good practice purposes

    --- Update ---

    Quote Originally Posted by Cornix View Post
    To add something to a JFrame you need to call the method add() on the content pane of the frame.
    I can not find any place in your program where you are doing that (might be because you posted a huge amount of code).

    Perhaps start with something smaller, just a frame with a single button or a label maybe. Once you got that working you can then try something bigger.
    Well i wish i had the time, this is a project due in soon, i cant start with something small, hence why I am asking where i am going wrong with this program

  9. #9
    Member coderxx0's Avatar
    Join Date
    Feb 2013
    Location
    England, UK
    Posts
    61
    My Mood
    Cool
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    Quote Originally Posted by SeanyC View Post
    Unfortunately i have to use Null Layout, lecturer wants it for good practice purposes
    I know they said you have to use the "null" as a good practice but when I was doing something from a brief it said use a "null" layout and I kept getting errors my point is if you listen to these guys they can really help you you do need to start small I know you said it's due in soon but the fact is with JAVA you have to start small and work up

  10. #10
    Member
    Join Date
    Sep 2014
    Posts
    31
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    Quote Originally Posted by coderxx0 View Post
    I know they said you have to use the "null" as a good practice but when I was doing something from a brief it said use a "null" layout and I kept getting errors my point is if you listen to these guys they can really help you you do need to start small I know you said it's due in soon but the fact is with JAVA you have to start small and work up
    I just don't have the time I'm afraid, Hence I'm asking all of this, any
    Other day of the week I would listen and would never use null layout
    I've asked my lecturer now to figure out this problem

  11. #11
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    Unfortunately i have to use Null Layout, lecturer wants it for good practice purposes
    Do you mean good practice - as in a good way to get better - or 'good practice' as in Best Practice? Because using null layout is far from best practice.

  12. #12
    Member
    Join Date
    Sep 2014
    Posts
    31
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    Quote Originally Posted by copeg View Post
    Do you mean good practice - as in a good way to get better - or 'good practice' as in Best Practice? Because using null layout is far from best practice.
    Good practice in a sense that when I am positioning components
    such as Jcomboboxes i can position stuff with setBounds

    Prob any other time I would not use it and my lecturer would
    prob say not to use it also, just for this particular project

  13. #13
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    As I already said, make sure you add your components to your frame correctly. You can simply google "Add components to JFrame" and you should get plenty of tutorials, for example this one:
    swing - Java - adding components to JFrame - Stack Overflow

  14. #14
    Member
    Join Date
    Sep 2014
    Posts
    31
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    Quote Originally Posted by GregBrannon View Post
    This is way too much code to write before doing any testing and way too much code to post to determine why you are unable to display a JFrame.

    Your code has errors. Are you getting error messages when you compile and/or run the code? You should be. Post your errors or other indications of bad behavior.

    What's up with this line ( ~line 177 ):

    new WindowAdapter()anonymous inner class

    That's not a valid Java statement.
    Can i just add to your post here and say that there was supposed to be two // in front of anonymous inner class, typo problems sorry

  15. #15
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    And what have you done with Cornix' suggestions?

  16. #16
    Member
    Join Date
    Sep 2014
    Posts
    31
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    Quote Originally Posted by GregBrannon View Post
    And what have you done with Cornix' suggestions?
    No i haven't, problem is i keep find examples with No argument constructors like this:
    code not executing (Beginning Java forum at JavaRanch)

    My constructor has two-arguments: public RestaurantBillCalculator( String databaseUserName, String databasePassword )

    and this is in my main method
    RestaurantBillCalculator application = new RestaurantBillCalculator (
    databaseUserName, databasePassword );

  17. #17
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    What has that to do with adding components to your JFrame? (Post #13)

  18. #18
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    You have been given ample advice, which from our vantage point seems as if it is being ignored. First, answer the question in post #2. If you cannot, or do not understand what that question means, then thoroughly read all the advice you have been given (esp. those posts by Cornix)

  19. #19
    Member
    Join Date
    Sep 2014
    Posts
    31
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    Quote Originally Posted by copeg View Post
    You have been given ample advice, which from our vantage point seems as if it is being ignored. First, answer the question in post #2. If you cannot, or do not understand what that question means, then thoroughly read all the advice you have been given (esp. those posts by Cornix)
    forget it, got someone else helping me

  20. #20
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Why is my JFrame not showing components such as JComboBoxes

    Also posted at: JFrame Issues (Swing / AWT / SWT forum at JavaRanch)

    http://www.javaprogrammingforums.com...s-posting.html
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Trouble adding components to a JFrame
    By NcAdams in forum AWT / Java Swing
    Replies: 3
    Last Post: May 22nd, 2012, 10:46 PM
  2. [SOLVED] JPanel not showing in JFrame
    By Tjstretch in forum AWT / Java Swing
    Replies: 2
    Last Post: October 31st, 2011, 12:27 AM
  3. [SOLVED] Add more components from JFrame Form
    By zecute in forum AWT / Java Swing
    Replies: 3
    Last Post: May 11th, 2011, 07:30 AM
  4. Making a little Lua script 'generator', JFrame showing up blank.
    By scribbleno1 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: May 2nd, 2010, 07:00 PM
  5. Change JFrame components problem
    By bruno88 in forum AWT / Java Swing
    Replies: 0
    Last Post: June 30th, 2009, 01:25 PM

Tags for this Thread