1

Here while I run java project in netbeans all things are working okay. But after they are built there is not any item added in combobox as it works during netbeans run. The sample code is given below.

First Login JFrame

 public class Login_Frame extends javax.swing.JFrame {

 welcome w = new welcome();     

 public Login_Frame() {
    initComponents();
 }

 //button action perform event for dispose this window and open new welcome window

 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {  

 .
 .
 w.setVisible(true);
 this.dispose();
 .
 .

 }
 }

Second JFrame

  public final class welcome extends javax.swing.JFrame {

    // comboitem is class in which method for adding item in combobox from sqlite 
       db is declared 

    comboitem c = new comboitem();

   // textclass is class in which method for changing lowercase text entered in
       text to uppercase is declared

    textclass tc = new textclass();

    public welcome() {

    // while I try to run the project using netbeans run project option 
    // logincall() method initialized and work fine.

Problem After project built when I try to run the jar file from the cmd. it runs without any error but logincall() method doesn't work or may be not initialized.

    initComponents();
    logincall();
    .
    .
    }

    public void logincall(){

 //Remarks    
 //tc.uppercase() method is working fine after built. But other c.but_stn() like
 // doen't.while during running project through netbeans all thing working fine. 

    c.bus_stn();
    c.bus_trl();
    c.inq_stn(); 
    c.editframe();
    c.userlist();
    c.editTrainStation();
    c.editFlightStation();
    c.flightFlight();
    c.pickupstand();
    tc.uppercase();

}

I didn't know what is wrong with it. I searched on google but didn't find any proper answer. There also any error showing up in netbeans. Please fill free to ask any questions if more information is needed. I appreciate all your replies.

This is my Welcome Main class's main method.

public static void main(String args[]) {
   ... 
   look and feel auto generated code
   ....

    java.awt.EventQueue.invokeLater(new Runnable() {

           public void run() {

            new welcome().setVisible(true);
        }
    });
}
  • I'll take a shot into the blue and blame the DB. You'll use a different one when running in Netbeans from when running "Standalone", right? I suspect there are no entries in the "non-netbeans" DB. Do you write some debug-log so you can see, with how many results from the db the Combobox shall be filled? – Fildor Aug 22 '14 at 10:06
  • 1) For better help sooner, post an [MCVE](http://stackoverflow.com/help/mcve) (Minimal, Complete, Verifiable Example). 2) See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) – Andrew Thompson Aug 22 '14 at 10:36
  • Hi @Fildor thank you for reply. I have entered the data in db. When I run the project in netbeans. Items are displayed in combobox. But after built when I run jar file There no such item displayed in combobox. – user3805446 Aug 22 '14 at 12:22
  • Hi @AndrewThompson thank you for your fast reply. I described problem in more detail. If it's still not sufficient please let me know.I have very long code and multiple classes which may be not possible to display. – user3805446 Aug 22 '14 at 12:25
  • *"If it's still not sufficient please let me know."* 'Sufficient' is an MCVE. Uncompilable code snippets are not an MCVE (neither is 'all your code'). – Andrew Thompson Aug 22 '14 at 17:12

1 Answers1

0

A couple of things that might be an issue here:

1) Are you running your GUI on the EventDispatchThread? this is mandatory for java swing GUI to be able to work properly. The main reason for this is concurrency. Details here.

2) Are you re-rendering your combobox? it is important that you do this because changes to GUI elements may not be immediately shown.

3) What Database are you using? in order to determine if the fault lies in the code or the DB you could write a test using static data, if it loads in the IDE and outside of it chances are that your code is correct but the DB isn't

MSB
  • 854
  • 7
  • 24
  • Hi MSB Thank you for fast reply. As I understand yes I am running my gui on EventDispatch Thread. But still for conformation I am adding my welcome class's main method in my question. Please look at it and suggest me what should I do – user3805446 Aug 22 '14 at 13:29
  • A suggestion to not only help me but others understand your problem better is an MCVE as mentioned by others. Build a simple barebones GUI with the combobox and populate is as you are doing now, then post THAT code. This will isolate the problem much faster. – MSB Aug 28 '14 at 10:13
  • Hi MSB, problem is sloved. Thank you. – user3805446 Sep 02 '14 at 13:32
  • I think you would help others greatly if you inform us about what eventually was the cause of your problem and how you fixed it. This way your question can be used for future reference. – MSB Sep 12 '14 at 08:36