Kezdőlap › Fórumok › Programozás › Netbeans Swing és Command Line Argumentumok
- This topic has 14 hozzászólás, 4 résztvevő, and was last updated 16 years, 9 months telt el by
sz_gergo.
-
SzerzőBejegyzés
-
2008-08-27-10:28 #2171455
adj egy kis kódrészletet 🙂
2008-08-27-10:28 #2171456adj egy kis kódrészletet 🙂
2008-08-28-09:40 #2171457Szia 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”); // NOI18NAblak 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 declarationprivate 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ö
2008-08-28-09:40 #2171458Szia 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”); // NOI18NAblak 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 declarationprivate 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ö
2008-08-28-11:34 #2171459Esetleg nem lehetne a SDHPortMapperView konstruktoranak parameterkent megadni az args-ot (adni meg egy parametert a konstruktornak)?
2008-08-28-11:34 #2171460Esetleg nem lehetne a SDHPortMapperView konstruktoranak parameterkent megadni az args-ot (adni meg egy parametert a konstruktornak)?
2008-08-28-12:33 #2171461ezt már nézted?
talán a stratup-hoz is kellene egy String[] argsezt szerintem szedd ki:
SDHPortMapper.arguments = args;a SDHPortMapperView-ben hogy próbálod elérni az args-ot?
2008-08-28-12:33 #2171462ezt már nézted?
talán a stratup-hoz is kellene egy String[] argsezt szerintem szedd ki:
SDHPortMapper.arguments = args;a SDHPortMapperView-ben hogy próbálod elérni az args-ot?
2008-08-29-08:47 #2171463Szia 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ő
2008-08-29-08:47 #2171464Szia 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ő
-
SzerzőBejegyzés
- Be kell jelentkezni a hozzászóláshoz.
legutóbbi hsz