E' la giusta punizio per aver usato Java![]()
Vabbè una volta risolta sta cosa non dovrei avere più ostacoli![]()
I'm no hero. Never was. Never will be.
-----
Soul of the mind, key to life's ether
Soul of the lost, withdrawn from its vessel
May strength be granted so the world might be mended...
So the world might be mended...
Mi spieghi per favore qual è il senso positivo di "ingegnere medio"?
Poi vedo se è il caso di insultarti o no
Cmq Axet io non posso aiutarti mi dispiace, swing l'ho usato solo in univ e poi l'ho allegramente dimenticato, sviluppo solo per web app
(in effetti potevi dirgli che gli facevi una web app, così dovevi curargli il doppio della manutenzione, l'app e il web servergli imponevi un po' di vincoli tipo IE only o FF only e poi li vedevi felici quando aprivano il loro browser tutto sbrilluccicoso con img e link per accedere ai loro dati
)
Tanek™: Game Designer & Algorithm Mastermind, Team Leader & SW Engineer and Dungeon Master!
"Datte Foco"™ and "Ma KITTESENCULA"™ are registered trademarks of Tanek Entertainment Inc.
"One of these days, scientists will discover that second X chromosome contains nothing but nonsense and twaddle." - Sheldon Cooper
Per non dimenticare:Spoiler
hdr.
bnet profile
Il problema che una finestra è persistente, ogni classe che estende jframe è un loop continuo quindi non posso controllare da fuori t_T spe allego il codice della classe magari aiuta (tanto non ho fatto un cazzo inerentemente all'aprire una nuova finestra :O)
import java.awt.Toolkit;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.JLabel;
public class Connect_GUI extends JFrame{
/**
*
*/
private static final long serialVersionUID = 1L;
private Toolkit toolkit;
public Connect_GUI(){
setSize(400, 300);
setTitle("Autenticazione a Cedri.. ");
setDefaultCloseOperation(EXIT_ON_CLOSE);
toolkit = getToolkit();
Dimension size = toolkit.getScreenSize();
setLocation(size.width/2 - getWidth()/2, size.height/2 - getHeight()/2);
final JTextField user_text = new JTextField();
final JPasswordField pass_text = new JPasswordField();
final JPanel panel = new JPanel(new BorderLayout());
getContentPane().add(panel);
panel.setLayout(null);
JLabel user_label = new JLabel("User:");
user_label.setBounds(80, 60, 50, 30);
user_text.setBounds(150, 60, 150, 30);
JLabel pass_label = new JLabel("Pass:");
pass_label.setBounds(80, 100, 50, 30);
pass_text.setBounds(150, 100, 150, 30);
JButton connetti = new JButton("Connetti");
connetti.setToolTipText("Premere per connettersi al DB");
connetti.setBounds(150, 150, 150, 30);
connetti.addActionListener(new ActionListener() {
@SuppressWarnings("deprecation")
public void actionPerformed(ActionEvent event){
String user = null, pass = null;
user = user_text.getText();
pass = pass_text.getText();
boolean ctrl;
if(user != null && pass != null)
{
ctrl = Connect.connessione(user, "");
if(ctrl == true){
JOptionPane.showMessageDialog(panel, "Autenticazione effettuata");
}
else
JOptionPane.showMessageDialog(panel, "Errore durante l'autenticazione");
}
}
});
panel.add(connetti);
panel.add(user_label);
panel.add(user_text);
panel.add(pass_label);
panel.add(pass_text);
WindowDestroyer listener = new WindowDestroyer();
addWindowListener(listener);
}
}
I'm no hero. Never was. Never will be.
-----
Soul of the mind, key to life's ether
Soul of the lost, withdrawn from its vessel
May strength be granted so the world might be mended...
So the world might be mended...
Once upon a time@DAoC
Evildark, Mercenario Unicorn Knight
http://www.dixan.it/it/dixan-sempre-con-te.html
Minchia tra tutti gli informatici di sto forum possibile che nessuno conosca un po' di swing a livello "avanzato"?![]()
I'm no hero. Never was. Never will be.
-----
Soul of the mind, key to life's ether
Soul of the lost, withdrawn from its vessel
May strength be granted so the world might be mended...
So the world might be mended...
Ora non si capisce, il tuo problema è non riuscire a chiudere o non appaiono le nuove finestre ?
Provo a darti una mano ma è solo un tentativo.
Se non riesci a chiuderla prova dall'esterno del window listener (dovresti avere un thread del main non credo serva un thread apposta), puoi provare dispose oppure usi processWindowEvent. Chiudere una finestra dall'interno del listener può portare a un loop se si manda un evento di WINDOW_CLOSING.
Magari non serve a un cazzo quello che ho scritto ma c'ho provato
Ovvio se non hai nessun'altro thread attivo(incluso il main) e chiudi l'unico jframe aperto la jvm potrebbe anche terminare, cioè se fai dispose all'interno del jframe e poi vuoi creare un nuovo jframe dopo.. probabilmente a quel codice non ci si arriva mai.
Waiting for nothing
AKA Ganondorf - Lista giochi giocati dal 97 a oggi in spoiler :
Spoiler
"Chi non sa fare la guerra, molto difficilmente può fare la pace"
Playing Starcraft 2
Se uso il metodo dispose dall'interno della classe che estende jframe non succede un tubo (testato, ma magari ho sbagliato qualcosa io).
Btw io uso già un "windowdestroyer" e la finestra me la chiude se viene "triggerato" l'evento di chiusura della finestra (come il premere l'icona X in alto a destra o la pressione di un jbutton settato per la chiusura della finestra).. il problema è che per quello che devo fare io non posso fare una cosa del genere.
Btw durante questo stato di ebrezza post-sabato sera mi è venuta un'idea, domani provo ad implementarla sperando di non dimenticarmi![]()
I'm no hero. Never was. Never will be.
-----
Soul of the mind, key to life's ether
Soul of the lost, withdrawn from its vessel
May strength be granted so the world might be mended...
So the world might be mended...
Waiting for nothing
AKA Ganondorf - Lista giochi giocati dal 97 a oggi in spoiler :
Spoiler
"Chi non sa fare la guerra, molto difficilmente può fare la pace"
Playing Starcraft 2
Saro' generico:
Per ogni evento piu' o meno esistente in Swing, c'e' l'interfaccia apposita. Implementi l'apposita interfaccia (es: ActionListener), e registri il listener dell'evento nel container dove l'evento e' prodotto (JFrame, JPanel etc).
Lo stesso container puo' implementare tali interfacce.... a te e' richiesto definire i metodi relativi a tali interfacce, che vengono poi chiamati durante la notifica dell'evento.
Esempio:
public class ClosingFrame extends JFrame implements WindowListener{
Il listener di cui devi implementare l'interfaccia e' WindowListener.
ora devi registrare il listener...
lo fai cosi':
this.addWindowListener(this);
Si capisci bene questa classe che estende JFrame e' listener di se stesso.
al che:
public void windowClosed(WindowEvent e){
/// QUI CI CREI IL NUOVO FRAME
JFrame miinchia = new JFrame("PER LE PALLE DI DESCARTES !!!");
}
Dovrebbe essere la soluzione ai tuoi problemi.
Ma va?
Io voglio creare un nuovo jframe, diverso da quello che vado a chiudere, quindi non c'è necessità di dichiarare tutto nella stessa classe.
Come si vede anche dal codice che ho postato, la classe che estende windowadapter l'ho dichiarata a se.
Cmq come dicevo ieri sera mi è venuta un'idea, appena mi passa il mal di testa provo![]()
I'm no hero. Never was. Never will be.
-----
Soul of the mind, key to life's ether
Soul of the lost, withdrawn from its vessel
May strength be granted so the world might be mended...
So the world might be mended...
io continuo a non capire cosa vuoi fare ma fa niente... scusa ma se hai jFrame1 e jFrame2 non capisco quale sia il problema di chiamare il setVisible del 2 sull'azione di chiusura dell'1...
fatto in 2 secondi con l'edito di rsa... non conosco swing quindi non se se set visible vada bene o c'è modo di killarlo del tutto (se setvisible non lo faccia da sè), dimmi tu. Copiaincolla e runnalo
(devo studiare reverse... ne ho talmente voglia che piuttosto mi son mezzo a giocare con i problemi di axetCode:import java.awt.event.KeyEvent; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.Event; import java.awt.BorderLayout; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.KeyStroke; import java.awt.Point; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JMenuItem; import javax.swing.JMenuBar; import javax.swing.JMenu; import javax.swing.JFrame; import javax.swing.JDialog; import javax.swing.JDesktopPane; import javax.swing.JButton; import java.awt.Rectangle; import java.awt.Dimension; public class Bella { private JFrame jFrame = null; private JPanel jContentPane = null; private JMenuBar jJMenuBar = null; private JMenu fileMenu = null; private JMenu editMenu = null; private JMenu helpMenu = null; private JMenuItem exitMenuItem = null; private JMenuItem aboutMenuItem = null; private JMenuItem cutMenuItem = null; private JMenuItem copyMenuItem = null; private JMenuItem pasteMenuItem = null; private JMenuItem saveMenuItem = null; private JDialog aboutDialog = null; private JPanel aboutContentPane = null; private JLabel aboutVersionLabel = null; private JDesktopPane jDesktopPane = null; private JButton jButton = null; private JFrame jFrame1 = null; // @jve:decl-index=0:visual-constraint="418,16" private JPanel jContentPane1 = null; private JDesktopPane jDesktopPane1 = null; private JButton jButton1 = null; /** * This method initializes jFrame * * @return javax.swing.JFrame */ private JFrame getJFrame() { if (jFrame == null) { jFrame = new JFrame(); jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jFrame.setJMenuBar(getJJMenuBar()); jFrame.setSize(300, 200); jFrame.setContentPane(getJContentPane()); jFrame.setTitle("Application"); } return jFrame; } /** * This method initializes jContentPane * * @return javax.swing.JPanel */ private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(new BorderLayout()); jContentPane.add(getJDesktopPane(), BorderLayout.CENTER); } return jContentPane; } /** * This method initializes jJMenuBar * * @return javax.swing.JMenuBar */ private JMenuBar getJJMenuBar() { if (jJMenuBar == null) { jJMenuBar = new JMenuBar(); jJMenuBar.add(getFileMenu()); jJMenuBar.add(getEditMenu()); jJMenuBar.add(getHelpMenu()); } return jJMenuBar; } /** * This method initializes jMenu * * @return javax.swing.JMenu */ private JMenu getFileMenu() { if (fileMenu == null) { fileMenu = new JMenu(); fileMenu.setText("File"); fileMenu.add(getSaveMenuItem()); fileMenu.add(getExitMenuItem()); } return fileMenu; } /** * This method initializes jMenu * * @return javax.swing.JMenu */ private JMenu getEditMenu() { if (editMenu == null) { editMenu = new JMenu(); editMenu.setText("Edit"); editMenu.add(getCutMenuItem()); editMenu.add(getCopyMenuItem()); editMenu.add(getPasteMenuItem()); } return editMenu; } /** * This method initializes jMenu * * @return javax.swing.JMenu */ private JMenu getHelpMenu() { if (helpMenu == null) { helpMenu = new JMenu(); helpMenu.setText("Help"); helpMenu.add(getAboutMenuItem()); } return helpMenu; } /** * This method initializes jMenuItem * * @return javax.swing.JMenuItem */ private JMenuItem getExitMenuItem() { if (exitMenuItem == null) { exitMenuItem = new JMenuItem(); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); } return exitMenuItem; } /** * This method initializes jMenuItem * * @return javax.swing.JMenuItem */ private JMenuItem getAboutMenuItem() { if (aboutMenuItem == null) { aboutMenuItem = new JMenuItem(); aboutMenuItem.setText("About"); aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JDialog aboutDialog = getAboutDialog(); aboutDialog.pack(); Point loc = getJFrame().getLocation(); loc.translate(20, 20); aboutDialog.setLocation(loc); aboutDialog.setVisible(true); } }); } return aboutMenuItem; } /** * This method initializes aboutDialog * * @return javax.swing.JDialog */ private JDialog getAboutDialog() { if (aboutDialog == null) { aboutDialog = new JDialog(getJFrame(), true); aboutDialog.setTitle("About"); aboutDialog.setContentPane(getAboutContentPane()); } return aboutDialog; } /** * This method initializes aboutContentPane * * @return javax.swing.JPanel */ private JPanel getAboutContentPane() { if (aboutContentPane == null) { aboutContentPane = new JPanel(); aboutContentPane.setLayout(new BorderLayout()); aboutContentPane.add(getAboutVersionLabel(), BorderLayout.CENTER); } return aboutContentPane; } /** * This method initializes aboutVersionLabel * * @return javax.swing.JLabel */ private JLabel getAboutVersionLabel() { if (aboutVersionLabel == null) { aboutVersionLabel = new JLabel(); aboutVersionLabel.setText("Version 1.0"); aboutVersionLabel.setHorizontalAlignment(SwingConstants.CENTER); } return aboutVersionLabel; } /** * This method initializes jMenuItem * * @return javax.swing.JMenuItem */ private JMenuItem getCutMenuItem() { if (cutMenuItem == null) { cutMenuItem = new JMenuItem(); cutMenuItem.setText("Cut"); cutMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK, true)); } return cutMenuItem; } /** * This method initializes jMenuItem * * @return javax.swing.JMenuItem */ private JMenuItem getCopyMenuItem() { if (copyMenuItem == null) { copyMenuItem = new JMenuItem(); copyMenuItem.setText("Copy"); copyMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK, true)); } return copyMenuItem; } /** * This method initializes jMenuItem * * @return javax.swing.JMenuItem */ private JMenuItem getPasteMenuItem() { if (pasteMenuItem == null) { pasteMenuItem = new JMenuItem(); pasteMenuItem.setText("Paste"); pasteMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK, true)); } return pasteMenuItem; } /** * This method initializes jMenuItem * * @return javax.swing.JMenuItem */ private JMenuItem getSaveMenuItem() { if (saveMenuItem == null) { saveMenuItem = new JMenuItem(); saveMenuItem.setText("Save"); saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK, true)); } return saveMenuItem; } /** * This method initializes jDesktopPane * * @return javax.swing.JDesktopPane */ private JDesktopPane getJDesktopPane() { if (jDesktopPane == null) { jDesktopPane = new JDesktopPane(); jDesktopPane.add(getJButton(), null); } return jDesktopPane; } /** * This method initializes jButton * * @return javax.swing.JButton */ private JButton getJButton() { if (jButton == null) { jButton = new JButton(); jButton.setBounds(new Rectangle(56, 27, 173, 96)); jButton.setText("BUSONE"); } return jButton; } /** * This method initializes jFrame1 * * @return javax.swing.JFrame */ private JFrame getJFrame1() { if (jFrame1 == null) { jFrame1 = new JFrame(); jFrame1.setSize(new Dimension(280, 189)); jFrame1.setContentPane(getJContentPane1()); } return jFrame1; } /** * This method initializes jContentPane1 * * @return javax.swing.JPanel */ private JPanel getJContentPane1() { if (jContentPane1 == null) { jContentPane1 = new JPanel(); jContentPane1.setLayout(new BorderLayout()); jContentPane1.add(getJDesktopPane1(), BorderLayout.CENTER); } return jContentPane1; } /** * This method initializes jDesktopPane1 * * @return javax.swing.JDesktopPane */ private JDesktopPane getJDesktopPane1() { if (jDesktopPane1 == null) { jDesktopPane1 = new JDesktopPane(); jDesktopPane1.add(getJButton1(), null); } return jDesktopPane1; } /** * This method initializes jButton1 * * @return javax.swing.JButton */ private JButton getJButton1() { if (jButton1 == null) { jButton1 = new JButton(); jButton1.setBounds(new Rectangle(52, 18, 174, 113)); jButton1.setText("AXET"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { getJFrame1().setVisible(false); getJFrame().setVisible(true); } }); } return jButton1; } /** * Launches this application */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { Bella application = new Bella(); application.getJFrame1().setVisible(true); } }); } })
Last edited by Hador; 12th July 2009 at 11:39.
hdr.
bnet profile