Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

How create a JComboBox with the border round

 
Greenhorn
Posts: 9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I'm doing developing a new look and feel for swing and now I want to create a new style of a combo box with the border round.

I have implemented new Border and this is the code

and this is the effect


But my problem is when I add the panel black and the JComboBox background white the effect is wrong and it is equal this



My component MaterialComboBoxUI is this



My problem is how remove the rectangular border to JComboBox?

Solution
I rewrite the update method, this is the code


This is the effect
 
Sheriff
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi vincenzo, welcome to the Ranch!

To me it looks like you're setting the JComboBox's border at line 32 of your code. You say you don't want that border? Then it seems to me you could just remove that line of code.

You also have a method called createArrowButton which does a lot of things with your special border-maker, but I don't see any code which calls that method. Anyway I don't understand why you don't put the special border around the combo box, instead of making a separate button.
 
vincenzo palazzo
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:Hi vincenzo, welcome to the Ranch!

To me it looks like you're setting the JComboBox's border at line 32 of your code. You say you don't want that border? Then it seems to me you could just remove that line of code.

You also have a method called createArrowButton which does a lot of things with your special border-maker, but I don't see any code which calls that method. Anyway I don't understand why you don't put the special border around the combo box, instead of making a separate button.



Hi Paul, thanks so much.

I'm setting my border round whit this code but the line of the border is round and the border doesn't is round.

To me it looks like you're setting the JComboBox's border at line 32 of your code. You say you don't want that border? Then it seems to me you could just remove that line of code.



Because this method is the method for setting a button od the JComboBox and I inherited all to BasicComboBoxUI

You also have a method called createArrowButton which does a lot of things with your special border-maker, but I don't see any code which calls that method. Anyway I don't understand why you don't put the special border around the combo box, instead of making a separate button




I found the problem and I edited the question with the solution, thanks so much
 
Paul Clapham
Sheriff
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, you're ahead of me in working with Swing look and feels. Good to hear you have the solution now.
 
vincenzo palazzo
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:Okay, you're ahead of me in working with Swing look and feels. Good to hear you have the solution now.



Thanks so much for your answer and for you beautiful words
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!