Hallo,
in einem zweiten Fenster befindet sich ein Sende-Button, wenn man auf diesen klickt so soll sich nur das Fenster schliessen in dem sich der Sende-Button befindet.
Wie schliesst man das zweite Fenster durch Sende-Button?
Viele Gruesse
in einem zweiten Fenster befindet sich ein Sende-Button, wenn man auf diesen klickt so soll sich nur das Fenster schliessen in dem sich der Sende-Button befindet.
Code:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.border.Border;
public class BallRoom extends JApplet implements ActionListener, Runnable {
private final int WIDTH = 350;
private final int HEIGHT = 300;
private JButton openPopup, ChooseSendFile, send;
private JFrame SettingFrame;
JRadioButton yes, no;
ButtonGroup groupRadio;
JPanel groupPanel, southPanel;
JTextField PathToSendFile;
JFileChooser SendFile;
String SendMsg = null;
public void init() {
this.setSize(WIDTH, HEIGHT);
SettingFrame = new JFrame("Einstellungen");
SettingFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
openPopup = new JButton("Einstellungen");
openPopup.addActionListener(this);
JPanel topPanel = new JPanel();
this.add(topPanel, BorderLayout.NORTH);
topPanel.add(openPopup);
yes = new JRadioButton("Ja");
yes.addActionListener(this);
no = new JRadioButton("Nein");
no.addActionListener(this);
no.setSelected(true);
PathToSendFile = new JTextField(20);
PathToSendFile.setEditable(false);
ChooseSendFile = new JButton("Open");
ChooseSendFile.setEnabled(false);
ChooseSendFile.addActionListener(this);
groupPanel = new JPanel();
Border b1 = BorderFactory.createTitledBorder("Datei senden?");
groupPanel.setBorder(b1);
southPanel = new JPanel();
groupRadio = new ButtonGroup();
groupPanel.add(yes);
groupRadio.add(yes);
groupPanel.add(no);
groupRadio.add(no);
groupPanel.add(PathToSendFile);
groupPanel.add(ChooseSendFile);
send = new JButton("Senden");
send.addActionListener(this);
southPanel.add(send);
SettingFrame.add(groupPanel, BorderLayout.NORTH);
SettingFrame.add(southPanel, BorderLayout.SOUTH);
}
public void run() {
}
public void actionPerformed(ActionEvent e){
if (e.getSource() == openPopup){
SettingFrame.setSize(500, 400);
SettingFrame.setVisible(true);
}
if (e.getSource() == yes){
PathToSendFile.setEditable(true);
ChooseSendFile.setEnabled(true);
}
if (e.getSource() == no){
PathToSendFile.setEditable(false);
ChooseSendFile.setEnabled(false);
}
if (e.getSource() == send){
System.out.print(SendMsg);
}
}
}
Wie schliesst man das zweite Fenster durch Sende-Button?
Viele Gruesse