Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,817 members, 7,813,697 topics. Date: Tuesday, 30 April 2024 at 04:33 PM

How To Create A Small Gui(graphical User Interface) Using Jframe In Java Program - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / How To Create A Small Gui(graphical User Interface) Using Jframe In Java Program (2120 Views)

Java Program To Solve Quadratic Equation-dealwap / Hope For C++ Newbies: Gui Toolkits / Import Dll Into Java Program (2) (3) (4)

(1) (Reply)

How To Create A Small Gui(graphical User Interface) Using Jframe In Java Program by mmsh350(m): 4:07pm On Sep 26, 2012
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.Event;
import java.awt.event.ActionEvent;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JOptionPane;


public class GUI1 extends JFrame{
private JTextField F;
private JLabel Text;
private JTextField Field;

public GUI1(){
super("This is the Title"wink;

setLayout(new FlowLayout());

Text=new JLabel("Hi Welcome to my windows"wink;
add(Text);
Field=new JTextField(5);
add(Field);

Handler h=new Handler();
Field.addActionListener(h);
}//end of constructor
private class Handler implements ActionListener{

public void actionPerformed(ActionEvent event){

String S="";

if(event.getSource()==Field){

S=String.format("Hi How Are You %s",event.getActionCommand());


}//end of if statements
F=new JTextField(S);
F.setForeground(Color.red);

add(F);

}//end of method actionPerformed


}//end of class Handler

}//end of class GUI1
[color=#006600][/color]

(1) (Reply)

Please Help A Dumb Guy With Some "PYTHON" Ideas. / Simple Algorithm Implementation / I Got A Call From A Recruiter

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 6
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.