Cześć,
Piszę prosty formularz do połączenia z bazą danych. Na razie chciałbym przetestować tylko mechanikę działania(url na sztywno, tylko login i hasło), mam jednak problem z panelem. Oto kod:
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
public class GUI extends Frame {
public static TextField user = null;
public static TextField password = null;
public static TextField base = null;
Label userLabel = null;
Label passwordLabel = null;
Label baseLabel = null;
public GUI(){
this.setSize(260, 160);
this.setTitle("Sybase connection");
this.setResizable(false);
//CLOSE OP
this.addWindowListener(new WindowAdapter(){
public void windowClosing( WindowEvent we){
System.exit(0);
}
});
//LAYOUT
this.setLayout(null);
// FORM PANEL
Panel form = new Panel();
form.setLayout(null);
form.setBackground(new Color(0, 200, 0));
form.setBounds(30,30, 200, 110);
//TEXT/LABEl
userLabel = new Label("User:");
userLabel.setBounds(5, 5, 90, 20);
form.add(userLabel);
passwordLabel = new Label("Password:");
passwordLabel.setBounds(5, 30, 90, 20);
form.add(passwordLabel);
baseLabel = new Label("Base:");
baseLabel.setBounds(5, 55, 90, 20);
form.add(baseLabel);
user = new TextField(20);
user.setBounds(100, 5, 90, 20);
form.add(user);
password = new TextField(20);
password.setBounds(100, 30, 90, 20);
form.add(password);
base = new TextField(20);
user.setBounds(100, 55, 90, 20);
form.add(base);
this.add(form);
//BUTTON
//LoginButton b = new LoginButton();
//this.add(b);
//BUTTON
}
public static void main(String[] args) {
GUI frame = new GUI();
frame.setVisible(true);
}
}
Wynik w załączniku.
Macie może jakieś pomysły dlaczego nie widać pierwszego TextFieldu?
Z góry dzięki za odpowiedź.