Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2011
    Location
    Belgium
    Posts
    25
    Rep Power
    0

    Default JCombobox not dropping down after using JTextField

    Hey I have a JCombobox that does drop down when my JPalet is innitialised but when I type something in a JTextField I can't dropdown the JCombobox anymore what's the reason for that?
    Everything is inside of a JRowPanel, but the problem only starts after I type something in the JTextField

    thanks!

    part of the code:

    Java Code:
          
                for(int i=0;i<=3;i++)
                {
    
                    JPanel rowPanel = new JPanel();
                    rowPanel.setPreferredSize(new Dimension(300,30));
                    columnpanel.add(rowPanel);
                    rowPanel.setLayout(null);
                    
                    if(i == 0)
                    {
                     label[i] = new JLabel("Naam: ");
                     label[i].setBounds(20, 5, 200, 23);
                     rowPanel.add(label[i]);
                     
                     text[i] = new JTextField("name:");
                     text[i].setBounds(100,5,160,23);
                     text[i].setBackground(Color.YELLOW);
                     rowPanel.add(text[i]);
                    }
                    if(i == 1)
                    {
                     label[i] = new JLabel("firstname: ");
                     label[i].setBounds(20, 5, 200, 23);
                     rowPanel.add(label[i]);
                     
                     text[i] = new JTextField("");
                     text[i].setBounds(100,5,160,23);
                     text[i].setBackground(Color.YELLOW);
                     rowPanel.add(text[i]);   
                        
                    }
                    if(i == 2)
                    {
                     label[i] = new JLabel("status: ");
                     label[i].setBounds(20, 5, 200, 23);
                     rowPanel.add(label[i]);
                     
                     cbStatus.setBounds(100, 5, 160, 23);
                     rowPanel.add(cbStatus);
                    }
                    if(i == 3)
                    {
                     label[i] = new JLabel("birthday ");
                     label[i].setBounds(20, 5, 200, 23);
                     rowPanel.add(label[i]);
                     
                     text[i] = new JTextField("0 ");
                     text[i].setBounds(150,5,120,23);
                     text[i].setBackground(Color.YELLOW);
                     rowPanel.add(text[i]);   
                    }
    
                    if(i%2==0)
                    rowPanel.setBackground(SystemColor.inactiveCaptionBorder);
                }
                
                  add(scrollPane,BorderLayout.CENTER);
            }

  2. #2
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,017
    Rep Power
    6

    Default Re: JCombobox not dropping down after using JTextField

    Please include an Short, Self Contained, Correct Example instead of an extract from you code. Otherwise, it is difficult to help you.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Join Date
    Dec 2011
    Location
    Belgium
    Posts
    25
    Rep Power
    0

    Default Re: JCombobox not dropping down after using JTextField

    Ok, this is what's relative to my question.

    From the constructor:

    Java Code:
    text = new JTextField[4];
          label = new JLabel[4];
         
          cbStatus = new JComboBox(rep.getStatusen().toArray());
          cbStatus.setRenderer(new ComboboxRenderer());
    Java Code:
     this.setLayout(new BorderLayout());
           add(listscroller,BorderLayout.EAST);
           add(groepbox,BorderLayout.SOUTH);
           
    
                scrollPane = new JScrollPane();
                scrollPane.setBounds(10, 101, 100, 276);
                scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
               
                
                //Paneel met een borderlayout om erin toe te voegen:
                JPanel borderlayoutpanel = new JPanel();
                scrollPane.setViewportView(borderlayoutpanel);
                borderlayoutpanel.setLayout(new BorderLayout(0, 0));
    
                JPanel columnpanel = new JPanel();
                borderlayoutpanel.add(columnpanel, BorderLayout.NORTH);
                columnpanel.setLayout(new GridLayout(0, 1, 0, 1));
                columnpanel.setBackground(Color.gray);
    That's all the relevant information I guess, dropdown works, but it doesn't drop down anymore after inserting something in the JTextfield (I does get focus when you click on the arrow I think, but the dropdown isn't showing anymore)

  4. #4
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,017
    Rep Power
    6

    Default Re: JCombobox not dropping down after using JTextField

    Sorry, but that still doesn't help. The self contained part means than I can copy and paste it and it will compile. But just show code which demonstrates the problem, not the entire app.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    Join Date
    Dec 2011
    Location
    Belgium
    Posts
    25
    Rep Power
    0

    Default Re: JCombobox not dropping down after using JTextField

    Quote Originally Posted by jim829 View Post
    Sorry, but that still doesn't help. The self contained part means than I can copy and paste it and it will compile. But just show code which demonstrates the problem, not the entire app.

    Regards,
    Jim
    nevermind i changed to JSpinner because of this problem, the reason to use JCombobobox was that I was able to place objects in it with a renderer but in a JSpinner I can't seem to place objects.
    I created a new thread for it.

Similar Threads

  1. dropping a URL: how to get page title?
    By zacchia in forum AWT / Swing
    Replies: 3
    Last Post: 06-20-2011, 04:45 AM
  2. Identify JTextField and JComboBox (editable)
    By mine0926 in forum New To Java
    Replies: 2
    Last Post: 07-09-2010, 05:36 PM
  3. JComboBox and JTextField
    By fahad in forum NetBeans
    Replies: 3
    Last Post: 05-31-2010, 04:20 AM
  4. Replies: 2
    Last Post: 12-10-2009, 02:58 PM
  5. Replies: 2
    Last Post: 07-30-2008, 01:33 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
  •