Rendre visible une nouvelle JFrame à partir d'un JButton sur une autre JFrame.
Bonjour, Je suis débutante en java, et j'aimerais faire que quand on clique sur un JButton que notre nouvelle JFrame appelée ProfilFrame sois visible car de base elle est en false, voici le code de ma JFrame :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| package fr.neyko.machine.desk;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import com.sun.awt.AWTUtilities;
import Sounds.Sound;
@SuppressWarnings({ "serial", "unused" })
public class ProfilFrame extends JFrame {
public static Sound music;
private static ProfilFrame instance;
private static ProfilPanel ProfilPanel;
public ProfilFrame() {
music = new Sound("/fr/neyko/machine//resources/menu.wav");
JFrame ProfilFrame = new JFrame("Test");
ProfilFrame.setTitle("ShadowZ Launcher");
ProfilFrame.setSize(977, 627);
ProfilFrame.setDefaultCloseOperation(EXIT_ON_CLOSE);
ProfilFrame.setLocationRelativeTo(null);
ProfilFrame.setUndecorated(true);
ProfilFrame.setIconImage(Swinger.getResource("icon.png"));
ProfilFrame.setContentPane(ProfilPanel = new ProfilPanel());
AWTUtilities.setWindowOpacity(this, 0.0F);
ProfilFrame.setVisible(false);
}
public static void main(String[] args) {
Swinger.setSystemLookNFeel();
instance = new ProfilFrame();
}
public static ProfilFrame getInstance() {
return instance;
}
@SuppressWarnings("static-access")
public ProfilPanel getProfilPanel() {
return this.ProfilPanel;
}
} |
Plus clair : Ma Frame Principale est MachineFrame et je lui ai attribué un Panel avec un JButton qui se nomme "Menu" et je veux que quand ce bouton est cliqué qu'il rende non-visible la Machine Frame et que la ProfilFrame devienne à sa place visible Merci de vos futures réponses.