Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7817355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:12:30+00:00 2026-06-02T06:12:30+00:00

I need to create a gui in java which will take a string from

  • 0

I need to create a gui in java which will take a string from a user and then user will click on submit button.On clicking the submit button,the user will do some processing on the string and then give output on screen(gui).

I have written the following code till now but when I run this code,it doesn’t give any output.

public class userinterface extends javax.swing.JFrame {
   
    public userinterface() {
        initComponents();
    }
                   
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration                   
    
    public void show() {
        String str = jTextField1.getText();
                        
        jButton1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                //Execute when button is pressed
                System.out.println("You clicked the button,str");
            }
        });
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new userinterface().setVisible(true);
                userinterface obj = new userinterface();
                obj.show();
            }
        });
    }

}

Please tell me where am I doing wrong ? How can I make the output display on gui screen?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:12:32+00:00Added an answer on June 2, 2026 at 6:12 am

    Your problem is you’ve overridden the essential method show() without realizing it, and this prevents the JFrame from displaying. Change the name of this method to something different:

    public void myShow() {
      // String str = jTextField1.getText(); // not useful
    
      jButton1.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
            // Execute when button is pressed
            System.out.println("You clicked the button,str");
         }
      });
    }
    
    public static void main(String args[]) {
      java.awt.EventQueue.invokeLater(new Runnable() {
         public void run() {
            // new userinterface().setVisible(true);
            userinterface obj = new userinterface();
            // obj.show();
            obj.myShow();
            obj.setVisible(true);
         }
      });
    }
    

    This is another reason that we all should strive not to extend classes unless absolutely necessary, since doing so can occasionally cause very difficult to debug errors.

    I was able to debug this by placing println’s throughout your code and seeing that show() was being called even when it wasn’t explicitly being called by me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to create a custom DNS name server using C which will check against
I need to create a program which will show how elliptic curve cryptography works.
I'm new to GUI programming, but need to create a multiple window GUI. Does
I need create a document word with Java. And I ask, how can I
I need to create a historical timeline starting from 1600's to the present day.
I have a java application which has a GUI in both English and French,
i need to create an application in java that would convert text strings into
I'm trying to create a web user interface for a Java application. The user
In my Java course I have to create a GUI class that interacts with
I am working on a Java Swing application. I need to create a dialog

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.