You're using a different JFrame in the main method than the one your getter returns.
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
[B][COLOR="red"]private JFrame frame;[/COLOR][/B]
....
});
}
[B][COLOR="#9acd32"]private JFrame frame;[/COLOR][/B]
public JFrame getFrame() {
return frame;
}
}
Better change your class so your code is not inside public static void main.
Try to use the main method just to instantiate classes and start up the whole system. Not to actually do stuff in.
public class Main {
private JFrame frame;
public Main(){
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel("com.jtattoo.plaf.smart.SmartLookAndFeel");
} catch (ClassNotFoundException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnsupportedLookAndFeelException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
Image image = Toolkit.getDefaultToolkit().getImage("\\NYP_logo.png");
frame = new JFrame("Kit");
frame.setIconImage(image);
frame.setSize(698, 500);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
System.setProperty("user.dir", "\\Desktop");
TestFile_Tab descriptor = new TestFile_Tab();
descriptor.testfile_tab();
}
});
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Main main = new Main();
JFrame frame = main.getFrame(); //you got the correct frame here <<--
}
public JFrame getFrame() {
return frame;
}
}