Tengo como código
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
//Esta clase muestra un cuadro de diálogo para introducir Servidor.
public class ConnectDialog extends JDialog {
// Estos son los tipos de servidor de correo electrónico.
private static final String[] TYPES = {"pop3", "imap"};
// Cuadro combinado para tipos de servidor de correo electrónico.
private JComboBox typeComboBox;
// Servidor, nombre de usuario y campos de texto del servidor SMTP.
private JTextField serverTextField, usernameTextField;
private JTextField smtpServerTextField;
// Campo de texto de contraseña.
private JPasswordField passwordField;
// Constructor para el diálogo.
public ConnectDialog(Frame parent) {
// Llame a super constructor, especificando que el diálogo es modal.
super(parent, true);
// Establecer el título del diálogo.
setTitle("Connect");
// Manejar eventos de cierre.
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
actionCancel();
}
});
// Configuración del panel de configuración.
JPanel settingsPanel = new JPanel();
settingsPanel.setBorder(
BorderFactory.createTitledBorder("Connection Settings"));
GridBagConstraints constraints;
GridBagLayout layout = new GridBagLayout();
settingsPanel.setLayout(layout);
JLabel typeLabel = new JLabel("Type:");
constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.EAST;
constraints.insets = new Insets(5, 5, 0, 0);
layout.setConstraints(typeLabel, constraints);
settingsPanel.add(typeLabel);
typeComboBox = new JComboBox(TYPES);
constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.WEST;
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.insets = new Insets(5, 5, 0, 5);
constraints.weightx = 1.0D;
layout.setConstraints(typeComboBox, constraints);
settingsPanel.add(typeComboBox);
JLabel serverLabel = new JLabel("Server:");
constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.EAST;
constraints.insets = new Insets(5, 5, 0, 0);
layout.setConstraints(serverLabel, constraints);
settingsPanel.add(serverLabel);
serverTextField = new JTextField(25);
constraints = new GridBagConstraints();
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.insets = new Insets(5, 5, 0, 5);
constraints.weightx = 1.0D;
layout.setConstraints(serverTextField, constraints);
settingsPanel.add(serverTextField);
JLabel usernameLabel = new JLabel("Username:");
constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.EAST;
constraints.insets = new Insets(5, 5, 0, 0);
layout.setConstraints(usernameLabel, constraints);
settingsPanel.add(usernameLabel);
usernameTextField = new JTextField();
constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.WEST;
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.insets = new Insets(5, 5, 0, 5);
constraints.weightx = 1.0D;
layout.setConstraints(usernameTextField, constraints);
settingsPanel.add(usernameTextField);
JLabel passwordLabel = new JLabel("Password:");
constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.EAST;
constraints.insets = new Insets(5, 5, 5, 0);
layout.setConstraints(passwordLabel, constraints);
settingsPanel.add(passwordLabel);
passwordField = new JPasswordField();
constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.WEST;
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.insets = new Insets(5, 5, 5, 5);
constraints.weightx = 1.0D;
layout.setConstraints(passwordField, constraints);
settingsPanel.add(passwordField);
JLabel smtpServerLabel = new JLabel("SMTP Server:");
constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.EAST;
constraints.insets = new Insets(5, 5, 5, 0);
layout.setConstraints(smtpServerLabel, constraints);
settingsPanel.add(smtpServerLabel);
smtpServerTextField = new JTextField(25);
constraints = new GridBagConstraints();
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.insets = new Insets(5, 5, 5, 5);
constraints.weightx = 1.0D;
layout.setConstraints(smtpServerTextField, constraints);
settingsPanel.add(smtpServerTextField);
// Configuración del panel de botones.
JPanel buttonsPanel = new JPanel();
JButton connectButton = new JButton("Connect");
connectButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionConnect();
}
});
buttonsPanel.add(connectButton);
JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionCancel();
}
});
buttonsPanel.add(cancelButton);
// Añadir paneles para mostrar.
getContentPane().setLayout(new BorderLayout());
getContentPane().add(settingsPanel, BorderLayout.CENTER);
getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
// Diálogo de tamaño a los componentes.
pack();
// Centro de diálogo sobre la aplicación.
setLocationRelativeTo(parent);
}
// Validar la configuración de la conexión y cerrar el cuadro de diálogo.
private void actionConnect() {
if (serverTextField.getText().trim().length() < 1
|| usernameTextField.getText().trim().length() < 1
|| passwordField.getPassword().length < 1
|| smtpServerTextField.getText().trim().length() < 1) {
JOptionPane.showMessageDialog(this,
"One or more settings is missing.",
"Missing Setting(s)", JOptionPane.ERROR_MESSAGE);
return;
}
// Cerrar diálogo.
dispose();
}
// Cancelar la conexión y salir del programa.
private void actionCancel() {
System.exit(0);
}
//Obtener servidor de correo electrónico
public String getType(){
return(String) typeComboBox.getSelectedItem();
}
// Obtener servidor de correo electrónico
public String getServer() {
return serverTextField.getText();
}
// Obtener un nombre de usuario de correo electrónico.
public String getUsername() {
return usernameTextField.getText();
}
// Obtener contraseña de correo electrónico.
public String getPassword() {
return new String(passwordField.getPassword());
}
// Obtener correo electrónico del servidor SMTP.
public String getSmtpServer() {
return smtpServerTextField.getText();
}
}
Me aparece error en esas lineas 166 y no sé qué podría ser, aparte de que en el "Obtener servidor de correo electronico" me pide poner el Override y cuando lo pongo me pide quitarlo y es el único error que me marca en el netbeans, alguna idea de por qué sera?