sethu
sethu

Reputation: 8411

Drawing borders on a java swing component

I have a UI requirement in java swing wherein I need to achieve the below:

enter image description here

The 2 buttons on the top are placed in a JPanel. I need to draw a line through the center of that panel, upto the beginning of the 2 buttons. The panel below is a container of panels arranged in a card layout. As and when the button is clicked, the card is switched showing another panel.

So in all respects this looks like a JTabbedPane, with one difference, the tabs are buttons arranged in the center of the tabbed pane. I need this difference for the UI I am building.

As of now, the buttons and card layout panel, looks like the below

enter image description here

As you can see, the buttons and panels appear and look separate, instead it would be nice if they are made to appear like they represent one unit.

Upvotes: 2

Views: 154

Answers (1)

camickr
camickr

Reputation: 324108

As you can see, the buttons and panels appear and look separate, instead it would be nice if they are made to appear like they represent one unit.

Put the Border around the outer panel. That is use a panel with a BorderLayout. This panel can have a LineBorder. Then you add your button panel to the NORTH and the panel with the CardLayout to the CENTER.

The line won't be drawn through the buttons but the buttons and panel will appear like they represent on unit.

Upvotes: 2

Related Questions