ho creato una finestra per l'about, che viene aperta quando viene cliccato l'apposito pulsante, solo che la finestra che viene lanciata sta in alto a sinistra e vorrei metterla al centro dello schermo, sapete dirmi come posso fare?
il codice della finestra è:
e lancio la finestra (dalla schermata principale) così:codice:package video.client; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import oracle.jdeveloper.layout.XYConstraints; import oracle.jdeveloper.layout.XYLayout; public class InfoAboutPanel { private XYLayout xyLayout = new XYLayout(); public static final int LARGHEZZA = 250; public static final int ALTEZZA = 210; public InfoAboutPanel() { JFrame window = new JFrame("About"); window.setLayout( xyLayout ); window.setBounds(0,0,LARGHEZZA,ALTEZZA); JLabel jLabel1 = new JLabel("Progetto sviluppato da:"); JLabel jLabel2 = new JLabel("aaa"); JLabel jLabel3 = new JLabel("bbb"); JLabel jLabel4 = new JLabel("ccc"); window.add(jLabel1, new XYConstraints(20, 20, -1, -1)); window.add(jLabel2, new XYConstraints(20, 55, -1, -1)); window.add(jLabel3, new XYConstraints(20, 75, -1, -1)); window.add(jLabel4, new XYConstraints(20, 95, -1, -1)); JButton jButton = new JButton("OK"); jButton.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent ae ) { AboutExit_ActionPerformed( ae ); } } ); window.add(jButton, new XYConstraints(95, 130, -1, -1)); window.setVisible(true); } void AboutExit_ActionPerformed(ActionEvent e) { System.exit(0); } }
come faccio a centrarla?codice:InfoAboutPanel panelInfoAbout = new InfoAboutPanel();
inoltre.. come sostituisco in AboutExit_ActionPerformed il comando System.exit(0) per evitare che si chiuda tutto, ma per far si che si chiuda solo la finestra dell'about?
edit: non ho visto che c'è l'apposita sezione per il java.. qualche mod può spostare il mio msg? Scusatemi tanto.. a volte dormo a occhi aperti![]()


Rispondi quotando