Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JButton stretched out on MigLayout

 
mitchell bat
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, when I run my code the button is stretched the full length of the panel, ive tried the following

- re sizing the panel
- setBounds
- setPreferredSize
- setMaximumSize
- setMinimumSize

Any ideas how to shrink it?

 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm confused as to why you have the JPanel variable "pan". You go to a lot of trouble setting it up, but then you don't use it in the GUI.
 
mitchell bat
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know it should represent what it means or what it's doing but that's not the point of this question. The question is why isn't the button re-sizing?
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But your question claims that you're using MigLayout. I don't see that you are using MigLayout, because you create a panel which uses MigLayout but then throw it away. So MigLayout is a red herring.
 
mitchell bat
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My apologies if I come off as misleading but where abouts do I "throw it out"? Do you mean in my code or in my responses?
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your code. Can you point out the line of code which adds the "pan" JPanel into your GUI?
 
mitchell bat
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Fred Kleinschmidt
Bartender
Posts: 470
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Why do you set the layout twice here?
Why use a migLayout for a single component?
 
mitchell bat
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would you recommend to use for just one component?
 
Brett Spell
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mitchell bat wrote:What would you recommend to use for just one component?


That depends on what the desired behavior is regarding that one component's size and position within its parent container. Without knowing more about that I could only speculate that either FlowLayout or GridBagLayout would be the best choice.
 
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!