Ошибка написание интерфейса для mail client - Java
Формулировка задачи:
Добрый день. Недавно начал осваивать написание мэйл клиентов на java. У меня есть код, но и имеется маленькая ошибка с геттером. На вид очень простая, но мне не по зубам. Помогите пожалуйста.
Вот сама ошибка:
А Вот весь код:
Заранее огромное спасибо!
public String getType() { return (String) typeComboBox.getSelectedItem();
package javamailproject; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JOptionPane; public class ConnectDialog extends javax.swing.JDialog { public ConnectDialog(java.awt.Frame parent) { super(parent, true); setTitle("Connection..."); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { actionCancel(); } }); setLocationRelativeTo(parent); initComponents(); } 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, "Error!", "Fill all gaps!", JOptionPane.ERROR_MESSAGE); return; } dispose(); } private void actionCancel() { System.exit(0); } public String getType() { return (String) typeComboBox.getSelectedItem(); } public String getServer() { return serverTextField.getText(); } public String getUsername() { return usernameTextField.getText(); } public String getPassword() { return new String(passwordField.getPassword()); } public String getSmtpServer() { return smtpServerTextField.getText(); } // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { connectPanel = new javax.swing.JPanel(); typeLabel = new javax.swing.JLabel(); typeComboBox = new javax.swing.JComboBox(); serverLabel = new javax.swing.JLabel(); serverTextField = new javax.swing.JTextField(); usernameLabel = new javax.swing.JLabel(); usernameTextField = new javax.swing.JTextField(); passwordLabel = new javax.swing.JLabel(); smtpServerLabel = new javax.swing.JLabel(); smtpServerTextField = new javax.swing.JTextField(); passwordField = new javax.swing.JPasswordField(); connectButton = new javax.swing.JButton(); cancelButton = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); connectPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Установка соединения")); typeLabel.setText("Тип протокола:"); typeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "pop3" })); serverLabel.setText("Сервер:"); usernameLabel.setText("Имя пользователя:"); passwordLabel.setText("Пароль:"); smtpServerLabel.setText("SMTP сервер:"); passwordField.setText("jPasswordField1"); javax.swing.GroupLayout connectPanelLayout = new javax.swing.GroupLayout(connectPanel); connectPanel.setLayout(connectPanelLayout); connectPanelLayout.setHorizontalGroup( connectPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(connectPanelLayout.createSequentialGroup() .addGroup(connectPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(connectPanelLayout.createSequentialGroup() .addGroup(connectPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(passwordLabel) .addComponent(usernameLabel) .addComponent(smtpServerLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)) .addComponent(serverLabel) .addGroup(connectPanelLayout.createSequentialGroup() .addComponent(typeLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) .addGroup(connectPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(typeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(serverTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE) .addComponent(smtpServerTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE) .addComponent(usernameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE) .addComponent(passwordField, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)) .addContainerGap()) ); connectPanelLayout.setVerticalGroup( connectPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(connectPanelLayout.createSequentialGroup() .addGroup(connectPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(typeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(typeLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(connectPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(serverTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(serverLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(connectPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(usernameLabel) .addComponent(usernameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(connectPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(passwordLabel) .addComponent(passwordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(connectPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(smtpServerTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(smtpServerLabel))) ); connectButton.setText("OK"); connectButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { connectButtonMouseClicked(evt); } }); cancelButton.setText("Отмена"); cancelButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { cancelButtonMouseClicked(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(connectPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addGap(38, 38, 38) .addComponent(connectButton, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(53, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(connectPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(connectButton) .addComponent(cancelButton)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void connectButtonMouseClicked(java.awt.event.MouseEvent evt) { actionConnect(); } private void cancelButtonMouseClicked(java.awt.event.MouseEvent evt) { actionCancel(); } // Variables declaration - do not modify private javax.swing.JButton cancelButton; private javax.swing.JButton connectButton; private javax.swing.JPanel connectPanel; private javax.swing.JPasswordField passwordField; private javax.swing.JLabel passwordLabel; private javax.swing.JLabel serverLabel; private javax.swing.JTextField serverTextField; private javax.swing.JLabel smtpServerLabel; private javax.swing.JTextField smtpServerTextField; private javax.swing.JComboBox typeComboBox; private javax.swing.JLabel typeLabel; private javax.swing.JLabel usernameLabel; private javax.swing.JTextField usernameTextField; // End of variables declaration }
Решение задачи: «Ошибка написание интерфейса для mail client»
textual
Листинг программы
return typeComboBox.getSelectedItem().toString()
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д