package GUI.SettingWindows;
import java.awt.Component;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseEvent;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.JWindow;
import Communication.ChatProvider;
import GUI.SettingsWindow;
import GUI.StandardBackground;
import GUI.Interfaces.Background;
/**
* Shows a GUI that enables the user to create a new Chat Connection
*
* @author Sebastian
*
*/
public class ChatConnectionEditor extends JWindow{
private TextField connectionName = new TextField("Verbindungsbezeichnung");
private JPasswordField passwordField = new JPasswordField("someText");
private JTextField loginName = new JTextField("Benutzername");
private JComboBox connectionType = new JComboBox();
private JButton applyButton = new JButton("�bernehmen");
public ChatConnectionEditor(Rectangle rectangle, final SettingsWindow settingsWindow) {
for(ChatProvider type : ChatProvider.values()){
connectionType.addItem(type);
}
setLayout(null);
setBounds(rectangle);
connectionName.setFont(new Font("Arial",Font.BOLD, 10));
loginName.setFont(new Font("Arial",Font.BOLD, 10));
connectionName.setBounds(15,15,190,23);
connectionName.isEditable();
loginName.setBounds(15,40,100,23);
passwordField.setBounds(125,40,80,23);
connectionType.setBounds(15,65,190,23);
applyButton.setBounds(15,90,190,23);
add(connectionName);
add(passwordField);
add(loginName);
add(connectionType);
add(applyButton);
Background background = new StandardBackground(false, rectangle, -1);
add((Component) background);
background.setBounds(0, 0, rectangle.width, rectangle.height);
applyButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
settingsWindow.chatConnectionEdited(connectionName.getText(),
loginName.getText(), passwordField.getText(),
(ChatProvider) connectionType.getSelectedItem());
setVisible(false);
}});
loginName.requestFocus();
loginName.requestFocusInWindow();
setVisible(true);
loginName.requestFocus();
connectionName.requestFocusInWindow();
}
public void componentHidden(ComponentEvent arg0) {
// TODO Auto-generated method stub
}
public void componentMoved(ComponentEvent arg0) {
// TODO Auto-generated method stub
}
public void componentShown(ComponentEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowClosing(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
}