1

I am trying to set background image width 100, height 100 and making the border to null. So that i can design the input field looking similar to following, but border is not applying and round corner does not exit + there is no background image apply way around.

http://image.shutterstock.com/display_pic_with_logo/85630/85630,1234358857,2/stock-vector-website-design-set-on-a-black-consist-of-menu-bar-buttons-checkbox-input-text-fields-drop-24795286.jpg

// Current
String[] petStringsa = { "eth0: ", "eth1: " };
JPanel namePanela = new JPanel(new BorderLayout());
JLabel nameLabela = new JLabel("View Inerfaces: ");
nameLabela.setDisplayedMnemonic(KeyEvent.VK_N);

final JComboBox nameTextFielda = new JComboBox(petStringsa);    
nameTextFielda.setBorder(null);
nameTextFielda.setBackground(Color.white);

nameLabela.setLabelFor(nameTextFielda);
namePanela.add(nameLabela, BorderLayout.WEST);
namePanela.add(nameTextFielda, BorderLayout.CENTER);
Bakudan
  • 19,134
  • 9
  • 53
  • 73
  • 5
    For rounded corners, find a look and feel that does this for you. Nimbus rounds the corners a little. The background image is a separate issue and is well-answered on this site and elsewhere. Consider making JLabel your contentPane and giving it an ImageIcon; just make sure that you make it opaque and give it an appropriate layout manager. – Hovercraft Full Of Eels Apr 15 '12 at 15:54
  • 2
    more than half or [Swing Look and Feels](http://stackoverflow.com/a/3954646/714968) implementing Rounded Whatever for JComponents, then why to reinvent the wheel, not good example because right side of container isn's correctly layed :-), toolbar or menu living own life too – mKorbel Apr 15 '12 at 20:01

1 Answers1

2

Take a look on this resource http://java.sun.com/developer/technicalArticles/GUI/translucent_shaped_windows/

I explains how to change the swing elements' shape.

This thread explains how to put background image: How to set an image as a background for Frame in Swing GUI of java?

Although my answer almost duplicates the Hovercraft Full Of Eels' comment I decided to write it because it contains specific links.

Community
  • 1
  • 1
AlexR
  • 114,158
  • 16
  • 130
  • 208