Hi,
During an installer that I'm making,I have a panel that ask a user for 4 details(i.e 4 text fields),
after that action I added a check to see whether all the fields were filled and if not goes back to the custom panel for completion.
The problem is that once the check fails(i.e not all the fields were filled)and it goes back to the panel, no matter what you type in-it doesn't recognize it and refuse to continue,and check keeps on failing no matter what you do.
I know its related to refreshing cause even if the user is filling the missing fields and pressing OK the Jpanel isn't catching it.
I'm using JDK 1.5.012
I'm also attaching my code.
10x.
p.s I also have a fifth field which is editable only when the user checks a check box. I also have problems with it but that is a different story
package ****;
import java.awt.*;
import com.zerog.ia.api.pub.*;
import java.io.*;
import javax.swing.*;
import java.awt.event.*;
public class CustomPanel extends CustomCodePanel implements ItemListener
{
//Constructor
public CustomPanel (){
selected=false;
}
private boolean selected;
private JLabel HostLabel,PortLabel,UsernameLabel1,UsernameLabel2,PasswordLabel1,PasswordLabel2,Caption1,Caption2,Caption3,DomainLabel;
private Frame frame;
private JPanel panel;
private JTextField HostField,PortField,UsernameField1,UsernameField2,field4,DomainNameField;
private JPasswordField passwordfield1,passwordfield2;
private JCheckBox check;
private int i=0;
GUIAccess gui;
CustomCodePanelProxy ccpp;
public boolean setupUI(CustomCodePanelProxy customCodePanelProxy)
{
//set the main panel
panel=new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.setBackground(new Color(255,255,255));
//Get the frame (window that displays all stuff)
ccpp = customCodePanelProxy;
gui = (GUIAccess)customCodePanelProxy.getService(com.zerog.ia.api.pub.GUIAccess.class);
frame = gui.getFrame();
//put components
//put the first Caption
Caption1 = new JLabel("<html>Database connection parameters<br></html>");
Caption1.setFont((Caption1.getFont()).deriveFont(14));
panel.add(Caption1);
panel.revalidate();
panel.repaint();
//put the Host label and the HostTextField
HostLabel = new JLabel("Host:");
HostLabel.setFont((HostLabel.getFont()).deriveFont(14));
panel.add(HostLabel);
panel.revalidate();
panel.repaint();
HostField =new JTextField(20);
HostField.setEditable(true);
HostField.setBorder(BorderFactory.createLineBorder(new Color(0,0,0)));
HostField.setText("localhost");
panel.add(HostField);
panel.revalidate();
panel.repaint();
//put the Port label and the PortTextField
PortLabel = new JLabel("Port:");
PortLabel.setFont((PortLabel.getFont()).deriveFont(14));
panel.add(PortLabel);
panel.revalidate();
panel.repaint();
PortField =new JTextField(20);
PortField.setEditable(true);
PortField.setBorder(BorderFactory.createLineBorder(new Color(0,0,0)));
PortField.setText("3728");
panel.add(PortField);
panel.revalidate();
panel.repaint();
//put the second Caption
Caption2 = new JLabel("User to create tables");
Caption2.setFont((Caption2.getFont()).deriveFont(14));
panel.add(Caption2);
panel.revalidate();
panel.repaint();
//put the Usernamr label and the UsernameTextField
UsernameLabel1 = new JLabel("User:");
UsernameLabel1.setFont((UsernameLabel1.getFont()).deriveFont(14));
panel.add(UsernameLabel1);
panel.revalidate();
panel.repaint();
UsernameField1 =new JTextField(20);
UsernameField1.setEditable(true);
UsernameField1.setBorder(BorderFactory.createLineBorder(new Color(0,0,0)));
panel.add(UsernameField1);
panel.revalidate();
panel.repaint();
//put the Password label and the PasswordTextField
PasswordLabel1 = new JLabel("Password:");
PasswordLabel1.setFont((PasswordLabel1.getFont()).deriveFont(14));
panel.add(PasswordLabel1);
panel.revalidate();
panel.repaint();
passwordfield1 =new JPasswordField(20);
passwordfield1.setEditable(true);
passwordfield1.setBorder(BorderFactory.createLineBorder(new Color(0,0,0)));
panel.add(passwordfield1);
panel.revalidate();
panel.repaint();
//adding the CheckBox and the follow TextField
check = new JCheckBox ("Windows autehntication exist",false);
check.setBackground(new Color(255,255,255));
panel.add(check);
panel.revalidate();
panel.repaint();
DomainLabel = new JLabel("Domain");
DomainLabel.setFont((DomainLabel.getFont()).deriveFont(14));
panel.add(DomainLabel);
panel.revalidate();
panel.repaint();
DomainNameField =new JTextField(20);
DomainNameField.setEditable(selected);
DomainNameField.setBorder(BorderFactory.createLineBorder(new Color(0,0,0)));
panel.add(DomainNameField);
panel.revalidate();
panel.repaint();
add(BorderLayout.NORTH,panel);
//Add the listener
check.addItemListener(this);
return true; // true if you want your panel displayed or false if not