我被指控使用新的软件工具,我正在尝试测试它。
问题: 我注意到我的GUI和服务器上运行的工具的GUI之间存在差异: 一个组件缺失! 就好像它没有显示,因为我进入调试模式,一切似乎都没问题。 这张图片显示了不同的内容:
正如你所看到的," Shaft end Dia"其他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;
}
}
我试图做的是:
通过.bat文件运行jar:FAIL (FAIL意味着它不会出现)
通过.bat文件在服务器上运行jar:WORKS
注意: 1)java版本:1.7.0.75(在我的同事电脑上的我的电脑上) 2)操作系统:Vbox上的窗口7(我和同事) 3)Eclipse Luna 4.x(两者的版本相同)
问题: 有人有过这种问题吗? 关于如何解决它的任何想法?
提前谢谢大家!
答案 0 :(得分:1)
您必须使用方法myInputPanel
setBounds()
的区域