java application GUI responds different after exporting

38 Views Asked by At

My application runs fine on eclipse IDE, but after exporting it, the fame won't repaint. i am trying to rebuild the lay out of JFrame by removing two JPanels and add them again with more panels & here is my code:

the app first calls buildGUI()

 private void buildGUI(){
        setTitle("MyApp");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setContentPane(new BackGroundImagePanel());
        setResizable(false);
        getContentPane().setLayout(new GridBagLayout());
        c = new GridBagConstraints();

        /*
        *set up GridBagConstraints and add the two panels
        */

        pack();
        setSize(700, 700);
        revalidate();
        setLocationRelativeTo(null);
    }

Upon user input do some calculations & call reBuildGUI():

private void reBuildGUI(){
        //Clean the frame.
        remove(firstPanel);
        remove(secondPanel);
        //removeAll() doesn't work for me;
        validate();
        repaint();

        /*
        *set up GridBagConstraints and more panels
        */

        pack();
        setSize(700, 700);
        repaint();
        validate();
}

again, the application work perfict on the IDE but not as stand alone jar, upon calling reBuildGUI() nothing happen ! Tried to use validate(), revalidate() & pack() in different orders with no gain ?

1

There are 1 best solutions below

0
Walid Kilany On

Hovercraft: you was right the code is not enough, sorry but i would paste pages of code and wouldn't be enough to debug this.

here is the troubleshooting: - directing the logger to log into file (using file handler) . - found where the logger stop. - added finer & finest log records till find the bug.

the error was burried far deep inside another class method in this line:

addOnImage = ImageIO.read(getClass().getClassLoader().getResource("images/AddTextOn.png"));

the actual file name was "ADDTextOn.png" but Eclipse was able to read it as "AddTextOn.png" while the JRE wasn't, but nothing was happening to indicate any errors, the program was just do nothing.