Ok
the tut: [Only registered and activated users can see links. ]
I have
Code:
/*
* Class Gui
*
* Version 1.0
*
* Wednesday September 23, 2009
*
* Created by Hunter
*/
package net.com.codeusa;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Gui extends JFrame {
static private JTextField textkick;
private JLabel textt;
private JButton button1;
private JPanel panel;
public Gui() {
super("Control Panel"); // The title bar
setLayout(new FlowLayout()); // This is the layout of the Gui
JPanel panel = new JPanel(new GridBagLayout());
textt = new JLabel("Enter a name to kick.");
textkick = new JTextField("Enter a username to kick");
textkick.setToolTipText("Type in the username to kick here.");
button1 = new JButton("KICK"); //button on the gui
button1.setToolTipText("Click to kick."); //Hover text
add(panel);
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0; //Position of textt
c.gridy = 0; // All of these are the X, Y position of the selected item
panel.add(textt, c); //For example, here the selected item is "textt"
c.gridx = 0;
c.gridy = 50;
panel.add(textkick, c);
c.gridx = 0;
c.gridy = 100;
panel.add(button1, c);
button1.addActionListener(new Action()); //Adds an ActionListener to button1
}
static class Action implements ActionListener {
public void actionPerformed (ActionEvent e) {
String kickwho = textkick.getText(); // Gets the text for textkick
//Here, you still need to add where it kicks "kickwho" kick who is what
//Is in the textField
System.out.println("Kicked "+kickwho+" from the server."); //What happens when button1 is clicked
}
}
}
I have no idea what to put in
//Here, you still need to add where it kicks "kickwho" kick who is what
//Is in the textField
Can someone show me an example of a working GUI? Or tell me what to put there? I just need an example so i can learn what to do!