Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 1 of 2 12 LastLast
Results 1 to 25 of 26

Thread: Is there a way to make things happen if a certain text is entered in a TextField?

  1. #1
    Member DusteroftheCentury's Avatar
    Join Date
    Jan 2012
    Location
    Northern California
    Posts
    42
    My Mood
    Fine
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Is there a way to make things happen if a certain text is entered in a TextField?

    Hey,

    First of all please excuse my lack of technical terms.

    I want to have a JTextField be able to accept commands, and have the commands change pictures, display text etc.

    Is their a simple way to do this?

    Thanks in advance,

    -Duster

    (If you need the code, just ask)


  2. #2
    Member
    Join Date
    Dec 2011
    Location
    United States
    Posts
    94
    My Mood
    Amused
    Thanks
    5
    Thanked 8 Times in 8 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    Quote Originally Posted by DusteroftheCentury View Post
    Hey,

    First of all please excuse my lack of technical terms.

    I want to have a JTextField be able to accept commands, and have the commands change pictures, display text etc.

    Is their a simple way to do this?

    Thanks in advance,

    -Duster

    (If you need the code, just ask)
    I would suggest reading java docs GUI tutorials and methods that fall into that concept. Try something that comes to your mind, if you fail, try again and then post errors you receive here.

  3. #3
    Member DusteroftheCentury's Avatar
    Join Date
    Jan 2012
    Location
    Northern California
    Posts
    42
    My Mood
    Fine
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    300zek0.pngThis image might help better explain what I want:

  4. #4
    Member DusteroftheCentury's Avatar
    Join Date
    Jan 2012
    Location
    Northern California
    Posts
    42
    My Mood
    Fine
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    Quote Originally Posted by elisha.java View Post
    I would suggest reading java docs GUI tutorials and methods that fall into that concept. Try something that comes to your mind, if you fail, try again and then post errors you receive here.
    Didnt see your post there. I shall try.

  5. #5
    Member DusteroftheCentury's Avatar
    Join Date
    Jan 2012
    Location
    Northern California
    Posts
    42
    My Mood
    Fine
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    Here is my code so far:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
     
     
    public class MainClass extends JFrame implements ActionListener
    {
    	public static void main(String[] args)
    	{
    		new MainClass();
    	}
    		private JButton button1;
    		private JLabel label1;
    		private JTextField textbox1;
     
    		public MainClass()
    		{
    		JPanel panel1 = new JPanel();
    		{
    		button1 = new JButton("OK");
    		ButtonListener b1 = new ButtonListener();
    		JLabel label1 = new JLabel();
    		JTextField textbox1 = new JTextField(15);
    		textbox1.getText();
    		textbox1.addActionListener(this);
     
    		panel1.add(textbox1);
    		panel1.add(label1);
    		panel1.add(button1);	
     
    		this.add(panel1);
    		this.setSize(300,100);
    		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		this.setVisible(true);
    	}
    }
     
    	private class ButtonListener implements ActionListener
    	{
    	public void ActionPerformed1(ActionEvent e)
    	{
    		if (e.getSource() == button1);
    		{
     
    			if (e.getSource() == button1);
    			//Code to check if the command the commands goes here?
    			}
    		}
    	}
     
    	public void ActionPerformed2(ActionEvent f)
    	{
    		if (f.getSource() == textbox1);
    		{
     
    			if (f.getSource() == textbox1);
    				//Or here? 
    			}
    	}		
    }



    Am I heading in the right direction? I checked the Java docs GUI tuts and from what I could gather this is where I should be going.

    In the places where i specified where the code might go what code would I put in there? The Gui docs tut just shows how to add the ActionListener, not how to use it.

    Thanks for the help,

    -Duster

  6. #6
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    Entering "Banana" and hitting "ok" would display a picture of "DANCING" banana
    so far your codes seems right, but your not even half way to what you want

    1.) By looking at your codes, Entering words and listening to the actions can be done
    2.) Displaying a picture
    - Start with how to paint images in a Light weight component
    3.) Dancing Banana
    - How do you want the banana to dance?
    - Rolling, Blinking, (im not sure what you want)
    - start with simple java animations
    - start with no.2, youre on the right track from painting images to animating simple things

    hope this helps
    Last edited by chronoz13; January 22nd, 2012 at 11:35 AM.

  7. #7
    Member DusteroftheCentury's Avatar
    Join Date
    Jan 2012
    Location
    Northern California
    Posts
    42
    My Mood
    Fine
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    I just want it to add a pic to the panel by using ImageIcon. This is the image: PBn'J.gif

    How would I listen to the actions? I know I can do "textbox1.getText();" to retrieve the text, but what code do I add to make it listen to that text and check if it is a command?

    Also where would it go?

    Thanks for your help,

    -Duster

  8. #8
    Junior Member
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    I have made a solution . May it work for you


    First you need to enter "banana" as a command to the text field shown below
    Untitled.png

    Now Click on "Click" Button You will get below image .. which make u happy
    Untitled2.jpg





    Code:-
    package pack;

    import java.awt.Image;
    import java.awt.event.ActionListener;

    import javax.swing.*;

    public class letsDance extends JFrame {

    private static final ActionListener ActionListener = null;

    public static void main(String[] args) {
    new letsDance();
    }

    private JButton clickButton;
    private JTextField commandField;

    public letsDance() {
    JPanel panel1 = new JPanel();
    {
    clickButton = new JButton("Click");
    clickButton.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    clickButtonActionPerformed(evt);
    }
    });


    commandField = new JTextField(15);
    commandField.setToolTipText("Enter the command");

    panel1.add(commandField);
    panel1.add(clickButton);

    this.add(panel1);
    this.setSize(300, 100);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
    this.setVisible(true);
    }
    }
    private void clickButtonActionPerformed(java.awt.event.ActionEv ent evt) {

    if(commandField.getText().toString().equals("banan a"))
    {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
    //provide the right image location in your local machine as i provided "C:/manojworkspace/BananaDancing/src/image/Dancing_Banana.gif"
    ImageIcon icon = new ImageIcon("C:/manojworkspace/BananaDancing/src/image/Dancing_Banana.gif");
    Image normalImage = icon.getImage();
    Icon ic = new ImageIcon(normalImage);
    JLabel label3 = new JLabel("Banana Dancing", icon, JLabel.CENTER);
    frame.add(label3,"North");

    frame.setSize(600, 300);
    frame.setVisible(true);

    }
    else{
    // add as your need
    }
    }

    }
    Last edited by Manoj Kumar Chhetri; January 22nd, 2012 at 02:55 PM.

  9. #9
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,264
    Thanks
    176
    Thanked 821 Times in 764 Posts
    Blog Entries
    5

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    Manoj Kumar Chhetri, please read the forum rules. I would also highly recommend that you read following:
    The Problem with Spoon-feeding
    I am stopping short of removing your code, but that does not mean another moderator won't come along and do so.

  10. #10
    Member DusteroftheCentury's Avatar
    Join Date
    Jan 2012
    Location
    Northern California
    Posts
    42
    My Mood
    Fine
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    I appreciate this but I understand that spoon feeding is bad. I only needed a few lines of that and that is what I will use.

    Thank you.

    @copeg I understand, I accidentally spoon fed someone this morning, before I knew it was wrong.

    -Duster

  11. #11
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    -_-, i never thought of a GIF image -_-, i was thinking you want to create the sprites and animation manually, well there you go.

  12. #12
    Member DusteroftheCentury's Avatar
    Join Date
    Jan 2012
    Location
    Northern California
    Posts
    42
    My Mood
    Fine
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    I really dont want to just use the code given, I want to figure it out with help.

    Here is my new code:

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.JFrame;
     
    public class MainClass extends JFrame 
    {
    	public static void main(String[] args)
    	{
    		new MainClass();
    	}
     
    		private JLabel label1;
    		private JTextField textbox1;
     
    		public MainClass()
    		{
    		JPanel panel1 = new JPanel();
    		{
     
    		JLabel label1 = new JLabel();
    		JTextField textbox1 = new JTextField(15);
    		textbox1.getText();
    		textbox1.setToolTipText("Enter commands");
     
    		panel1.add(textbox1);
    		panel1.add(label1);
     
     
     
    		this.add(panel1);
    		this.setSize(300,100);
    		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		this.setVisible(true);
    	}
    }
     
     
    	public void ActionPerformed2(ActionEvent f)
    	{
    		if (textbox1.getText().toString().equals("banana"))
    			{
    			JFrame frame1 = new JFrame();
    			frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    			ImageIcon pic = new ImageIcon(MainClass.class.getResource("PBn'J.gif"));
    			frame1.add(new JLabel(pic));
     
    		}		
    	}
    }

    When I type "banana" and hit enter, nothing happens. No errors messages either. Do I need to add an action listener? if so, how would I do that in this instance?

    Thanks for helping

    -Duster

  13. #13
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,264
    Thanks
    176
    Thanked 821 Times in 764 Posts
    Blog Entries
    5

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    Yes you need a listener of some sort - an ActionListener your best bet (which you can add to a JTextField). See How to Write an Action Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)

  14. #14
    Junior Member
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    @moderator

    I sorry for what i did . Actually i am new to this forum and some of the post i have seen others providing solution using code snippets ...So that's why i did ..

    But if i will not provide snippets, how would i able to give my solution ? If you recommend suggestion in terms of providing links and some comments, So its just become a long thread of a clarification/queries chain and just the wastage of time.

    Personally i do believe in open source ethics "share and learn".

  15. #15
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,264
    Thanks
    176
    Thanked 821 Times in 764 Posts
    Blog Entries
    5

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    Quote Originally Posted by Manoj Kumar Chhetri View Post
    @moderator

    I sorry for what i did . Actually i am new to this forum and some of the post i have seen others providing solution using code snippets ...So that's why i did ..

    But if i will not provide snippets, how would i able to give my solution ? If you recommend suggestion in terms of providing links and some comments, So its just become a long thread of a clarification/queries chain and just the wastage of time.

    Personally i do believe in open source ethics "share and learn".
    Please check your private messages. Lets leave this discussion outside this thread for fear of getting off the main topic at hand.

  16. #16
    Member DusteroftheCentury's Avatar
    Join Date
    Jan 2012
    Location
    Northern California
    Posts
    42
    My Mood
    Fine
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    Thanks, I checked the link and touched up on ActionListeners. I wrote this code,

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.JFrame;
     
    public class MainClass extends JFrame implements ActionListener
    {
    	public static void main(String[] args)
    	{
    		new MainClass();
    	}
     
    		private JLabel label1;
    		private JTextField textbox1;
    		private JButton button1;
     
    		public MainClass()
    		{
    		JPanel panel1 = new JPanel();
    		{
     
    		JLabel label1 = new JLabel();
    		JTextField textbox1 = new JTextField(15);
    		textbox1.getText();
    		textbox1.addActionListener(this);
    		textbox1.setToolTipText("Whats the password?");
    		button1 = new JButton("OK");
    		button1.addActionListener(this);
     
    		panel1.add(textbox1);
    		panel1.add(button1);
    		panel1.add(label1);
     
     
     
    		this.add(panel1);
    		this.setSize(300,100);
    		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		this.setVisible(true);
    	}
    }
     
     
    	public void actionPerformed(ActionEvent e)
    	{
    		if (e.getSource() == button1)
    			{
    			if (textbox1.getText().equals("password"))
    				System.out.println("You sir are a good guesser.");
     
    		}		
    	}
    }

    And it produces this error message:

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    	at MainClass.actionPerformed(MainClass.java:48)
    	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    	at java.awt.Component.processMouseEvent(Unknown Source)
    	at javax.swing.JComponent.processMouseEvent(Unknown Source)
    	at java.awt.Component.processEvent(Unknown Source)
    	at java.awt.Container.processEvent(Unknown Source)
    	at java.awt.Component.dispatchEventImpl(Unknown Source)
    	at java.awt.Container.dispatchEventImpl(Unknown Source)
    	at java.awt.Component.dispatchEvent(Unknown Source)
    	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    	at java.awt.Container.dispatchEventImpl(Unknown Source)
    	at java.awt.Window.dispatchEventImpl(Unknown Source)
    	at java.awt.Component.dispatchEvent(Unknown Source)
    	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    	at java.awt.EventQueue.access$000(Unknown Source)
    	at java.awt.EventQueue$3.run(Unknown Source)
    	at java.awt.EventQueue$3.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue$4.run(Unknown Source)
    	at java.awt.EventQueue$4.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)

    Please help, not sure what is wrong with my code.

    Thanks,

    -Duster

  17. #17
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,264
    Thanks
    176
    Thanked 821 Times in 764 Posts
    Blog Entries
    5

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    What is null on that line of code? Add some println's in there to see (hint: where do you initialize the instance variables?)

  18. #18
    Member DusteroftheCentury's Avatar
    Join Date
    Jan 2012
    Location
    Northern California
    Posts
    42
    My Mood
    Fine
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    Could you explain what null means? And what kind of printlns? I know they can be used to catch exceptions but how?

    Thanks for the help,

    -Duster

  19. #19
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,264
    Thanks
    176
    Thanked 821 Times in 764 Posts
    Blog Entries
    5

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    Quote Originally Posted by DusteroftheCentury View Post
    Could you explain what null means?
    null means an object has not been instantiated. In the following code...
    String myValue;
    ...myValue will be null.

    Quote Originally Posted by DusteroftheCentury View Post
    And what kind of printlns? I know they can be used to catch exceptions but how?

    Thanks for the help,

    -Duster

    Simply print out to the terminal (eg System.out.println). It allows you to inspect the value of a variable, and is one of the many invaluable debugging techniques (see http://www.javaprogrammingforums.com...t-println.html ). The exception stack trace tells you the method that throws the exception (and even the line it occurs on), so you can print the values of some variables you access prior to where the exception is thrown to see which is null, the backtrack to investigate why (and keep in mind my hint above). I am not trying to torture you by not telling you exactly what is wrong, because learning how to determine what is wrong is an important skill to learn.

  20. #20
    Member DusteroftheCentury's Avatar
    Join Date
    Jan 2012
    Location
    Northern California
    Posts
    42
    My Mood
    Fine
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    What lines of code would you reccomend checking? And how? I understand your blog, but I do not see how that would apply here, because I dont really use numbers and integers and such, which if I did I would know how to check. However I dont know how to check text variables.

    Thanks for helping a beginner,

    -Duster

  21. #21
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,264
    Thanks
    176
    Thanked 821 Times in 764 Posts
    Blog Entries
    5

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    Quote Originally Posted by DusteroftheCentury View Post
    What lines of code would you reccomend checking? And how? I understand your blog, but I do not see how that would apply here, because I dont really use numbers and integers and such, which if I did I would know how to check. However I dont know how to check text variables.

    Thanks for helping a beginner,

    -Duster
    Read the exception:
    at MainClass.actionPerformed(MainClass.java:48)
    Looks like line 48 of your MainClass.

    PrintStream (System.out) contains print statements for all sorts of data types, not just primitives. To reiterate, go to the line of code above and inspect the value of the variables used in that line. For instance, you could write
    System.out.println(textbox1);
    What does it print?

  22. #22
    Member DusteroftheCentury's Avatar
    Join Date
    Jan 2012
    Location
    Northern California
    Posts
    42
    My Mood
    Fine
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    It prints this:
    javax.swing.JTextField[,0,0,0x0,invalid,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@25b80053,flags=296,maximumSize=,minimumSize=,preferredSize=,caretColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],disabledTextColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],editable=true,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],selectedTextColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],columns=15,columnWidth=0,command=,horizontalAlignment=LEADING]

    Thanks for helping,

    -Duster

  23. #23
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    Quote Originally Posted by DusteroftheCentury View Post
    It prints this:
    javax.swing.JTextField[,0,0,0x0,invalid,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@25b80053,flags=296,maximumSize=,minimumSize=,preferredSize=,caretColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],disabledTextColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],editable=true,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],selectedTextColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],columns=15,columnWidth=0,command=,horizontalAlignment=LEADING]

    Thanks for helping,

    -Duster
    NO. In your previous last given code, you have actually declared textbox1 as instance variable and then in constructor, you re-declare and initialize it as a local variable, so the instance variable is actually shadowed but still null. Just remove the declaration inside the constructor and the code will work fine.

  24. #24
    Member DusteroftheCentury's Avatar
    Join Date
    Jan 2012
    Location
    Northern California
    Posts
    42
    My Mood
    Fine
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    What line do I remove? Sorry Im just not very familiar with the many technical terms.

    Thank you so much,

    -Duster

  25. #25
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Is there a way to make things happen if a certain text is entered in a TextField?

    JTextField textbox1 = new JTextField(15);
    Instead of this, just write
    textbox1 = new JTextField(15);

Page 1 of 2 12 LastLast

Similar Threads

  1. why could this happen?
    By bvk1013 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 17th, 2011, 10:48 PM
  2. Beginner Question Here (Trying to make things easier)
    By beer-in-box in forum AWT / Java Swing
    Replies: 2
    Last Post: June 1st, 2011, 10:48 AM
  3. Adding entered text from one GUI to another
    By fride360 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 24th, 2011, 01:08 PM
  4. loading things from a text file into an array list
    By sp11k3t3ht3rd in forum What's Wrong With My Code?
    Replies: 11
    Last Post: February 6th, 2011, 02:32 PM
  5. Replies: 1
    Last Post: December 4th, 2010, 04:26 PM