How to call the run method from another class?

How to call the run method from another class?

Sorry, if this is a stupid question.

I would like to find out how to call the run method that is located in

java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new FereastraPrincipala().setVisible(true); from the class

The run method is declared in and I want to call this from, so that changes can be seen to FereastraPrincipala after introducing values in the textfields from If I don't call a method, then I have to run again, in order to see the new info in the JTabbedPane.

Here is the code for

package sakila.ui;

 import java.util.List;
 import java.util.Vector;
 import javax.swing.table.DefaultTableModel;
 import org.hibernate.Session;
 import sakila.entity.*;
 import sakila.util.HibernateUtil;

public class FereastraPrincipala extends javax.swing.JFrame {

public FereastraPrincipala() {

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
    AdaugaComanda ac = new AdaugaComanda();

public static void main(String args[]) {

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

        public void run() {
            new FereastraPrincipala().setVisible(true);
            Session session = HibernateUtil.getSessionFactory().openSession();


    List<Comanda> comenzi = session.createQuery("from Comanda").list();

    Vector<String> tableHeaders = new Vector<String>();
    Vector tableData = new Vector();
    tableHeaders.add("Unit de mas");

    for (Comanda comanda : comenzi) {
        Vector <Object> oneRow = new Vector <Object>();
        oneRow.add(comanda.getDepozit() == null ? "" : comanda.getDepozit().toString());
        oneRow.add(comanda.getFurnizor() == null ? "" : comanda.getFurnizor().toString());
        oneRow.add(comanda.getClient() == null ? "" : comanda.getClient().toString());
        oneRow.add(comanda.getProdus() == null ? "" : comanda.getProdus().toString());


   ComandaTable.setModel(new DefaultTableModel(tableData, tableHeaders));    

       }catch (Exception he){

Here is the code for

package sakila.ui;

  import java.util.List;
  import sakila.entity.*;
  import sakila.service.Functie;
  import sakila.entity.Client;

 public class AdaugaComanda extends javax.swing.JDialog {

public AdaugaComanda() {

   private void initComboBoxes() {


    System.out.println("sterge itemurile");

    List<Depozit> depozite = (List<Depozit>) sakila.client.Client.citeste(Functie.LISTEAZA_DEPOZITE);
    for (Depozit depozit : depozite)

    List<Furnizor> furnizori = (List<Furnizor>) sakila.client.Client.citeste(Functie.LISTEAZA_FURNIZORI);
    for (Furnizor furnizor : furnizori)

    List<Client> clienti = (List<Client>) sakila.client.Client.citeste(Functie.LISTEAZA_CLIENTI);
    for (Client client : clienti)

    List<Produs> produse = (List<Produs>) sakila.client.Client.citeste(Functie.LISTEAZA_PRODUSE);
    for (Produs produs : produse)


private void ClientComboBoxActionPerformed(java.awt.event.ActionEvent evt) {                                               
    // TODO add your handling code here:

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

 private void runQueryBasedOnInsert(){

    Comanda comanda = new Comanda();

    Depozit depozit = (Depozit)DepozitComboBox.getSelectedItem();

    Furnizor furnizor = ((Furnizor)FurnizorComboBox.getSelectedItem());

    sakila.entity.Client client = ((sakila.entity.Client)ClientComboBox.getSelectedItem());

    Produs produs = ((Produs)ProdusComboBox.getSelectedItem());


    sakila.client.Client.scrie(Functie.CREAZA_COMANDA, comanda);

 public static void main(String args[]) {

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

        public void run() {
            new AdaugaComanda().setVisible(true);

Maybe someone could help me. Thank you a lot!

View Answers

Related Tutorials/Questions & Answers:
How to call the run method from another class?
How to pass variable from one class to another in java
how to open one Jframe from main method call
how to call static method
how to call static method
how to call static method
how to call static method
how to call static method
how to call static method
how to pass a string from one class to another
Java call method from another class
how to call ejb with in another ejb - EJB
How to call java method on Button click in jsp?
how to call jsp from flex
how to call jsp from flex
How to make a servlet to automatically call another servlet at some time instant.
how to run a applet from browser
how to create a jar file for my packages classs - Struts
Use varibles from another class
how to call javascript function from flex
how to call from pc to telephone in java - MobileApplications
How to make phone call from web application
ModuleNotFoundError: No module named 'classh'
ModuleNotFoundError: No module named 'classh'
how to use string of one class into another Class
How to forward the control from one jsp to another?
How to navigate from one jsf to another in eclipse
How to run PHP Script from the command line ?
swings:how to link from one form to another form
How to invoke method of a library from command line
how to copy file from one directory to another in java with examples
how can we pass parameters from jsp href to another servlet
how to pass an array from one jsp to another jsp - JSP-Servlet
Call an array from multiple functions
How to Send particular error to another page in Servlet from web.xml
how to call an exe file from java - Java Beginners
How to call jasper from jsp or servlet - JSP-Servlet
how to call the array variable in scriptlet from javascript function
how to call servlet from html page at anchor tag ?
How I call the function union from the main - Java Interview Questions
how to go from one frame to another frame in swings - Java Beginners
how to write function of copy from one to another location in this code
call another computer in LAN (no internet acces)
call from java - JavaMail
How To Pass data from one GUI to another in java swing
Calling another web resources
How to run java swing application from jar files .
how can i run ASP.Net Server from netbeans IDE?
javascript call action class method instruts
Get JTextField value from another class