Netbeans Swing és Command Line Argumentumok

Kezdőlap Fórumok Programozás Netbeans Swing és Command Line Argumentumok

10 bejegyzés megtekintése - 1-10 / 15
  • Szerző
    Bejegyzés
  • #2171455
    lacix
    Felhasználó

      adj egy kis kódrészletet 🙂

      #2171456
      lacix
      Felhasználó

        adj egy kis kódrészletet 🙂

        #2171457
        sz_gergo
        Felhasználó

          Szia Lacix

          Tehát egy GUI Applikációnál a Netbeans (6.1) Két osztályt generál:
          1. A „main” osztály:

          import org.jdesktop.application.Application;
          import org.jdesktop.application.SingleFrameApplication;

          /**
          * The main class of the application.
          */
          public class SDHPortMapper extends SingleFrameApplication {

             /**
              * This method is to initialize the specified window by injecting resources.
              * Windows shown in our application come fully initialized from the GUI
              * builder, so this additional configuration is not needed.
              */
             @Override protected void configureWindow(java.awt.Window root) {
             }

             /**
              * A convenient static getter for the application instance.
              * @return the instance of SDHPortMapper
              */
             public static SDHPortMapper getApplication() {
                 return Application.getInstance(SDHPortMapper.class);
             }

             /**
              * Main method launching the application.
              */
             public static void main(String[] args) {
                 SDHPortMapper.arguments = args;
                 launch(SDHPortMapper.class, args);
             }

           @Override
           protected void startup() {
             show(new SDHPortMapperView(this));
           }
          }

          és a View ( a tulajdonképpeni Form)
          /*
          * SDHPortMapperView.java
          */

          public class SDHPortMapperView extends FrameView {
           
             public SDHPortMapperView(SingleFrameApplication app) {
                 super(app);
           
                 initComponents();

                 // status bar initialization – message timeout, idle icon and busy animation, etc
                 ResourceMap resourceMap = getResourceMap();
                 int messageTimeout = resourceMap.getInteger(„StatusBar.messageTimeout”);
                 messageTimer = new Timer(messageTimeout, new ActionListener() {
                     public void actionPerformed(ActionEvent e) {
                         statusMessageLabel.setText(„”);
                     }
                 });
                 messageTimer.setRepeats(false);
                 int busyAnimationRate = resourceMap.getInteger(„StatusBar.busyAnimationRate”);
                 for (int i = 0; i                          
           private void initComponents() {

             mainPanel = new javax.swing.JPanel();
             jPanel1 = new javax.swing.JPanel();
             jLabel1 = new javax.swing.JLabel();
             jLabel2 = new javax.swing.JLabel();
             jComboBox1 = new javax.swing.JComboBox();
             jLabel3 = new javax.swing.JLabel();
             jLabel4 = new javax.swing.JLabel();
             jLabel5 = new javax.swing.JLabel();
             jCheckBox1 = new javax.swing.JCheckBox();
             jPanel2 = new javax.swing.JPanel();
             jLabel6 = new javax.swing.JLabel();
             jLabel7 = new javax.swing.JLabel();
             jScrollPane1 = new javax.swing.JScrollPane();
             jList1 = new javax.swing.JList();
             jLabel8 = new javax.swing.JLabel();
             jLabel9 = new javax.swing.JLabel();
             jScrollPane2 = new javax.swing.JScrollPane();
             jTextArea1 = new javax.swing.JTextArea();
             menuBar = new javax.swing.JMenuBar();
             javax.swing.JMenu fileMenu = new javax.swing.JMenu();
             javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
             javax.swing.JMenu helpMenu = new javax.swing.JMenu();
             javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
             statusPanel = new javax.swing.JPanel();
             javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
             statusMessageLabel = new javax.swing.JLabel();
             statusAnimationLabel = new javax.swing.JLabel();
             progressBar = new javax.swing.JProgressBar();
             jButton3 = new javax.swing.JButton();
             jButton4 = new javax.swing.JButton();

             mainPanel.setName(„mainPanel”); // NOI18N

             jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
             jPanel1.setName(„jPanel1”); // NOI18N

          Ablak rajzolási kommandók…… sajnos nem lehetett mind elkuldeni 🙁

           // Variables declaration – do not modify                    
           private javax.swing.JButton jButton3;
           private javax.swing.JButton jButton4;
           private javax.swing.JCheckBox jCheckBox1;
           private javax.swing.JComboBox jComboBox1;
           private javax.swing.JLabel jLabel1;
           private javax.swing.JLabel jLabel2;
           private javax.swing.JLabel jLabel3;
           private javax.swing.JLabel jLabel4;
           private javax.swing.JLabel jLabel5;
           private javax.swing.JLabel jLabel6;
           private javax.swing.JLabel jLabel7;
           private javax.swing.JLabel jLabel8;
           private javax.swing.JLabel jLabel9;
           private javax.swing.JList jList1;
           private javax.swing.JPanel jPanel1;
           private javax.swing.JPanel jPanel2;
           private javax.swing.JScrollPane jScrollPane1;
           private javax.swing.JScrollPane jScrollPane2;
           private javax.swing.JTextArea jTextArea1;
           private javax.swing.JPanel mainPanel;
           private javax.swing.JMenuBar menuBar;
           private javax.swing.JProgressBar progressBar;
           private javax.swing.JLabel statusAnimationLabel;
           private javax.swing.JLabel statusMessageLabel;
           private javax.swing.JPanel statusPanel;
           // End of variables declaration                  

             private final Timer messageTimer;
             private final Timer busyIconTimer;
             private final Icon idleIcon;
             private final Icon[] busyIcons = new Icon[15];
             private int busyIconIndex = 0;

             private JDialog aboutBox;
          }

          Ezeket kellene valahogy úgy összehozni, hogy a „view” -ban el tudjam érni az „args” -ot. De sehogysem sikerul.
          Probáltam már az args -ot berakni private válltozóba  és getterrel elérni, de az sem ment.

          A neten sem foglalkoznak ezzel. Vagy mert annyira triviális , vagy mert nem használnak Command Line Argumentumot egy GUI Applikációban.

          Köszi a segítséget.

          Gergö

          #2171458
          sz_gergo
          Felhasználó

            Szia Lacix

            Tehát egy GUI Applikációnál a Netbeans (6.1) Két osztályt generál:
            1. A „main” osztály:

            import org.jdesktop.application.Application;
            import org.jdesktop.application.SingleFrameApplication;

            /**
            * The main class of the application.
            */
            public class SDHPortMapper extends SingleFrameApplication {

               /**
                * This method is to initialize the specified window by injecting resources.
                * Windows shown in our application come fully initialized from the GUI
                * builder, so this additional configuration is not needed.
                */
               @Override protected void configureWindow(java.awt.Window root) {
               }

               /**
                * A convenient static getter for the application instance.
                * @return the instance of SDHPortMapper
                */
               public static SDHPortMapper getApplication() {
                   return Application.getInstance(SDHPortMapper.class);
               }

               /**
                * Main method launching the application.
                */
               public static void main(String[] args) {
                   SDHPortMapper.arguments = args;
                   launch(SDHPortMapper.class, args);
               }

             @Override
             protected void startup() {
               show(new SDHPortMapperView(this));
             }
            }

            és a View ( a tulajdonképpeni Form)
            /*
            * SDHPortMapperView.java
            */

            public class SDHPortMapperView extends FrameView {
             
               public SDHPortMapperView(SingleFrameApplication app) {
                   super(app);
             
                   initComponents();

                   // status bar initialization – message timeout, idle icon and busy animation, etc
                   ResourceMap resourceMap = getResourceMap();
                   int messageTimeout = resourceMap.getInteger(„StatusBar.messageTimeout”);
                   messageTimer = new Timer(messageTimeout, new ActionListener() {
                       public void actionPerformed(ActionEvent e) {
                           statusMessageLabel.setText(„”);
                       }
                   });
                   messageTimer.setRepeats(false);
                   int busyAnimationRate = resourceMap.getInteger(„StatusBar.busyAnimationRate”);
                   for (int i = 0; i                          
             private void initComponents() {

               mainPanel = new javax.swing.JPanel();
               jPanel1 = new javax.swing.JPanel();
               jLabel1 = new javax.swing.JLabel();
               jLabel2 = new javax.swing.JLabel();
               jComboBox1 = new javax.swing.JComboBox();
               jLabel3 = new javax.swing.JLabel();
               jLabel4 = new javax.swing.JLabel();
               jLabel5 = new javax.swing.JLabel();
               jCheckBox1 = new javax.swing.JCheckBox();
               jPanel2 = new javax.swing.JPanel();
               jLabel6 = new javax.swing.JLabel();
               jLabel7 = new javax.swing.JLabel();
               jScrollPane1 = new javax.swing.JScrollPane();
               jList1 = new javax.swing.JList();
               jLabel8 = new javax.swing.JLabel();
               jLabel9 = new javax.swing.JLabel();
               jScrollPane2 = new javax.swing.JScrollPane();
               jTextArea1 = new javax.swing.JTextArea();
               menuBar = new javax.swing.JMenuBar();
               javax.swing.JMenu fileMenu = new javax.swing.JMenu();
               javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
               javax.swing.JMenu helpMenu = new javax.swing.JMenu();
               javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
               statusPanel = new javax.swing.JPanel();
               javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
               statusMessageLabel = new javax.swing.JLabel();
               statusAnimationLabel = new javax.swing.JLabel();
               progressBar = new javax.swing.JProgressBar();
               jButton3 = new javax.swing.JButton();
               jButton4 = new javax.swing.JButton();

               mainPanel.setName(„mainPanel”); // NOI18N

               jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
               jPanel1.setName(„jPanel1”); // NOI18N

            Ablak rajzolási kommandók…… sajnos nem lehetett mind elkuldeni 🙁

             // Variables declaration – do not modify                    
             private javax.swing.JButton jButton3;
             private javax.swing.JButton jButton4;
             private javax.swing.JCheckBox jCheckBox1;
             private javax.swing.JComboBox jComboBox1;
             private javax.swing.JLabel jLabel1;
             private javax.swing.JLabel jLabel2;
             private javax.swing.JLabel jLabel3;
             private javax.swing.JLabel jLabel4;
             private javax.swing.JLabel jLabel5;
             private javax.swing.JLabel jLabel6;
             private javax.swing.JLabel jLabel7;
             private javax.swing.JLabel jLabel8;
             private javax.swing.JLabel jLabel9;
             private javax.swing.JList jList1;
             private javax.swing.JPanel jPanel1;
             private javax.swing.JPanel jPanel2;
             private javax.swing.JScrollPane jScrollPane1;
             private javax.swing.JScrollPane jScrollPane2;
             private javax.swing.JTextArea jTextArea1;
             private javax.swing.JPanel mainPanel;
             private javax.swing.JMenuBar menuBar;
             private javax.swing.JProgressBar progressBar;
             private javax.swing.JLabel statusAnimationLabel;
             private javax.swing.JLabel statusMessageLabel;
             private javax.swing.JPanel statusPanel;
             // End of variables declaration                  

               private final Timer messageTimer;
               private final Timer busyIconTimer;
               private final Icon idleIcon;
               private final Icon[] busyIcons = new Icon[15];
               private int busyIconIndex = 0;

               private JDialog aboutBox;
            }

            Ezeket kellene valahogy úgy összehozni, hogy a „view” -ban el tudjam érni az „args” -ot. De sehogysem sikerul.
            Probáltam már az args -ot berakni private válltozóba  és getterrel elérni, de az sem ment.

            A neten sem foglalkoznak ezzel. Vagy mert annyira triviális , vagy mert nem használnak Command Line Argumentumot egy GUI Applikációban.

            Köszi a segítséget.

            Gergö

            #2171459
            zoltan22
            Felhasználó

              Esetleg nem lehetne a SDHPortMapperView konstruktoranak parameterkent megadni az args-ot (adni meg egy parametert a konstruktornak)?

              #2171460
              zoltan22
              Felhasználó

                Esetleg nem lehetne a SDHPortMapperView konstruktoranak parameterkent megadni az args-ot (adni meg egy parametert a konstruktornak)?

                #2171461
                lacix
                Felhasználó

                  ezt már nézted?
                  talán a stratup-hoz is kellene egy String[] args

                  ezt szerintem szedd ki:
                  SDHPortMapper.arguments = args;

                  a SDHPortMapperView-ben hogy próbálod elérni az args-ot?

                  #2171462
                  lacix
                  Felhasználó

                    ezt már nézted?
                    talán a stratup-hoz is kellene egy String[] args

                    ezt szerintem szedd ki:
                    SDHPortMapper.arguments = args;

                    a SDHPortMapperView-ben hogy próbálod elérni az args-ot?

                    #2171463
                    sz_gergo
                    Felhasználó

                      Szia Zoli

                      a kérdésedre :
                      Esetleg nem lehetne a SDHPortMapperView konstruktoranak parameterkent megadni az args-ot (adni meg egy parametert a konstruktornak)?

                      De lehetne adni, meg is próbáltam, csakhogy az SDHPortMapper csak a default Kontsruktort hajlando meghivni. Ha itt válltoztatok , akkor meg ugat nem frankó a dolog.

                      Laci:
                      Csináltam már String[] args -os startupot is. Csakhogy azt meg a launch nem hajlando meghívi :(.
                      Ha kiveszem az args-ot egy Pivate válltozóba, akkor az SDHMapperView-ban az app.get…….. -el probalom kivenni, de a get metódust nem látja. Nem tudom , hogy miért, ugyanis a Startup methódus átadja az egész osztályt (SDHPortMapper) a this keyworddel. Innetől kezdve nem értem, hogy miafaszért nincsen benne az én getterem .

                      Egyéb ötlet ??

                      Gergő

                      #2171464
                      sz_gergo
                      Felhasználó

                        Szia Zoli

                        a kérdésedre :
                        Esetleg nem lehetne a SDHPortMapperView konstruktoranak parameterkent megadni az args-ot (adni meg egy parametert a konstruktornak)?

                        De lehetne adni, meg is próbáltam, csakhogy az SDHPortMapper csak a default Kontsruktort hajlando meghivni. Ha itt válltoztatok , akkor meg ugat nem frankó a dolog.

                        Laci:
                        Csináltam már String[] args -os startupot is. Csakhogy azt meg a launch nem hajlando meghívi :(.
                        Ha kiveszem az args-ot egy Pivate válltozóba, akkor az SDHMapperView-ban az app.get…….. -el probalom kivenni, de a get metódust nem látja. Nem tudom , hogy miért, ugyanis a Startup methódus átadja az egész osztályt (SDHPortMapper) a this keyworddel. Innetől kezdve nem értem, hogy miafaszért nincsen benne az én getterem .

                        Egyéb ötlet ??

                        Gergő

                      10 bejegyzés megtekintése - 1-10 / 15
                      • Be kell jelentkezni a hozzászóláshoz.