Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


gaetano
java
3 Answer(s)      5 years and 4 months ago
Posted in : Swing AWT



Advertisement
View Answers

December 1, 2009 at 10:42 AM


Hi Friend,

import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JOptionPane;
import javax.swing.JButton;
class CurrentAccount extends JFrame
{
private JLabel label1;
private JLabel label2;
private JLabel label3;


private JTextField textField1;
private JTextField textField2;
private JTextField textField3;
private JTextField textField4;
private JTextField textField5;
private JTextField textField6;
private JTextField textField7;
private JTextField textField8;
private JTextField textField9;
private JTextField textField10;
private JTextField textField11;
private JTextField textField12;
private JTextField textField13;
private JTextField textField14;
private JTextField textField15;
private JTextField textField16;
private JTextField textField17;
private JTextField textField18;
private JTextField textField19;
private JPasswordField passwordField;
private JButton plainJButton;
private JButton resetJButton;
public CurrentAccount(){
super( "Current Account" );
setLayout( new FlowLayout() );
{
setLayout( new FlowLayout() );
label1 = new JLabel( "With Your Banking Solutions" );
label1.setToolTipText( "This is label1" );
add( label1 );

Icon bug = new ImageIcon( getClass().getResource( "current.gif" ) );
label3 = new JLabel();
label3.setText( "Fill in the spaces below to create a Current Account !" );
label3.setIcon( bug );
label3.setHorizontalTextPosition( SwingConstants.CENTER );
label3.setVerticalTextPosition( SwingConstants.BOTTOM );
label3.setToolTipText( "This is label3" );
add( label3 ); }

textField2 = new JTextField( "First Name:",15 );
textField2.setEditable( false );
add( textField2 );

textField1 = new JTextField( 15 );
add( textField1 );
textField4 = new JTextField( "Second Name:",15 );
textField4.setEditable( false );
add( textField4 );
textField5 = new JTextField( 15 );
add( textField5 );
textField6 = new JTextField( "University:",15 );
textField6.setEditable( false );
add( textField6 );
textField7 = new JTextField( 15 );
add( textField7 );
textField8 = new JTextField( "Faculty:",15 );
textField8.setEditable( false );
add( textField8 );
textField9 = new JTextField( 15 );
add( textField9 );
textField10 = new JTextField( "Course:",15 );
textField10.setEditable( false );
add( textField10 );
textField11 = new JTextField( 15 );
add( textField11 );
textField12 = new JTextField( "Year Of Study:",15 );
textField12.setEditable( false );
add( textField12 );
textField13 = new JTextField( 15 );
add( textField13 );
textField14 = new JTextField( "Tel NO:",15 );
textField14.setEditable( false );
add( textField14 );
textField15 = new JTextField( 15 );
add( textField15 );
textField16 = new JTextField( "Email:",15 );
textField16.setEditable( false );
add( textField16 );
textField17 = new JTextField( 15 );


December 1, 2009 at 10:46 AM


continue...

add( textField17 );
textField18 = new JTextField( "Physical Address:",15 );
textField18.setEditable( false );
add( textField18 );
textField19 = new JTextField( 15 );
add( textField19 );
textField3 = new JTextField( "Username",15 );
textField3.setEditable( false );
add( textField3 );
passwordField = new JPasswordField( "",15 );
add( passwordField );
plainJButton = new JButton( "Submit" );
add( plainJButton );
resetJButton = new JButton( "Reset" );
add( resetJButton );
plainJButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
Template temp=new Template();
temp.setVisible(true);
}
});
TextFieldHandler handler = new TextFieldHandler();
textField1.addActionListener( handler );
textField2.addActionListener( handler );
textField3.addActionListener( handler );
textField4.addActionListener( handler );
textField5.addActionListener( handler );
passwordField.addActionListener( handler );
}
private class TextFieldHandler implements ActionListener{
public void actionPerformed( ActionEvent event ){
String string = "";
if ( event.getSource() == textField1 )
string = String.format( "textField1: %s",
event.getActionCommand() );
else if ( event.getSource() == textField2 )
string = String.format( "textField2: %s",
event.getActionCommand() );
else if ( event.getSource() == textField3 )
string = String.format( "textField3: %s",
event.getActionCommand() );
else if ( event.getSource() == textField4 )
string = String.format( "textField4: %s",
event.getActionCommand() );
else if ( event.getSource() == textField5 )
string = String.format( "textField5: %s",
event.getActionCommand() );
else if ( event.getSource() == textField6 )
string = String.format( "textField6: %s",
event.getActionCommand() );
else if ( event.getSource() == textField7 )
string = String.format( "textField7: %s",
event.getActionCommand() );
else if ( event.getSource() == textField8 )
string = String.format( "textField8: %s",
event.getActionCommand() );
else if ( event.getSource() == textField9 )
string = String.format( "textField9: %s",
event.getActionCommand() );
else if ( event.getSource() == textField10 )
string = String.format( "textField10: %s",
event.getActionCommand() );
else if ( event.getSource() == textField11 )
string = String.format( "textField11: %s",
event.getActionCommand() );
else if ( event.getSource() == textField12 )
string = String.format( "textField12: %s",
event.getActionCommand() );
else if ( event.getSource() == textField13 )
string = String.format( "textField13: %s",
event.getActionCommand() );
else if ( event.getSource() == textField14 )
string = String.format( "textField14: %s",
event.getActionCommand() );
else if ( event.getSource() == textField15 )
string = String.format( "textField15: %s",
event.getActionCommand() );
else if ( event.getSource() == textField16 )
string = String.format( "textField16: %s",
event.getActionCommand() );
else if ( event.getSource() == textField17 )
string = String.format( "textField17: %s",
event.getActionCommand() );
else if ( event.getSource() == textField18 )
string = String.format( "textField18: %s",
event.getActionCommand() );
else if ( event.getSource() == textField19 )
string = String.format( "textField19: %s",
event.getActionCommand() );
else if ( event.getSource() == passwordField )
string = String.format( "passwordField: %s",
new String( passwordField.getPassword() ) );
}
}
}


December 1, 2009 at 10:48 AM


continue..

public class FinalAccount{
public static void main( String args[] ){
CurrentAccount textFieldFrame = new CurrentAccount();
textFieldFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
textFieldFrame.setSize( 400, 410 );
textFieldFrame.setVisible( true );
}
}

Template.java
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JOptionPane;
import javax.swing.JButton;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Template extends JFrame{
private JLabel label1;
private JLabel label2;
private JLabel label3;
private JTextField textField1;
private JTextField textField2;
private JTextField textField3;
private JTextField textField4;
private JPasswordField passwordField;
private JButton plainJButton;
private JButton fancyJButton;
public Template(){ super("Walz Bank International");
setLayout( new FlowLayout() );{
label1 = new JLabel( "With Your Banking Solutions" );
label1.setToolTipText( "This is label1" );
add( label1 );
Icon bug = new ImageIcon( getClass().getResource( "a.gif" ) );
label3 = new JLabel();
label3.setText( "Login If registered Customer" );
label3.setIcon( bug );
label3.setHorizontalTextPosition( SwingConstants.CENTER );
label3.setVerticalTextPosition( SwingConstants.BOTTOM );
label3.setToolTipText( "This is label3" );
add( label3 );
}
textField2 = new JTextField( "Username" );
textField2.setEditable(false);
add( textField2 );
textField1 = new JTextField( 15 );
add( textField1 );
textField3 = new JTextField( "PIN Code");
textField3.setEditable( false );
add( textField3 );
passwordField = new JPasswordField( "",15 );
add( passwordField );
plainJButton = new JButton( "Enter" );
add( plainJButton );
textField4 = new JTextField( "Create an Account",21 );
textField4.setEditable(false);
add( textField4 );
plainJButton = new JButton( "Savings Acc" );
add( plainJButton );
plainJButton = new JButton( "Current Acc" );
add( plainJButton );
TextFieldHandler handler = new TextFieldHandler();
textField1.addActionListener( handler );
textField2.addActionListener( handler );
textField3.addActionListener( handler );
textField4.addActionListener( handler);
passwordField.addActionListener( handler );
pack();
}
private class TextFieldHandler implements ActionListener{
public void actionPerformed( ActionEvent event ){
String string = "";
if ( event.getSource() == textField1 )
string = String.format( "textField1: %s",
event.getActionCommand() );
else if ( event.getSource() == textField2 )
string = String.format( "textField2: %s",
event.getActionCommand() );
else if ( event.getSource() == textField3 )
string = String.format( "textField3: %s",
event.getActionCommand() );
else if ( event.getSource() == passwordField )
string = String.format( "passwordField: %s",
new String( passwordField.getPassword() ) );
JOptionPane.showMessageDialog( null, string );
}
}
}
Thanks


Related Tutorials/Questions & Answers:
java
java  diff bt core java and java
java
java  what is java
Advertisements
Java
Java   Whether Java is pure object oriented Language
JAVA
JAVA  how the name came for java language as "JAVA
java
java  different between java & core java
java
java  explain technologies are used in java now days and structure java
java
java   why iterator in java if we for loop
java
java  what is java reflection
java
java  is java open source
java
what is the size of array in java ?  what is the size of array in java ? what is the mean of finalize in java
java
java   in java does not pointers concept but what is nullpointers in java?   nullpointer is a runtime Exception
java
java  write a java program using filenotfoundexception
Java
Java  how to draw class diagrams in java
java
java   difference between class and interface
java
java  why multiple inheritance is not possible in java
java
java  explain object oriented concept in java
java
java  is java purely object oriented language
Java
Java   Whether Java is Programming Language or it is SOftware
java
java  what are JAVA applications development tools
java
java  how use java method
java
java  send me java interview questions
java
java  write a program in java to acess the email
java
java  Write a java code to print "ABABBABCABABBA
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  give a simple example for inheritance in java
java
java  give a simple example for inheritance in java
Java
Java  how to do java in command prompt
java
java  Does java allows multiline comments
Advertisements
 

 

 

DMCA.com