• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can't change visibility of two jPanels when calling the method from a button event in another class

 
Chris Reed
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Let me see if I can explain what I am trying to do. I have two classes involved in this portion. CheckIn_Search (class #1) is my main UI and I am collecting search information from the user in a jPanel form. When they click "Search" it passes the search criteria to a method that contacts a web service and gets the results. These results are passed to coSearchResults (class #2) that opens a jFrame and jTable (in modal format, over the main window created by CheckIn_Search. The user selects a row in the table and that selection data is passed back to coSearchResults to populate a new jPanel form. When the data is passed from coSearchResults, I want to close its window, hide the first jPanel in CheckIn_Search and make the second jPanel visible. To accomplish this, I created a method in CheckIn_Search that simply hides/shows the panels (it will do more later). I instantiate and call the method in CoSearchResults as part of the button click event. The problem is, it doesn't work. The panels are unaffected and there are no errors. I've put in break-points and it goes into the method...ugh!
Here is the coSearch_Results code. Here is am retrieving the jtable row id and using the first value in the row to get the data from the table model as there is more data than what is displayed in the table. I'm sending that whole row of data to the method that changes visibility.


The code to show/hide the panel in CheckIn_Search is



Any help is appreciated!

 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too much to read in detail. I just saw a basic question that you want to hide/show a panel. In this case the commons solution is to use a CardLayout.

Read the section from the Swing tutorial for more information and working examples: How to Use Card Layout.
 
Chris Reed
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read a couple articles on Card Layout and it like what I was going for. Thanks for the tip.
 
Campbell Ritchie
Marshal
Posts: 52587
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!