1

i've been charged with a new software tool, and i m trying to test it.

PROBLEM: I noticed a difference between mine GUI and the GUI of the tool run on the server: a component is missing! It is like if it's not shown, because i went in debug mode, and everything seems to be fine. this image shows the different:

different

as you can see, the "Shaft end Dia" component is missing between the others 2 components.

CODE: here is a code part. There are lots of items that get instantiate and added in the same way, but it doesn't apper on my pc (but they works well in others!!)

//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;
}

}

What i tried to do is:

  1. running it via my Eclipse: FAIL
  2. running the jar via .bat file: FAIL (FAIL means it doesn't appear)

  3. running the jar on the server via .bat file: WORKS

  4. running the jar via eclipse on a colleague's computer by downloading the code via cvs: WORKS
  5. running the jar via .bat on colleague's computer giving him my files: WORKS
  6. running the jar via .bat on colleague's computer with files compiled by himself: WORKS
  7. commenting the previous panelColumn on my code: WORKS!!!!

NOTE: 1) java version: 1.7.0.75 (either on mine pc either on my collegue pc) 2) OS: window 7 on Vbox (either me and collegue) 3) Eclipse Luna 4.x (same version again for both)

QUESTION: Has anyone had this kind of problems? Any idea about how to solve it?

Thank you all in advance!

Robdll
  • 5,865
  • 7
  • 31
  • 51
  • 1
    *"Any idea about how to solve it?"* (Probably) fix the code. For better help sooner, post an [MCVE](http://stackoverflow.com/help/mcve) (Minimal Complete Verifiable Example) or [SSCCE](http://www.sscce.org/) (Short, Self Contained, Correct Example). – Andrew Thompson Feb 23 '15 at 14:30
  • it cannot be a code problem, otherwise it would give the same problem on server and on my colleague computer but it doesn't. – Robdll Feb 23 '15 at 14:40
  • 1
    *"it cannot be a code problem"* Famous last words.. *"otherwise it would give the same problem.."* The problems will be random if the core problem is `null` layouts, GUI code not being on the EDT, setting preferred sizes ... – Andrew Thompson Feb 23 '15 at 14:59
  • i didn't get what your trying to communicate. But if you want to waste time on a working code, let do it, i m gonna post you the code flow in a row. – Robdll Feb 23 '15 at 15:08
  • 1
    You still haven't post an `MCVE` or 'SSCCE` so we can't help. – camickr Feb 23 '15 at 16:18
  • fortunally you are not the whole community, so, put this "we" where you preffer. I m gonna post a MCVE soon for those who wants to help me out. – Robdll Feb 23 '15 at 16:26

1 Answers1

1

You must increase the area of the your panel myInputPanel with the method setBounds()

HRM
  • 2,097
  • 6
  • 23
  • 37
frank
  • 34
  • 2
  • Thank you very much, you found the problem! The father component wasn't big enough to show everything, increasing the size of it has solved the problem! – Robdll Feb 24 '15 at 12:51
  • See [Should I avoid the use of set(Preferred|Maximum|Minimum)Size methods in Java Swing?](http://stackoverflow.com/q/7229226/418556) (Yes.) That advice applies doubly to `setSize(..)`. – Andrew Thompson Feb 27 '15 at 01:23