いくつかの任意の値を持つ単純なスクロール可能な JTable を作成し、それを JPanel 内に配置しようとしています。JTable は表示されますが、列名のみが表示され、残りの行が押しつぶされているように見えるという奇妙な結果が発生しています。また、テーブルはパネルの中央に表示され、上部に配置したいと思います。
// Panel to hold our layer information
JPanel layerPanel = new JPanel(new GridBagLayout());
layerPanel.setBackground(Color.LIGHT_GRAY);
layerPanel.setPreferredSize(new Dimension(200, 200));
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(0,5,0,5);
c.weightx = 1; c.weighty = 0.0;
c.fill = GridBagConstraints.BOTH;
c.gridx = 0; c.gridy = 0;
String[] columns = { "Show", "Layer" };
Object[][] data = {{"x", "Layer1"},
{"x", "Layer2"}};
// Construct our table to hold our list of layers
JTable layerTable = new JTable(data, columns);
layerTable.getColumnModel().getColumn(0).setPreferredWidth(64);
layerPanel.add(new JScrollPane(layerTable), c);
frame.add(layerPanel);
GridBagLayout を使用する代わりに GridLayout(1,0) を使用するとコードが機能するため、間違って使用しているように感じます。
お時間をいただきありがとうございます。