Advertisement
xXm0dzXx

TabbedPane.Java

Apr 15th, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.50 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.event.*;
  3. import java.io.Writer;
  4.  
  5. public class TabbedPane extends JFrame {
  6.    
  7.     public static String targetIP;
  8.     public static String targetPort;
  9.     JTextField log = new JTextField("localhost", 13);
  10.     JTextField port = new JTextField("25565", 13);
  11.     JButton test = new JButton("Start");
  12.     JTextArea ip = new JTextArea("~~~ SpamBot By m0dz ~~~ \n", 13, 20);
  13.    
  14.     public TabbedPane() {
  15.        
  16.          //This will create the title you see in the upper left of the window    
  17.         setTitle("Spambot (By m0dz)");  
  18.         setSize(400,600); //set size so the user can "see" it
  19.         //Here we are creating the object
  20.         JTabbedPane jtp = new JTabbedPane();
  21.  
  22.         //This creates the template on the windowed application that we will be using
  23.        getContentPane().add(jtp);
  24.  
  25.        JPanel jp1 = new JPanel();//This will create the first tab
  26.  
  27.        JPanel jp2 = new JPanel();//This will create the second tab
  28.        
  29.          //This creates a non-editable label, sets what the label will read
  30.         //and adds the label to the first tab
  31.        JLabel label1 = new JLabel();
  32.        label1.setText("IP Adress:");
  33.        jp1.add(label1);
  34.        jp1.add(log);
  35.        jp1.add(port);
  36.        
  37.        //This adds the first and second tab to our tabbed pane object and names it
  38.        jtp.addTab("Main", jp1);
  39.        jtp.addTab("Log", jp2);
  40.  
  41.         //This creates a new button called "Press" and adds it to the second tab
  42.        jp2.add(ip);
  43.        ip.setEnabled( false );
  44.        jp2.setLayout(new BoxLayout(jp2, BoxLayout.PAGE_AXIS));
  45.        jp2.add(test);
  46.  
  47.         //This is an Action Listener which reacts to clicking on
  48.         //the test button called "Press"
  49.         ButtonHandler phandler = new ButtonHandler();
  50.         test.addActionListener(phandler);
  51.         setVisible(true); //otherwise you won't "see" it
  52.     }
  53.    
  54.     //This is the internal class that defines what the above Action Listener
  55.     //will do when the test button is pressed.
  56.     class ButtonHandler implements ActionListener{
  57.            public void actionPerformed(ActionEvent e){
  58.                    targetIP = log.getText();
  59.                    targetPort = port.getText();
  60.                    test.setEnabled( false );
  61.                    ip.setText(ip.getText() + "Logging in to " + targetIP + ":" + targetPort + "... \n");
  62.            }
  63.     }
  64.  
  65.     //example usage
  66.      public static void main (String []args){
  67.         TabbedPane tab = new TabbedPane();
  68.     }
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement