[问题] Gridbaglayout排序乱掉

楼主: tool11 (:))   2014-06-13 20:21:42
大概有 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);
}
}

Links booklink

Contact Us: admin [ a t ] ucptt.com