SHARE
TWEET

WIP GUI for Command Line

EmreTech May 22nd, 2019 (edited) 184 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import javax.swing.*;
  2. import javax.swing.text.*;
  3. import java.awt.*;
  4. import java.awt.event.ActionListener;
  5. import java.awt.event.ActionEvent;
  6.  
  7. public class GUI {
  8.     public JFrame frame;
  9.        public JTextPane console;
  10.        public JTextField input;
  11.        public JScrollPane scrollpane;
  12.        public StyledDocument document;
  13.        boolean trace = false;
  14.        public CommandLine central = new CommandLine();
  15.        public static String text;
  16.    @SuppressWarnings("static-access")
  17.     public static void main(String[] args) {
  18.         new GUI();
  19.         CommandLine central = new CommandLine();
  20.         central.main(text);
  21.        
  22.    }
  23.  
  24.    
  25.  
  26.    public GUI() {
  27.         try {
  28.             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  29.         } catch (Exception ex) {}
  30.         frame = new JFrame();
  31.         frame.setTitle("Command Line");
  32.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  33.         console = new JTextPane();
  34.         console.setForeground(Color.BLACK);
  35.         console.setEditable(false);
  36.         console.setFont(new Font("Courier New", Font.PLAIN, 13));
  37.         console.setOpaque(false);
  38.  
  39.         document = console.getStyledDocument();
  40.  
  41.         input = new JTextField();
  42.         input.setBorder(null);
  43.         input.setBounds(0, 303, 528, 25);
  44.         input.setEditable(true);
  45.         input.setFont(new Font("Courier New", Font.PLAIN, 13));
  46.         input.setBackground(Color.WHITE);
  47.         input.setForeground(Color.WHITE);
  48.         input.setCaretColor(Color.GREEN);
  49.         input.setOpaque(false);
  50.         scrollpane = new JScrollPane(console);
  51.         scrollpane.setBounds(0, 0, 660, 303);
  52.         scrollpane.setBorder(null);
  53.         scrollpane.setOpaque(false);
  54.         scrollpane.getViewport().setOpaque(false);
  55.         frame.getContentPane().setLayout(null);
  56.         frame.getContentPane().add(input);
  57.         frame.getContentPane().add(scrollpane);
  58.         frame.getContentPane().setBackground(new Color(40, 40, 40));
  59.        
  60.         JButton submit = new JButton("Enter");
  61.         submit.addActionListener(new ActionListener() {
  62.             public void actionPerformed(ActionEvent e) {
  63.                 text = input.getText();
  64.                
  65.             }
  66.         });
  67.         submit.setBounds(540, 301, 120, 29);
  68.         frame.getContentPane().add(submit);
  69.         frame.setLocationRelativeTo(null);
  70.         frame.setSize(660, 350);
  71.         frame.setResizable(true);
  72.         frame.setVisible(true);
  73.    }
  74. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top