Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

    Default Multiple components in Jpanel

    Hi,

    I have been trying to add a graph and a combo box dynamically to a jpanel.
    This jpanel is added to the 3rd index of a jTabbedPane. The problem I am facing is that only the last added component shows up on UI at runtime, If I add combobox later that only this shows up and graph doesnt. The code is as follows

    jComboBox5 = new JComboBox(data.inProdTradeName);
    jComboBox5.setSize(100, 20);
    jComboBox5.setAlignmentX(100);
    jPanel6.add(jComboBox5, 0);
    //Adding a series graph dynamically to the panel
    jPanel6.updateGraph();

    In the above case only the graph shows up since I added that last.
    I also tried writing following code after I add the two components, but that did not help either:

    jPanel6.revalidate()
    jTabbedPane1.revalidate()

    Can some one tell me what am I missing here..

    Thanks in advance!

  2. #2
    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

    Default

    Hi,

    I have found the mistake, I was clearing the components in one point of time.
    Sorry for the false alarm :)

Similar Threads

  1. Components Layout in a JPanel
    By jboy in forum New To Java
    Replies: 4
    Last Post: 10-11-2009, 01:08 PM
  2. [SOLVED] accessing JPanel.add components
    By VeasMKII in forum New To Java
    Replies: 5
    Last Post: 06-19-2009, 02:29 AM
  3. How to place components on JPanel
    By deshprateek in forum AWT / Swing
    Replies: 1
    Last Post: 02-22-2009, 06:34 AM
  4. help?! paint on top of swing components on JPanel
    By beam2008 in forum AWT / Swing
    Replies: 1
    Last Post: 12-05-2008, 05:15 AM
  5. Removing components from JPanel
    By Echilon in forum New To Java
    Replies: 0
    Last Post: 12-30-2007, 05:05 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
  •