0

I'm building a GUI using Netbeans, and I created a JPanel with some components to perform a add and search in some different contests. I would like to integrate this panel into a single JFrame when a button is clicked.

I tried to call like below in button action listener. I kept one constant panel in the frame and the component in this constant panel should repaint different panel. This is what I need.

I tried this code:

overemotional(); 
panel.repaint();

panel my-panel =new second panel();
panel.add(my-panel);

panel.repaint();

But my frame don't display the called panel, but it invoke the called panel. What actually am I doing wrong?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
kabilesh
  • 1
  • 3
  • *"I would like to integrate this panel into a single `JFrame` when a button is clicked."* 1) For many components in one space, use a [`CardLayout`](http://docs.oracle.com/javase/7/docs/api/java/awt/CardLayout.html) as seen in this [short example](http://stackoverflow.com/a/5786005/418556). 2) For better help sooner, post a [MCTaRE](http://stackoverflow.com/help/mcve) (Minimal Complete Tested and Readable Example). – Andrew Thompson Mar 16 '14 at 11:07
  • Are you using the GUI Builder tool? – Paul Samsotha Mar 16 '14 at 11:09
  • hai @peeskillet thank you so much i am using netbeans IDE – kabilesh Mar 17 '14 at 08:14
  • hai @AndrewThompson thanks for you response i manged to put the panels inside the frame . rather then creating it externally and calling them . it bit difficult to set the layout if i do so. but some how i am managing . now i am facing new problem hope u can help to solve this out – kabilesh Mar 17 '14 at 08:17
  • @AndrewThompson i hve one java file to call my mysql database , i am trying to pass values from my database java file to my frame java file.BY creating a funct like "framejave.getvalue (name ,paho, date ) " and receving the value in the frame java file ,i tried to print the passed value there is no problem it print the value correctly , but when i try to set value to the Jtextfeld it dosnt display the settext value ... i dono why ... :( – kabilesh Mar 17 '14 at 08:20
  • If you've solved the problem in this question, either answer it yourself, or delete it. Ask a new question for the (quite separate) new question. Note that this is a Q&A site, not a help desk. I mention that since you asked me personally, to help you, and seem a little confused.. But please start using Upper Case at the start of sentences. It is painful to read all lower case. It is like trying to listen to someone who is mumbling.. – Andrew Thompson Mar 17 '14 at 08:28
  • Thank you @AndrewThompson . I am new here so only i don't how to put it actually. Sorry for inconvenience. – kabilesh Mar 17 '14 at 09:49

0 Answers0