Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JLists are not appearing in JPanel  RSS feed

 
fredy salgado
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to add 2 JLists inside a JPanel for a crossword. The JPanel is located SOUTH and I'm using BorderLayout in the constructor to locate the JPanel.
The problem is, I can't see the 2 JLists inside the JPanel. For some strange reason the JLists appear in the center where the crosswordPanel is, even though the clues JPanel method is located SOUTH.

 
Carey Brown
Saloon Keeper
Posts: 2536
33
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add something like:
 
fredy salgado
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:Add something like:

I already played with that and the JLists still appear in the center instead of south.

Here are 2 screenshots:

Both JLists should appear in the white JPanel located south.


If I comment the crosswordPanel grid which appears in the center in the first pic, the last JList created in the clues method appears in the center. They should appear in the south JPanel.


 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I fixed up your code (with the missing MouseListener methods) and ran it, I didn't quite get that result. In my case I didn't see your JLists anywhere. But when I looked closer I realized that was because they were empty, so there was nothing to see. When I changed one line of code to look like this:



then the list showed up in the South panel.
 
fredy salgado
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:When I fixed up your code (with the missing MouseListener methods) and ran it, I didn't quite get that result. In my case I didn't see your JLists anywhere. But when I looked closer I realized that was because they were empty, so there was nothing to see. When I changed one line of code to look like this:



then the list showed up in the South panel.


Could you post the entire code. They still appear behind the center grid for me, with the code you posted. I didn't post the MouseListener methods but I have them in my code.
 
fredy salgado
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok got it.

In the clues method, I added these 2 lines to both JLists:





Changed the layout from FlowLayout to BorderLayout.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!