我一直在负责一个新的软件工具,而我会尝试测试它。的Java AWT或Swing组件缺失或不显示
问题: 我注意到我的GUI和服务器上运行的工具的GUI之间的区别: 组件丢失了! 这就好像它没有显示,因为我进入调试模式,并且一切似乎都很好。 这个图像显示了不同:
,你可以看到,在“轴端直径”组件在其他2个组件之间失踪。
CODE: 这里是一个代码的一部分。有很多是那些获得实例,并用同样的方法添加的项目,但它并不在我的电脑冲击片雷管(但效果很好的人!)
//PanelContainerClass
public class myInputPanel extends JPanel {
//myInputPanel fields
private JPanel myPanelMissing = null;
private JLabel jLabel_ofPanelMissing = null;
//myInputPanel is added to the mainFrame.
public myInputPanel() {
super();
initialize();
}
private void initialize() {
//a GridBagConstraints is created for each panel i m going to add to myInputPanel
GridBagConstraints gbc6 = new GridBagConstraints();
gbc6.gridx = 6;
gbc6.ipadx = 46;
gbc6.fill = GridBagConstraints.BOTH;
gbc6.insets = new Insets(0, 0, 0, 0);
gbc6.ipady = 0;
gbc6.gridy = 1;
//in a similiar way others gbc are instantiate
//a layout is given to myInputPanel
GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 176, 0, 63, 0, 0, 0, 0, 0, 0, 0};
this.setLayout(gridBagLayout);
this.setSize(1185, 120);
this.setPreferredSize(new Dimension(1164, 143));
this.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
// add others panels to myInputPanel using this.add(getPanel_X(), gridBagConstraintsN);
this.add(getmyPanelMissing(), gridBagConstraints6);
// add others panels to myInputPanel using this.add(getPanel_Y(), gridBagConstraintsM);
}
private JPanel getmyPanelMissing() {
if (myPanelMissing == null) {
//in debug it get inside the if
jLabel_ofPanelMissing = new JLabel();
jLabel_ofPanelMissing.setHorizontalAlignment(SwingConstants.CENTER);
jLabel_ofPanelMissing.setText("<html><body>" +
"<table cellspacing='0';cellpadding='0';> <tr> <td align='center'>Shaft end Dia</td> </tr> <tr> <td align='center'>[mm]</td> </tr></table>" +
"</body></html>");
GridLayout lay = new GridLayout();
lay.setRows(1);
myPanelMissing = new JPanel();
myPanelMissing.setBorder(new SoftBevelBorder(SoftBevelBorder.RAISED));
myPanelMissing.setLayout(lay);
myPanelMissing.add(jLabel_ofPanelMissing, null);
}
return myPanelMissing;
}
}
了我所要做的是:
- 通过我的Eclipse中运行它:失败
通过.bat文件运行的jar:FAIL (FAIL意味着它不会出现)
通过.bat文件在服务器上运行的jar:WORKS
- 由通过CVS下载代码运行通过同事的电脑上日食的jar:WORKS
- 同事的电脑给他上通过蝙蝠运行的jar我的文件:作品
- 通过.bat在同事的计算机上运行jar,并自行编译文件:WORKS
- 评论我的代码上的panelColumn:WORKS !!!!
注: 1)Java版本:1.7.0.75(无论是在矿井PC无论是在我的collegue PC) 2)OS:窗口7 VBOX(无论是我和collegue) 3)Eclipse的月神4。 X(同样再为两个版本)
问题: 有没有人有这样那样的问题? 有关如何解决它的任何想法?
谢谢大家提前!
*“关于如何解决它的主意?” *(可能)修复代码。为了更快地获得更好的帮助,请发布[MCVE](http://stackoverflow.com/help/mcve)(最小完整可验证示例)或[SSCCE](http://www.sscce.org/)(Short,Self Contained ,正确的例子)。 – 2015-02-23 14:30:57
它不能是一个代码问题,否则它会在服务器和我的同事计算机上给出相同的问题,但它不会。 – Koop4 2015-02-23 14:40:27
*“它不可能是一个代码问题” *鬼才。*“否则将给予同样的问题。” *的问题将是随机的,如果核心问题是'null'布局,不要正对GUI代码美国东部时间,设置首选尺寸... – 2015-02-23 14:59:06