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.

Results 1 to 4 of 4

Thread: How to combine Text and Button to show Search Result in java application

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default How to combine Text and Button to show Search Result in java application

    I do a photo search application.

    in my application, it has 1 textfield and 5 buttons as Asia, EU, Australia, America and Africa

    When user enter a keyword (for example, cupcake) in textfield then press one of 5 button (such as button EU)

    It should shows a photo relates to the keyword n a name of button, EU.

    What I am stuck now is how I can combine the the text and a name of button in my code ?
    I am thinking of a string for a name of button.

    My code here is:

    PHP Code:
    if (e.getSource() == btAfrica)
            {
                if (
    timer.isRunning())
                {
                    
    timer.stop();
                }
                
    keyWord txtSearch.getText();
                
    String location btAfrica.getText("Africa"); // My aim to get name of a button called AFRICA so user search photo with a keyword + AFRICA
                
    originalKeyWord keyWord location ;
                
    oldKeyWord keyWord location;
                
    timer.start();
            } 
    Error goes up:

    PHP Code:
    Method getText() in class.ajax.Swing.AbstracButton can not be applied to given types 
    Is this way correct or is there another way to do much easier, please provide code example ?

    I appreciate with your helps.

    Thanks


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How to combine Text and Button to show Search Result in java application

    You need to read the API doc for the getText() method to see how to use it.
    What class is the btAfrica variable?

    name of a button called AFRICA
    This is confusing. A button has a variable name and it can contain text.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to combine Text and Button to show Search Result in java application

    thanks, I found a way to archive this (^^)

  4. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: How to combine Text and Button to show Search Result in java application

    Probably in some cross-post.

  5. The Following User Says Thank You to curmudgeon For This Useful Post:

    Norm (December 15th, 2012)

Similar Threads

  1. Replies: 8
    Last Post: December 4th, 2012, 04:58 AM
  2. [SOLVED] CardLayout show a specific card with button click
    By IanSawyer in forum AWT / Java Swing
    Replies: 2
    Last Post: April 13th, 2012, 11:07 AM
  3. JSP / Java Problem - Twitter search application
    By aidanmur in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 30th, 2012, 03:17 PM
  4. [SOLVED] The button wouldn't show on the panel
    By nggdowt in forum AWT / Java Swing
    Replies: 7
    Last Post: November 3rd, 2011, 09:31 PM
  5. result set array button
    By dread_arisawa in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 21st, 2010, 10:05 AM