How do I properly display all content in a JTabbedPane?
- by maleki
I am nesting a JPanel inside a JTabbedPane. I am having trouble displaying all the content inside of the JTabbedPane. The outside borders of the internal content get chopped off.
I am currently not using a Layout Manager for my JTabbedPane or dummy Panel because it stretches my content automatically.
How do I add a JPanel inside the JTabbedPane so that I can have an even border around all the content.My attempts to create a dummy panel and setting a border for the inner panel using BorderFactory haven't worked. Is there a convention that I need to know to do this correctly?
JTabbedPane tabPane = new JTabbedPane();
GridPane tab1 = new GridPane();
GridPane tab2 = new GridPane();
tabPane.add("My Pieces",tab1);
tabPane.add("Opponent Pieces",tab2);
public class GridPane extends JPanel {
public GridPane()
{
this.setPreferredSize(new Dimension(400,160));
this.setLayout(new GridLayout(4,10));
this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 10; j++) {
boardSquares[i][j] = new JPanel();
boardSquaresArr.add(boardSquares[i][j]);
this.add(boardSquares[i][j]);
}
}
}
}