Hello,

I am trying to write a simple program that takes input from the fields I have created for the following UI and writes them to a command prompt. Can someone help me with the next step.... getting the input entered and writing it to the prompt? I would also like the buildLicenseButton to be the one to execute this write method and the quitButton to close the app. Any help is appreciated. Here is the source.

//
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import javax.swing.*;

public class newbuildcode extends Applet {
    JComboBox productComboBox;
    JTextField verstionTextField;
    ButtonGroup cbg;
    JRadioButton maintRadioButton;
    JRadioButton button_4;
    JTextField nodeTextField;
    JTextField userTextField;
    JTextField serialTextField;
    JTextField outputTextField;
    JTextField expirationTextField;
    JButton quitButton;
    JLabel productLabel;
    JLabel versionLabel;
    JLabel licenseLabel;
    JLabel nodeLabel;
    JLabel userLabel;
    JLabel serialLabel;
    JLabel outputLabel;
    JLabel expirationLabel1;
    JButton buildLicenseButton;
    JLabel expirationLabel2;

    public void init() {
        newbuildcodeLayout customLayout = new newbuildcodeLayout();

        setFont(new Font("Helvetica", Font.PLAIN, 12));
        setLayout(customLayout);
       
        productComboBox = new JComboBox();
        productComboBox.addItem("avalanche");
        productComboBox.addItem("mobile manager");
        productComboBox.addItem("sensor");
        productComboBox.addItem("remote control");
        productComboBox.addItem("ce secure");
        productComboBox.addItem("cert manager");
        productComboBox.addItem("terminal emulation");
        productComboBox.addItem("communicator");
        productComboBox.setToolTipText("Select a product from the dropdown menu");
        add(productComboBox);

        verstionTextField = new JTextField("");
        verstionTextField.setToolTipText("Enter the Version of the Product");
        add(verstionTextField);

        cbg = new ButtonGroup();
        maintRadioButton = new JRadioButton("Maint", false);
        maintRadioButton.setBackground(Color.white);
        maintRadioButton.setToolTipText("Check this checkbox for a Maintenance License");
        cbg.add(maintRadioButton);
        add(maintRadioButton);

        button_4 = new JRadioButton("Base", false);
        button_4.setBackground(Color.white);
        button_4.setToolTipText("Check this checkbox for a Maintenance License");
        cbg.add(button_4);
        add(button_4);

        nodeTextField = new JTextField("");
        add(nodeTextField);

        userTextField = new JTextField("");
        add(userTextField);

        serialTextField = new JTextField("");
        userTextField.setBackground(Color.pink);
        add(serialTextField);

        outputTextField = new JTextField("");
        add(outputTextField);

        expirationTextField = new JTextField("");
        add(expirationTextField);

        quitButton = new JButton("Quit");
        add(quitButton);

        productLabel = new JLabel("Product");
        add(productLabel);

        versionLabel = new JLabel("Version");
        add(versionLabel);

        licenseLabel = new JLabel("License Type:");
        add(licenseLabel);

        nodeLabel = new JLabel("Node Lock");
        add(nodeLabel);

        userLabel = new JLabel("User Limit");
        add(userLabel);

        serialLabel = new JLabel("32 char key");
        add(serialLabel);

        outputLabel = new JLabel("Output Path");
        add(outputLabel);

        expirationLabel1 = new JLabel("Expiration");
        add(expirationLabel1);

        buildLicenseButton = new JButton("Build .lic");
        add(buildLicenseButton);

        expirationLabel2 = new JLabel("Ex. MMDDYYYY");
        add(expirationLabel2);

        setSize(getPreferredSize());

    }

    public static void main(String args[]) {
        newbuildcode applet = new newbuildcode();
        Frame window = new Frame("WLBuildCode");
     

        window.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        applet.init();
        window.add("Center", applet);
        window.pack();
        window.setVisible(true);
        window.setResizable(false);
        window.setVisible(true);
        window.setFont(null);
        window.setForeground(Color.pink);
        window.setBackground(Color.cyan);
        
        
        
    	}
    	
}

class newbuildcodeLayout implements LayoutManager {

    public newbuildcodeLayout() {
    }

    public void addLayoutComponent(String name, Component comp) {
    }

    public void removeLayoutComponent(Component comp) {
    }

    public Dimension preferredLayoutSize(Container parent) {
        Dimension dim = new Dimension(0, 0);

        Insets insets = parent.getInsets();
        dim.width = 279 + insets.left + insets.right;
        dim.height = 248 + insets.top + insets.bottom;

        return dim;
    }

    public Dimension minimumLayoutSize(Container parent) {
        Dimension dim = new Dimension(0, 0);
        return dim;
    }

    public void layoutContainer(Container parent) {
        Insets insets = parent.getInsets();

        Component c;
        c = parent.getComponent(0);
        if (c.isVisible()) {c.setBounds(insets.left+88,insets.top+16,184,16);}
        c = parent.getComponent(1);
        if (c.isVisible()) {c.setBounds(insets.left+88,insets.top+40,184,16);}
        c = parent.getComponent(2);
        if (c.isVisible()) {c.setBounds(insets.left+88,insets.top+64,96,16);}
        c = parent.getComponent(3);
        if (c.isVisible()) {c.setBounds(insets.left+184,insets.top+64,88,16);}
        c = parent.getComponent(4);
        if (c.isVisible()) {c.setBounds(insets.left+88,insets.top+88,184,16);}
        c = parent.getComponent(5);
        if (c.isVisible()) {c.setBounds(insets.left+88,insets.top+112,184,16);}
        c = parent.getComponent(6);
        if (c.isVisible()) {c.setBounds(insets.left+88,insets.top+136,184,16);}
        c = parent.getComponent(7);
        if (c.isVisible()) {c.setBounds(insets.left+88,insets.top+160,184,16);}
        c = parent.getComponent(8);
        if (c.isVisible()) {c.setBounds(insets.left+88,insets.top+184,96,16);}
        c = parent.getComponent(9);
        if (c.isVisible()) {c.setBounds(insets.left+144,insets.top+208,88,24);}
        c = parent.getComponent(10);
        if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+16,80,16);}
        c = parent.getComponent(11);
        if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+40,80,16);}
        c = parent.getComponent(12);
        if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+64,80,16);}
        c = parent.getComponent(13);
        if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+88,80,16);}
        c = parent.getComponent(14);
        if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+112,80,16);}
        c = parent.getComponent(15);
        if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+136,80,16);}
        c = parent.getComponent(16);
        if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+160,80,16);}
        c = parent.getComponent(17);
        if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+184,80,16);}
        c = parent.getComponent(18);
        if (c.isVisible()) {c.setBounds(insets.left+40,insets.top+208,88,24);}
        c = parent.getComponent(19);
        if (c.isVisible()) {c.setBounds(insets.left+184,insets.top+184,88,16);}
    }
}
stephen84s commented: Followed advice on code tags readily with too much of a fuss. +6

Recommended Answers

All 3 Replies

Wrap your code inside code tags.

Like this:-

[code=java] // Your code here

[/code]


Here is a tutorial on implementing the ActionListener which you will want to catch your events when your button is clicked.

Sorry, this was my first post.
Thanks for the info, I will do that from now on.

Thanks for the tutorial. That should be the information that I need.
I appreciate the assistance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.