• Post Reply Bookmark Topic Watch Topic
  • New Topic

JButton without border/frame  RSS feed

 
Grégoire Berclaz
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,
I like to use a JToolBar and put on a JButton without border(I applied to my JButton a IconImage).
Is it possible?
I have an other question. I didn't resize my JButton how I'll like... maibe didn't I use a JButton on my JToolBar or else?
Tks for the answers.
Greg
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Button without border:
yourbutton.setBorderPainted(false);
I don't understand your question about resizing. Could you elaborate a bit on that?
 
Grégoire Berclaz
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Tks for your answer...
I don't understand what the problem... this is my code :
ImageIcon img = new ImageIcon("btn/img1.gif") ;
JButton bouton = new JButton(img) ;
bouton.setBorderPainted(false) ;
bouton.setSize(10,10) ;
My image width : 13
My image height : 12
And the button's width mesures minimum 20... I see perfectly the img1.gif...
What the problem?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The distance between button images/text and the edge of the button or the Margin is measured with Insets. To change this, so that you lose the extra padding you need to do:
Insets margin = new Insets(int,int,int,int);
bouton.setMargin(margin);
Don't worry about setting the size of the Button on the JToolbar, just make all your images the same size and specify the margin on each button. That should do the trick.
 
Grégoire Berclaz
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tks
All it's ok...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!