Support Forum Index FAQ Memberlist Search Usergroups Profile Log in to check your private messages Log in Register
Welcome to, a friendly and fast growing community of programmers, coders, web application developers and more. You are currently viewing our forums as a guest!

This message will go away once you are registered. Also, by registering you will have access to all post topics, communicate privately with other members (PM), respond to polls and access other special features. Registration is fast, simple and absoultely free so please Click Here to join our community

Enjoy our great collection of snippets and tutorials!

Log in


Our Sponsors
Want to list your business here. Contact us.
 Capitalisation of Letters in a simple GUI View next topic
View previous topic
Post new topic Reply to topic
Author Message

Joined: 05 Sep 2005
Posts: 39
Location: Valletta

PostPosted: Fri Mar 17, 2006 6:40 pm Reply with quoteBack to top


import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Container;
import java.awt.FlowLayout;

class MyActionListener implements ActionListener {

   JTextField  textfield;

   MyActionListener(JTextField textfield) {

      this.textfield = textfield;

   public void actionPerformed (ActionEvent e) {
      textfield.setText(textfield.getText().toUpperCase());       // convert letters to uppercase


class capssies {

   public static void main(String args[]) {

      JTextField textfield;
      FlowLayout layout;
      JButton button;
      String amessage = "Click Here to capitalise the letters";  // what would be shown on the button

      JFrame frame = new JFrame();
      frame.setTitle("Capitilisation");             // Title of the window
      textfield = new JTextField("Type your text here.",20);   // new textfield and default text - max 20 characters
      button = new JButton(amessage);                     // amessage passed as parameter
      button.addActionListener(new MyActionListener(textfield)); // button => textfield connection
      Container contentPane = frame.getContentPane();

      contentPane.add(textfield);               // add textfield to the frame
      contentPane.add(button);               // add button to the frame
      layout = new FlowLayout();               // layout of type FlowLayout - consult JAVA layout manager docs for more info.
      contentPane.setLayout(layout);            // layout just defined in the above line passed as parameter
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  // close frame and remove it from main memory
      frame.pack();                        // shrink wrap the frame
      frame.setVisible(true);                  // forget this and you won't see the window :-(



Display posts from previous:      
Post new topic Reply to topic

 Jump to:   

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2002 phpBB Group :: FI Theme
All times are GMT