Write the code in Java: 1. Create a method that displays your name in the console....

90.2K

Verified Solution

Question

Programming

Write the code in Java:

1. Create a method that displays your name in the console. Thismethod is void and takes no parameters. Make an app that runs themethod in response to a button press.

2. Create a version of the method in #1 that takes the text(String) to be displayed as a parameter. Allow the user to enterthe text in a dialog box or text field and display that text in theconsole. Be sure to trim() the text.

Answer & Explanation Solved by verified expert
4.1 Ratings (581 Votes)
import javaawteventActionEventimport javaawteventActionListenerimport javaawteventKeyAdapterimport javaawteventKeyEventimport javaxswingJButtonimport javaxswingJFrameimport javaxswingJLabelimport javaxswingJPanelimport javaxswingJTextFieldpublic class ButtonClick static JFrame frame new JFrameJFrame Example public static void mainString s JPanel    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students