大概有 25欄 25列左右
使用gridbaglayout
造成空白列數很多 座標往下移 或是 位置擁擠
有試過 gbl_jMonitorPanel.columnWidths = new int[25];
gbl_jMonitorPanel.rowHeights = new int[25];
和 下列排法{0......} 都會 有些位置錯誤 列述錯亂
如果不設定的話 是直接 空白列很多 而導致 有些label出不來
請問 是哪邊 設定需要再更改嗎 謝謝^_________^
塞入的label 每個大小都是固定的
//配置大小
private JPanel getJMonitorPanel() {
if (jMonitorPanel == null) {
jMonitorPanel = new JPanel();
//指定大小
jMonitorPanel.setSize(1500, 2000);
}
return jMonitorPanel;
}
//主程式
private void PutLabel{
if (option.equals("ALL")){
//選擇全部時 配置 FlowLayout
jMonitorPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
jMonitorPanel.add(放入label);
}else{
//配置方式 改置gridbaglayout
jMonitorPanel.setLayout(new GridBagLayout());
//存入指定位置
GridBagLayout gbl_jMonitorPanel = new GridBagLayout();
gbl_jMonitorPanel.columnWidths = new int[]{180, 46, 0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
gbl_jMonitorPanel.rowHeights = new
int[]{20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
gbl_jMonitorPanel.columnWeights = new double[]{0.0, 0.0, 0.0,
Double.MIN_VALUE};
gbl_jMonitorPanel.rowWeights = new double[]{0.0, Double.MIN_VALUE};
jMonitorPanel.setLayout(gbl_jMonitorPanel);
GridBagConstraints tjMonitorPanel = new GridBagConstraints();
tjMonitorPanel.insets = new Insets(0, 0,0,5)
tjMonitorPanel.gridx = int_xaxis; //接取變數
tjMonitorPanel.gridy = int_yaxis;
jMonitorPanel.setVisible(true);
jMonitorPanel.add(label, tjMonitorPanel);
}
}