0

On intellij I have created a JXTable on a JPanel.
I have added two columns and set their width.
I want the panel too be much longer then the jxtable and so i set its size to be very large.
The problem is that the columns are are added to the left side.
Is there a way to make them added to the right side of the table area? I have tried

  jxtable.setAlignment(JComponent.RIGHT_ALIGNMENT) 

but with no success

Thank you.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Bick
  • 17,833
  • 52
  • 146
  • 251

2 Answers2

0

You need to use an appropriate layout manager. Check out this link: http://download.oracle.com/javase/tutorial/uiswing/layout/visual.html

From your description a FlowLayout set to RIGHT sounds like the best solution for you.

jzd
  • 23,473
  • 9
  • 54
  • 76
0

I may not be understanding your question, but here is one way you can place a table in a panel that is larger than the table:

final JPanel bigPanel = new JPanel(new BorderLayout());
// initialize your panel with stuff

final JXTable smallTable = new JXTable(...);
bigPanel.add( smallTable, BorderLayout.LINE_START ); // Left side of panel
bigPanel.add( smallTable, BorderLayout.LINE_END );   // Right side of panel
bigPanel.add( smallTable, BorderLayout.PAGE_START ); // Top of panel
bigPanel.add( smallTable, BorderLayout.PAGE_END);    // Bottom of panel
bigPanel.add( smallTable, BorderLayout.CENTER );     // Center of panel
Nate W.
  • 9,141
  • 6
  • 43
  • 65