add to the code: I need help with making a more defined textfields that have a label
Question:
add to the code: I need help with making a more defined textfields that have a label indication what data is expected to be entered. Enhance the GUI by adding a Submit button and allowing the user to enter their own data in the textfields.
import javax.swing.*;
public class Widget {
public static void main(String[] args) {
// Creating a JFrame & JPanel as required
JFrame frame = new JFrame("Widget"); // with title as Widget
JPanel panel = new JPanel();
// Creating 3 JTextFields
JTextField nameField = new JTextField(20); JTextField ageField = new JTextField(10); JTextField addressField = new JTextField(50);
nameField.setText("John Doe"); ageField.setText("Age 26"); addressField.setText("Silver Spring, Maryland");
// Adding fields in panel
panel.add(nameField); panel.add(ageField); panel.add(addressField);
// Adding panel in Frame
frame.add(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Setting size of frame width & height
frame.setSize(600, 300);
// Making JFrame visible
frame.setVisible(true); } }
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill