public SISCFrame(AppContext ctx) { setLayout(new BorderLayout()); SchemePanel.SchemeDocument d = new SchemePanel.SchemeDocument(); sp = new SchemePanel(ctx, d, new JTextPane(d)); input = new JTextArea(4, 70); input.setText("; Enter s-expressions here"); JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, sp, input); JPanel execPanel = new JPanel(); execPanel.setLayout(new BoxLayout(execPanel, BoxLayout.X_AXIS)); execPanel.add(Box.createHorizontalGlue()); eval = new JButton("Evaluate"); clear = new JButton("Clear"); autoClear = new JCheckBox("Auto-Clear"); submitOnEnter = new JCheckBox("Evaluate on Enter"); autoClear.setSelected(true); submitOnEnter.setSelected(true); execPanel.add(submitOnEnter); execPanel.add(autoClear); execPanel.add(clear); execPanel.add(eval); add(split, BorderLayout.CENTER); add(execPanel, BorderLayout.SOUTH); eval.addActionListener(this); clear.addActionListener(this); input.addKeyListener(this); /* addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });*/ }
private void initGUI() { JPanel pCommand = new JPanel(); pResult = new JPanel(); nsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pCommand, pResult); pCommand.setLayout(new BorderLayout()); pResult.setLayout(new BorderLayout()); Font fFont = new Font("Dialog", Font.PLAIN, 12); txtCommand = new JTextArea(5, 40); txtCommand.setMargin(new Insets(5, 5, 5, 5)); txtCommand.addKeyListener(this); txtCommandScroll = new JScrollPane(txtCommand); txtResult = new JTextArea(20, 40); txtResult.setMargin(new Insets(5, 5, 5, 5)); txtResultScroll = new JScrollPane(txtResult); txtCommand.setFont(fFont); txtResult.setFont(new Font("Courier", Font.PLAIN, 12)); /* // button replaced by toolbar butExecute = new JButton("Execute"); butExecute.addActionListener(this); pCommand.add(butExecute, BorderLayout.EAST); */ pCommand.add(txtCommandScroll, BorderLayout.CENTER); gResult = new GridSwing(); gResultTable = new JTable(gResult); gScrollPane = new JScrollPane(gResultTable); // getContentPane().setLayout(new BorderLayout()); pResult.add(gScrollPane, BorderLayout.CENTER); // Set up the tree rootNode = new DefaultMutableTreeNode("Connection"); treeModel = new DefaultTreeModel(rootNode); tTree = new JTree(treeModel); tScrollPane = new JScrollPane(tTree); tScrollPane.setPreferredSize(new Dimension(120, 400)); tScrollPane.setMinimumSize(new Dimension(70, 100)); txtCommandScroll.setPreferredSize(new Dimension(360, 100)); txtCommandScroll.setMinimumSize(new Dimension(180, 100)); gScrollPane.setPreferredSize(new Dimension(460, 300)); ewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tScrollPane, nsSplitPane); fMain.getContentPane().add(ewSplitPane, BorderLayout.CENTER); doLayout(); fMain.pack(); }
public DistributedTextEditor() { area1.setFont(new Font("Monospaced", Font.PLAIN, 12)); area2.setFont(new Font("Monospaced", Font.PLAIN, 12)); ((AbstractDocument) area1.getDocument()).setDocumentFilter(dec); area2.setEditable(false); Container content = getContentPane(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); JScrollPane scroll1 = new JScrollPane( area1, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); content.add(scroll1, BorderLayout.CENTER); JScrollPane scroll2 = new JScrollPane( area2, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); content.add(scroll2, BorderLayout.CENTER); content.add(ipaddress, BorderLayout.CENTER); content.add(portNumber, BorderLayout.CENTER); JMenuBar JMB = new JMenuBar(); setJMenuBar(JMB); JMenu file = new JMenu("File"); JMenu edit = new JMenu("Edit"); JMB.add(file); JMB.add(edit); file.add(Listen); file.add(Connect); file.add(Disconnect); file.addSeparator(); file.add(Save); file.add(SaveAs); file.add(Quit); edit.add(Copy); edit.add(Paste); edit.getItem(0).setText("Copy"); edit.getItem(1).setText("Paste"); Save.setEnabled(false); SaveAs.setEnabled(false); Disconnect.setEnabled(false); setDefaultCloseOperation(EXIT_ON_CLOSE); pack(); area1.addKeyListener(k1); area1.addMouseListener(m1); setTitle("Disconnected"); setVisible(true); area1.insert("Welcome to Hjortehandlerne's distributed text editor. \n", 0); this.addWindowListener(w1); }
public Gui2() { setTitle("My First Gui"); setSize(600, 600); setLocation(100, 100); setDefaultCloseOperation(EXIT_ON_CLOSE); pane = getContentPane(); // pane.setLayout(new GridLayout(3,3)); pane.setLayout(new FlowLayout()); b1 = new JButton("Click me"); b1.addActionListener(this); pane.add(b1); b2 = new JButton("exit"); b2.addActionListener(this); pane.add(b2); labeler = new JButton("Labeler"); labeler.addActionListener(this); pane.add(labeler); label = new JLabel("The Label:"); pane.add(label); box = new JCheckBox("Cap"); pane.add(box); text = new JTextArea(); text.setColumns(40); text.setRows(5); text.setBorder(BorderFactory.createLineBorder(Color.red, 2)); text.addKeyListener(new Key()); pane.add(text); canvas = new Canvas(); canvas.setPreferredSize(new Dimension(300, 300)); canvas.setBorder(BorderFactory.createLineBorder(Color.blue, 2)); pane.add(canvas); }
public void makeGUI() { frm = new JFrame(); c = frm.getContentPane(); btnImport = new JButton("Import"); btnImport.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureImport(); } }); btnMove = new JButton("Move"); btnMove.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureMove(); } }); btnDelete = new JButton("Delete"); btnDelete.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureDelete(); } }); btnAnalyse = new JButton("Analyse"); btnAnalyse.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureAnalysis(); } }); tblItems = new JTable(store); tblItems.setRowSorter(tableSorter); tblItems.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tblItems.setFillsViewportHeight(true); tblItems.getRowSorter().toggleSortOrder(Storage.COL_DATE); tblItems.addMouseListener( new MouseListener() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { tblItems.setRowSelectionInterval( e.getY() / tblItems.getRowHeight(), e.getY() / tblItems.getRowHeight()); } if (e.getClickCount() > 1 || e.getButton() == MouseEvent.BUTTON3) { int idx = tblItems.convertRowIndexToModel(tblItems.getSelectedRow()); secureExport(idx); } } public void mouseEntered(MouseEvent arg0) {} public void mouseExited(MouseEvent arg0) {} public void mousePressed(MouseEvent arg0) {} public void mouseReleased(MouseEvent arg0) {} }); txaStatus = new JTextArea(TXA_HEIGHT, TXA_WIDTH); txaStatus.setEditable(false); txaStatus.setBorder(BorderFactory.createTitledBorder("Status")); txaSearch = new JTextArea(4, TXA_WIDTH); txaSearch.setBorder(BorderFactory.createTitledBorder("Search")); txaSearch.addKeyListener( new KeyListener() { public void keyPressed(KeyEvent arg0) {} public void keyReleased(KeyEvent arg0) { filterBase(txaSearch.getText()); // EXPORT settings here, as in mass export (export everything) if (allowExport && txaSearch.getText().equalsIgnoreCase(CMD_EXPORT)) { // txaSearch.setText(""); if (JOptionPane.showConfirmDialog( frm, "Do you really want to export the whole secure base?", "Confirm Export", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { totalExport(); } } // LOST X IMPORT asin look through the store for files not listed if (txaSearch.getText().equalsIgnoreCase(CMD_STOCKTAKE)) { for (int i = 0; i < storeLocs.size(); i++) { if (store.stockTake(i)) needsSave = true; } } } public void keyTyped(KeyEvent arg0) {} }); JPanel pnlTop = new JPanel(new GridLayout(1, 4)); JPanel pnlEast = new JPanel(new BorderLayout()); JPanel pnlCenterEast = new JPanel(new BorderLayout()); JScrollPane jspItems = new JScrollPane(tblItems); pnlTop.add(btnImport); pnlTop.add(btnMove); pnlTop.add(btnDelete); pnlTop.add(btnAnalyse); pnlCenterEast.add(txaStatus, BorderLayout.CENTER); pnlCenterEast.add(txaSearch, BorderLayout.NORTH); // pnlEast.add(pswPass, BorderLayout.NORTH); pnlEast.add(pnlCenterEast, BorderLayout.CENTER); c.setLayout(new BorderLayout()); c.add(pnlTop, BorderLayout.NORTH); c.add(pnlEast, BorderLayout.EAST); c.add(jspItems, BorderLayout.CENTER); frm.setContentPane(c); }
public IRCBOT(boolean uList, String channel, int chatNum) { // chatter = new ChatDisplay("<html><body bgcolor='black'><table border=0pt width=100%>"); winNum = chatNum; URL iconURL = getClass().getResource("P_300x300.png"); ImageIcon icon = new ImageIcon(iconURL); setIconImage(icon.getImage()); Action doNothing = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) {} }; channelName = channel; standardWindow = uList; chatInput = new JTextArea(4, 55); chatInput.setWrapStyleWord(true); chatInput.setLineWrap(true); chatInput.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "doNothing"); chatScreen = new JTextPane(); chatScreen.setContentType("text/html"); chatScreen.setEditorKit(kit); chatScreen.setDocument(doc); userList = new JTextPane(); registeredUserList = new JTextPane(); sendButton = new JButton("SEND"); g_start = new JButton("START"); g_end = new JButton("END"); g_reroll = new JButton("secret"); JLabel l_giveaway = new JLabel("Giveaway", JLabel.CENTER); JLabel l_chat = new JLabel("Chat", JLabel.CENTER); JLabel l_uList = new JLabel("User List", JLabel.CENTER); sendButton.addActionListener(this); g_start.addActionListener(this); g_end.addActionListener(this); g_reroll.addActionListener(this); g_start.setEnabled(false); // disabled for basic irc client g_end.setEnabled(false); g_reroll.setEnabled(false); // String start = "<html><body>"; Dimension min = new Dimension(100, 1); Dimension pref = new Dimension(150, 1); Dimension max = new Dimension(600, 600); // chatScreen.setMinimumSize(min); // userList.setMinimumSize(min); // chatInput.addKeyListener(KeyBoardListener); JPanel mainPanel = new JPanel(new BorderLayout(5, 5)); JPanel left = new JPanel(new BorderLayout(5, 5)); JPanel mid = new JPanel(new BorderLayout(5, 5)); JPanel right = new JPanel(new BorderLayout(5, 5)); JPanel giveaway_buttons = new JPanel(new BorderLayout(5, 5)); JPanel sendBar = new JPanel(); scrollChat = new JScrollPane(chatScreen); JScrollPane scrollChatInput = new JScrollPane(chatInput); userListScroll = new JScrollPane(userList); JScrollPane regUserListScroll = new JScrollPane(registeredUserList); userListScroll.setMinimumSize(min); // userListScroll.setPreferredSize(pref); // userListScroll.setMaximumSize(new Dimension(800,600)); // userListScroll.setPreferredSize(new Dimension(100,100)); // scrollChat.setPreferredSize(pref); scrollChat.setMinimumSize(min); // scrollChat.setMaximumSize(new Dimension(500,500)); regUserListScroll.setPreferredSize(pref); mid.add(l_chat, BorderLayout.NORTH); mid.add(scrollChat, BorderLayout.CENTER); right.add(l_uList, BorderLayout.NORTH); right.add(userListScroll, BorderLayout.CENTER); giveaway_buttons.add(g_start, BorderLayout.WEST); giveaway_buttons.add(g_end, BorderLayout.CENTER); giveaway_buttons.add(g_reroll, BorderLayout.PAGE_END); left.add(giveaway_buttons, BorderLayout.PAGE_END); JSplitPane chat_userList = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mid, right); chat_userList.setOneTouchExpandable(true); chat_userList.setDividerLocation(500); chat_userList.setResizeWeight(0.5); chat_userList.setContinuousLayout(true); // chat_userList.setPreferredSize(new Dimension(100,100)); chat_userList.setMinimumSize(min); // chat_userList.setMaximumSize(max); userListScroll.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); // scroll.add(chatScreen); sendBar.add(scrollChatInput); sendBar.add(sendButton); if (standardWindow) { mainPanel.add(chat_userList, BorderLayout.CENTER); mainPanel.add(sendBar, BorderLayout.PAGE_END); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); settings = new JMenuItem("Settings"); settings.addActionListener(this); fileMenu.add(settings); menuBar.add(fileMenu); left.add(l_giveaway, BorderLayout.NORTH); left.add(regUserListScroll, BorderLayout.CENTER); // left.setBorder(new EmptyBorder(0,5,0,0)); // chat_userList.setBorder(new EtchedBorder(0,0,0,5)); mainPanel.add(left, BorderLayout.WEST); mainPanel.add(menuBar, BorderLayout.PAGE_START); // mainPanel.setBorder(new EmptyBorder(0,10,10,10)); } else { mainPanel.add(scrollChat, BorderLayout.CENTER); } registeredUserList.setEditable(false); userList.setEditable(false); chatScreen.setEditable(false); registeredUserList.setFont(new Font("Courier New", Font.PLAIN, 12)); chatScreen.setFont(new Font("Courier New", Font.PLAIN, 12)); chatInput.setFont(new Font("Courier New", Font.PLAIN, 12)); getContentPane().add(mainPanel); setSize(800, 500); setVisible(true); setResizable(true); setLocationRelativeTo(null); setTitle("IRC Chatter"); setMinimumSize(new Dimension(500, 200)); addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { // System.out.println("\n\n\n\n\n\\n\nCLOSEDWINDOW\n\n\n\n\n\n\n\n"); if (sock.isSafe() == true) sock.outputText("PART " + channelName + "\r\n"); // System.out.println("\n\n\n\n\n\\n\nCLOSEDWINDOW\n\n\n\n\n\n\n\n"); } }); chatInput.addKeyListener(this); chatInput.requestFocus(); }
/** Constructor to create the frame and its components */ public CoreyTextEditor() { // Create a scroll pane area.setFont(new Font("Monospaced", Font.PLAIN, 12)); JScrollPane scroll = new JScrollPane( area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); add(scroll, BorderLayout.CENTER); // Adds the system default look and feel try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | UnsupportedLookAndFeelException | IllegalAccessException e) { e.printStackTrace(); } // Create a menu bar JMenuBar JMB = new JMenuBar(); setJMenuBar(JMB); JMenu file = new JMenu("File"); JMenu edit = new JMenu("Edit"); JMB.add(file); JMB.add(edit); // Finishing our menu bar file.add(New); file.add(Open); file.add(Save); file.add(SaveAs); file.addSeparator(); file.add(Quit); edit.add(Cut); edit.add(Copy); edit.add(Paste); edit.getItem(0).setText("Cut"); edit.getItem(0).setIcon(new ImageIcon("cut.gif")); edit.getItem(1).setText("Copy"); edit.getItem(1).setIcon(new ImageIcon("copy.gif")); edit.getItem(2).setText("Paste"); edit.getItem(2).setIcon(new ImageIcon("paste.gif")); // Time to make a toolbar! JToolBar tool = new JToolBar(); add(tool, BorderLayout.NORTH); tool.add(New); tool.add(Open); tool.add(Save); tool.addSeparator(); JButton cut = tool.add(Cut); JButton cop = tool.add(Copy); JButton pas = tool.add(Paste); cut.setText(null); cut.setIcon(new ImageIcon("cut.gif")); cop.setText(null); cop.setIcon(new ImageIcon("copy.gif")); pas.setText(null); pas.setIcon(new ImageIcon("paste.gif")); Save.setEnabled(false); SaveAs.setEnabled(false); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); pack(); /* KeyListener to change Save and SaveAs */ KeyListener k1 = new KeyAdapter() { public void keyPressed(KeyEvent e) { changed = true; Save.setEnabled(true); SaveAs.setEnabled(true); } }; area.addKeyListener(k1); setTitle(currentFile + " - CoreyTextEditor"); setVisible(true); }