Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,624 members, 7,955,286 topics. Date: Saturday, 21 September 2024 at 09:33 PM |
Nairaland Forum / Science/Technology / Programming / How To Create A Small Gui(graphical User Interface) Using Jframe In Java Program (2157 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" setLayout(new FlowLayout()); Text=new JLabel("Hi Welcome to my windows" 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)
What Skillsets Are Needed To Create A World Class Web-based Accounting Software? / Can I Use Hp Pavilion G6 For Programming??? / Studying Computer Science At 40?
(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. 11 |