Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JScrollPane and paint method problems  RSS feed

 
Jonathan Sternberg
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently, I'm trying to make a program to handle double elimination brackets for a team tournament. One of my classes involves overwritting the paint method in order to display the brackets. The code is as follows:


It draws the brackets recursively and works pretty well. The class that it is in extends JLabel and is added to the content pane of a different class (GUI) that extends JFrame. Inside of GUI, I have:



But when I add the BracketDisplayer (the JLabel) as a JScrollPane and run it, the Scroll Bar doesn't show up. I've had this problem other times with JButtons that don't show up when I overwrite a paint method. Why does this happen and how can I fix it?

Thank you for any help.
 
Brian Cole
Author
Ranch Hand
Posts: 949
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you saying it works ok if you add the BracketDisplayer directly without the JScrollPane? Does the BracketDisplayer return an appropriate value in its getPreferredSize() method?

btw, why does BracketDisplayer extend JLabel?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!