Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import javax.swing.JTextField;
- import javax.swing.JButton;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- import javax.swing.JTextPane;
- import javax.swing.JLabel;
- import javax.swing.JPasswordField;
- import javax.swing.JScrollPane;
- import javax.swing.JSeparator;
- import javax.swing.SwingConstants;
- import javax.swing.text.DefaultCaret;
- import javax.swing.JTextArea;
- import java.awt.Font;
- public class Console {
- private JFrame frame;
- private JTextField usernameField;
- private JPasswordField passwordField;
- private JTextField commandBox;
- private static JScrollPane scroll;
- private static JTextArea chat;
- private static JLabel loginError;
- private static JLabel lblYes;
- private static JLabel lblNo;
- private static MCBotMain bot = new MCBotMain();
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- bot.readWhitelist();
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- Console window = new Console();
- window.frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the application.
- */
- public Console() {
- initialize();
- }
- /**
- * Initialize the contents of the frame.
- */
- public static void loginError(){ //Change login sucess indicator text on login error
- loginError.setText("Login Failed");
- }
- public static void loginSuccess(){ //Change login sucess indicator text on success of login
- loginError.setText("Successful Login");
- }
- private void initialize() {
- frame = new JFrame();
- frame.setBounds(100, 100, 1000, 593);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.getContentPane().setLayout(null);
- usernameField = new JTextField();
- usernameField.setBounds(117, 68, 308, 26);
- frame.getContentPane().add(usernameField);
- usernameField.setColumns(10);
- passwordField = new JPasswordField();
- passwordField.setBounds(117, 106, 308, 26);
- frame.getContentPane().add(passwordField);
- JLabel lblUsername = new JLabel("Username:");
- lblUsername.setBounds(12, 73, 93, 16);
- frame.getContentPane().add(lblUsername);
- JLabel lblNewLabel = new JLabel("Password:");
- lblNewLabel.setBounds(12, 111, 93, 16);
- frame.getContentPane().add(lblNewLabel);
- JButton btnLogin = new JButton("Login");
- btnLogin.setBounds(172, 144, 117, 29);
- btnLogin.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) { //Log in to ECC
- MCBotMain.recieveCredentials(usernameField.getText(),passwordField.getText());
- }
- });
- frame.getContentPane().add(btnLogin);
- JSeparator separator = new JSeparator();
- separator.setBounds(6, 175, 450, 12);
- frame.getContentPane().add(separator);
- JLabel lblBotAccountLogin = new JLabel("Bot Account Login");
- lblBotAccountLogin.setBounds(154, 23, 135, 33);
- lblBotAccountLogin.setHorizontalAlignment(SwingConstants.CENTER);
- frame.getContentPane().add(lblBotAccountLogin);
- commandBox = new JTextField();
- commandBox.setBounds(12, 524, 540, 26);
- frame.getContentPane().add(commandBox);
- commandBox.setColumns(10);
- JButton btnEnter = new JButton("Enter");
- btnEnter.setBounds(555, 524, 117, 29);
- btnEnter.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) { //Send command from console
- MCBotMain bot = new MCBotMain();
- bot.sendMessage(commandBox.getText());
- commandBox.setText("");
- }
- });
- frame.getContentPane().add(btnEnter);
- scroll = new JScrollPane();
- scroll.setBounds(12, 199, 982, 313);
- frame.getContentPane().add(scroll);
- chat = new JTextArea();
- chat.setLineWrap(true);
- chat.setEditable(false);
- scroll.setViewportView(chat);
- loginError = new JLabel("");
- loginError.setBounds(301, 149, 179, 16);
- frame.getContentPane().add(loginError);
- DefaultCaret caret = (DefaultCaret) chat.getCaret();
- caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
- }
- public static void updateChat(String incomingMessage){ //Update chat box with incoming input
- chat.append("\n");
- chat.append(incomingMessage);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement