Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My First GUI.....maybe

 
David Pedisich
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off, I wish I could attach my file since it is rather large. My apologize to any mode who have a problem with this. I'm trying to create a very simple GUI using identification. there will be 3 inputs; Agent: ;Code; Clerence. Then if that is correct. I want a second Java window to pop up with the response.....thats all. I've spent the last 3 hours trying to figure this out with no luck. can someone PLEASE help me clean this up?


-------------
------------
------------

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Auth extends JFrame {
JPanel pane;
JButton subBT;
JButton canBT;
JTextField agent;
JTextField code;
JTextField clear;

public Input() {
super("Security");
my take = new my();
agent = new JTextField();
code = new JTextField();
clear = new JTextField();
subBT = new JButton("Execute");
canBT = new JButton("Disable");
subBT.addActionListener(myListener);
canBT.addActionListener(myListener);

pane = new JPanel();
pane.setLayout(new GridLayout(8,23));
pane.add(new JLabel("Agent: "));
pane.add(agent);agent.setBackground(Color.lightGray);
pane.add(new JLabel("Code: "));
pane.add(code);code.setBackground(Color.lightGray);
pane.add(new JLabel("Clerence: "));
pane.add(clear);clear.setBackground(Color.lightGray);
pane.add(subBT);subBT.setBackground(Color.lightGray);
pane.add(canBT);canBT.setBackground(Color.lightGray);
pane.setBackground(Color.lightGray);
setContentPane(pane);
}

public class Result extends JFrame {
JPanel out;
JTextField name;
JTextField d;
JTextField type;
JTextField di;
JTextField backround;
JTextField dis;

public Output() {
super("Agent Information");
my display = new my();
d = new JTextField();
di = new JTextField();
dis = new JTextField();


out = new JPanel();
out.setLayout(new GridLayout(8,23));
out.add(new JLabel("Real Name: "));
out.add(name);name.setBackground(Color.lightGray);
out.add(new JLabel("/t"+"David Pedisich"));
out.add(d);d.setBackground(Color.lightGray);
out.add(new JLabel("Type: "));
out.add(type);type.setBackground(Color.lightGray);
out.add(new JLabel("/t"+" CIA"));
out.add(di);di.setBackground(Color.lightGray);
out.add(new JLabel("Backround: "));
out.add(type);type.setBackground(Color.lightGray);
out.add(new JLabel("/t"+"Joined in 1987"));
out.add(dis);dis.setBackground(Color.lightGray);
out.setBackground(Color.lightGray);
setContentPane(pane);
}
}
}

public class my implements ActionListener {
public void actionPerformed(ActionEvent e) {
if(agent.equalsIgnoreCase("Bourne")){
if(code.equalsIgnoreCase("7190")){
if(clear.equalsIgnoreCase("Level 4")){
getOppositeWindow(Result);
}
}
}


}
}




public static void main(String[] args) {
WindowListener windowL= new WindowAdapter(){
public void windoClosing(WindowEvent e){
System.exit(0);
}
};
Auth frame = new Auth();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
Result frame1= new Result();
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame1.setVisible(false);
}
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / AWT / SWT / JFace forum...
 
Sham Grandhe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mr. David Pedisich,

Iam sorry to tell you that i couldn't get what ur actually trying to ask. the code that you have sent has many errors, hence i have corrected that and i am sending the code. hope this could help you.

best of luck.

here is the code
---------------

//FileName: Auth.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Auth extends JFrame implements ActionListener{
JPanel pane;
JButton subBT;
JButton canBT;
JTextField agent;
JTextField code;
JTextField clear;

public Auth()
{
super("Security");
agent = new JTextField();
code = new JTextField();
clear = new JTextField();
subBT = new JButton("Execute");
canBT = new JButton("Disable");

subBT.addActionListener(this);
canBT.addActionListener(this);

pane = new JPanel();
pane.setLayout(new GridLayout(8,23));
pane.add(new JLabel("Agent: "));
pane.add(agent);
agent.setBackground(Color.lightGray);

pane.add(new JLabel("Code: "));
pane.add(code);
code.setBackground(Color.lightGray);

pane.add(new JLabel("Clerence: "));
pane.add(clear);clear.setBackground(Color.lightGray);

pane.add(subBT);
subBT.setBackground(Color.lightGray);

pane.add(canBT);
canBT.setBackground(Color.lightGray);

pane.setBackground(Color.lightGray);
setContentPane(pane);
}

public void actionPerformed(ActionEvent e)
{
String agentName = agent.getText().toString(); // u have to compare text in the textfield not the textfiled object
String agentCode = code.getText().toString();
String agentClear = clear.getText().toString();

if(agentName.equalsIgnoreCase("Bourne") && (agentCode.equalsIgnoreCase("7190")) && (agentClear.equalsIgnoreCase("Level 4")))
new Result(this).show();
}

public static void main(String[] args)
{
Auth frame = new Auth();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}

// -- uesr defined class

class Result extends JDialog
{
JPanel out;
JTextField name;
JTextField d;
JTextField type;
JTextField di;
JTextField backround;
JTextField dis;

public Result(javax.swing.JFrame f)
{
super(f,"Agent Information",true);

out = new JPanel();
out.setLayout(new GridLayout(0,2));
out.add(new JLabel("Real Name: "));

name = new JTextField(10);
out.add(name);
name.setBackground(Color.lightGray);
out.add(new JLabel("/t"+"David Pedisich"));

d = new JTextField(10);
out.add(d);
d.setBackground(Color.lightGray);

out.add(new JLabel("Type: "));
type = new JTextField(10);
out.add(type);
type.setBackground(Color.lightGray);

out.add(new JLabel("/t"+" CIA"));
di = new JTextField(10);
out.add(di);
di.setBackground(Color.lightGray);

out.add(new JLabel("Backround: "));
type = new JTextField(10);
out.add(type);
type.setBackground(Color.lightGray);

out.add(new JLabel("/t"+"Joined in 1987"));
dis = new JTextField(10);
out.add(dis);
dis.setBackground(Color.lightGray);
out.setBackground(Color.lightGray);

getContentPane().add(out);

pack();

}
}
 
David Pedisich
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mr. Kumar Shyam,

Your code corrections helped greatly! Thank you very much for your assistance.

-David Pedisich
 
Nigel Browne
Ranch Hand
Posts: 703
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use the code tags when posting code !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic