Hi,
I wrote the following GUI. Its total crap but just need to get the basics working first. Its compiles fine and my Hello World test message comes up but no sign of the UI itself. Any ideas at all ?
Much Thanks,
Sean

import javax.swing.JFrame;
import java.awt.event.WindowEvent;
import java.awt.Label;
import java.awt.Button;
import java.awt.Font;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;


public class TaxiGUI extends JFrame {
/** Creates new form JFrame */
public TaxiGUI() {
initGUI();
pack();
}



public static void main(String arg[])
{
TaxiGUI taxi = new TaxiGUI( ); //new
System.out.println("Hello World!");//TEST


}


/** This method is called from within the constructor to initialize the form. */
private void initGUI() {
label1.setText("ONLINE TAXI SERVICE");
label1.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 24));
label1.setBounds(new java.awt.Rectangle(2, 1, 466, 53));
label1.setForeground(new java.awt.Color(0, 0, 255));
panel1.setLayout(null);
panel1.add(label1);
panel1.add(label2);
panel1.add(textField1);
panel1.add(label3);
panel1.add(label4);
panel1.add(textField2);
panel1.add(button1);
label2.setText("User Name : ");
label2.setBounds(new java.awt.Rectangle(34, 127, 121, 22));
label2.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 20));
label2.setForeground(new java.awt.Color(0, 0, 255));
textField1.setText("");
textField1.setBounds(new java.awt.Rectangle(171, 131, 173, 20));
textField1.setFont(new java.awt.Font("Dialog",java.awt.Font.BOLD,12));
label3.setText("SYSTEM LOGIN");
label3.setBounds(new java.awt.Rectangle(135, 72, 160, 35));
label3.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 18));
label3.setForeground(new java.awt.Color(255,0,0));
label4.setText("Password :");
label4.setBounds(new java.awt.Rectangle(35, 174, 124, 27));
label4.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD,20));
label4.setForeground(new java.awt.Color(0,51,255));
addWindowListener(
new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
getContentPane().add(panel1, java.awt.BorderLayout.CENTER);
textField2.setText("");
textField2.setBounds(new java.awt.Rectangle(170, 180, 176, 22));
textField2.setFont(new java.awt.Font("Dialog",java.awt.Font.BOLD,12));
button1.setLabel("- LOGIN -");
button1.setBounds(new java.awt.Rectangle(169, 232, 122, 33));
button1.setFont(new java.awt.Font("Book Antiqua", java.awt.Font.BOLD, 18));
button1.setForeground(new java.awt.Color(255,0,0));
button1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){button1ActionPerformed(e);}});
}


/** Exit the Application */
private void exitForm(WindowEvent evt) {
System.exit(0);
}


public void button1ActionPerformed(ActionEvent e)
{
while(textField1 == null)
{
JOptionPane.showMessageDialog(null, "alert", "alert", JOptionPane.ERROR_MESSAGE);
}
//need to check text from testField1/2
//if(textField1 == "John" && textField2 == "john123")
if(1 == 1)
{
//payGUI = new PaymentGUI(); //if user name and password is valid
selectionGUI = new MainGUI(); //if user name and password is valid
}
else
{
JOptionPane.showMessageDialog(null, "alert", "alert", JOptionPane.ERROR_MESSAGE);
}
}


private Panel panel1 = new Panel();
private Label label1 = new Label();
private Label label2 = new Label();
private TextField textField1 = new TextField();
private Label label3 = new Label();
private Label label4 = new Label();


private TextField textField2 = new TextField();
private Button button1 = new Button();
// private PaymentGUI payGUI;
private MainGUI selectionGUI;
}

You simply forgot to set your frame visible.

try:

taxi.setVisible(true);

This isn't related to your question, but you're mixing AWT and Swing visual components. That is a bad idea in general. Please read the following artical for an explanation.

http://java.sun.com/products/jfc/tsc/articles/mixing/

Brilliant. Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.