public static void main(String[] args) { final JPopupMenu menu = new JPopupMenu(); menu.setLayout(new GridLayout(0, 3, 5, 5)); final MenuedButton button = new MenuedButton("Icons", menu); for (int i = 0; i < 9; i++) { // replace "print.gif" with your own image final JLabel label = new JLabel("" + i); // new ImageIcon("resources/images/print.gif") ); label.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { button.getMainButton().setIcon(label.getIcon()); menu.setVisible(false); } }); menu.add(label); } JFrame frame = new JFrame("Button Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new JLabel("Click Arrow Button To Show Popup"), BorderLayout.NORTH); frame.getContentPane().add(button, BorderLayout.CENTER); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
public void Window() { JFrame f = new JFrame("test"); f.setSize(570, 383); f.add(new test()); f.setLocationRelativeTo(null); f.setResizable(false); f.setVisible(true); }
public static void main(String args[]) { JFrame frame = new CopyFileToTable(); frame.setTitle("CopyFileToTable"); frame.setSize(700, 200); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); }
/** Create the entire GUI from scratch */ private void createGUI() { clientFrame = new JFrame("LeetFTP"); // Allow program to exit gracefully clientFrame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); createTabs(); createMenu(); // Top Options Bar connectButton = new JButton("Connect"); connectButton.addMouseListener(mouseHandler); optionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); optionPanel.add(connectButton); optionPanel.add(new JLabel("Name Server Hostname")); optionPanel.add(serverTextField); optionPanel.add(new JLabel("Port #")); optionPanel.add(portTextField); optionPanel.add(new JLabel("UserName")); optionPanel.add(nameTextField); // Bottom Transfer Table transferTable = new JTable(); transferPanel = new JPanel(new BorderLayout()); transferPanel.add(new JLabel("Current Transfers:"), BorderLayout.NORTH); transferPanel.add(transferTable); // Make the tab pane the GUI pane clientFrame.getContentPane().setLayout(new BorderLayout()); clientFrame.getContentPane().add(mainPanel); clientFrame.getContentPane().add(optionPanel, BorderLayout.NORTH); clientFrame.getContentPane().add(transferPanel, BorderLayout.SOUTH); // Set Client Window Properties clientFrame.setSize(800, 600); // clientFrame.setResizable(false); clientFrame.setLocationRelativeTo(null); clientFrame.setVisible(true); }
public Fenetre() { frame = new JFrame(); frame.setTitle("Gestion Sauvegarde Serveur"); frame.setSize(700, 600); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setIconImage( Toolkit.getDefaultToolkit().getImage(getClass().getResource("/go-home.png"))); frame.setResizable(true); frame.setLocationRelativeTo(null); frame.setUndecorated(false); frame.setBackground(Color.white); frame.setContentPane(contentPane()); frame.setVisible(true); }
public static void createAndShowGUI() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } JFrame frame = new JFrame("@title@"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(new MainPanel()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); // UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); // UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); // UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception ex) { System.err.println(ex); } JFrame frame = new JFrame("E+ idf TextPanel test"); frame.getContentPane().add(new EPlusEditorPanel()); // frame.getContentPane().add(new EPlusTextPanel (null, null, 1, null, null, null)); frame.setSize(800, 800); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
public void startGui() { JTerminalListener listener = new JTerminalListener(); jFrame = new JFrame("Glowstone"); jTerminal = new JTerminal(); jInput = new JTextField(80) { @Override public void setBorder(Border border) {} }; jInput.paint(null); jInput.setFont(new Font("Monospaced", Font.PLAIN, 12)); jInput.setBackground(Color.BLACK); jInput.setForeground(Color.WHITE); jInput.setMargin(new Insets(0, 0, 0, 0)); jInput.addKeyListener(listener); JLabel caret = new JLabel("> "); caret.setFont(new Font("Monospaced", Font.PLAIN, 12)); caret.setForeground(Color.WHITE); JPanel ipanel = new JPanel(); ipanel.add(caret, BorderLayout.WEST); ipanel.add(jInput, BorderLayout.EAST); ipanel.setBorder(BorderFactory.createEmptyBorder()); ipanel.setBackground(Color.BLACK); ipanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); ipanel.setSize(jTerminal.getWidth(), ipanel.getHeight()); jFrame.getContentPane().add(jTerminal, BorderLayout.NORTH); jFrame.getContentPane().add(ipanel, BorderLayout.SOUTH); jFrame.addWindowListener(listener); jFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); jFrame.setLocationRelativeTo(null); jFrame.pack(); jFrame.setVisible(true); sender = new ColoredCommandSender(); logger.removeHandler(consoleHandler); logger.addHandler( new StreamHandler(new TerminalOutputStream(), new DateOutputFormatter(CONSOLE_DATE))); }
JFrame openMonitorGUI(String title) { try { MonitorGUI gui = new MonitorGUI(this, title); JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.addWindowListener(this); frame.getContentPane().add(gui); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle r = ge.getMaximumWindowBounds(); frame.setSize(400, 200); frame.setLocationRelativeTo(null); frame.pack(); frame.setVisible(true); return frame; } catch (Exception e) { System.out.println("9\b" + getClass().getName() + "\n\t" + e); return null; } }
public static void createAndShowGUI() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } // UIManager.put("AuditoryCues.playList", UIManager.get("AuditoryCues.allAuditoryCues")); // UIManager.put("AuditoryCues.playList", UIManager.get("AuditoryCues.defaultCueList")); // UIManager.put("AuditoryCues.playList", UIManager.get("AuditoryCues.noAuditoryCues")); UIManager.put("AuditoryCues.playList", OPTION_PANE_AUDITORY_CUES); // UIManager.put("OptionPane.informationSound", "/example/notice2.wav"); // UIManager.put("OptionPane.informationSound", "sounds/OptionPaneError.wav"); // System.out.println(UIManager.get("AuditoryCues.actionMap")); JFrame frame = new JFrame("@title@"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(new MainPanel()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
private static void initGui() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception exception) { exception.printStackTrace(); } JFrame frame = new JFrame("DarkBot"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridBagLayout()); Insets noInsets = new Insets(0, 0, 0, 0); final JToggleButton sessionsButton = new JToggleButton("Login (0)"); frame.add( sessionsButton, new GridBagConstraints( 0, 0, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0)); sessionsButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { sessions.set(sessionsButton.isSelected()); synchronized (sessions) { sessions.notifyAll(); } } }); final JToggleButton joinsButton = new JToggleButton("Join (0)"); frame.add( joinsButton, new GridBagConstraints( 0, 1, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0)); joinsButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { joins.set(joinsButton.isSelected()); synchronized (joins) { joins.notifyAll(); } } }); final JTextField field = new JTextField(); frame.add( field, new GridBagConstraints( 0, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0)); final JButton button = new JButton("Start"); frame.add( button, new GridBagConstraints( 1, 2, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0)); button.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (button.getText().startsWith("Start")) { field.setEnabled(false); spamMessage = field.getText(); button.setText("Stop"); } else { spamMessage = null; button.setText("Start"); field.setEnabled(true); } } }); Timer timer = new Timer( 500, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { sessionsButton.setText( sessionsButton.getText().split(" ")[0] + " (" + Integer.toString(sessionCount.get()) + ")"); joinsButton.setText( joinsButton.getText().split(" ")[0] + " (" + Integer.toString(amountJoined.get()) + ")"); } }); timer.setRepeats(true); timer.start(); frame.pack(); frame.setSize(500, frame.getHeight()); frame.setLocationRelativeTo(null); frame.setVisible(true); }
public View(Model model) { this.model = model; model.makeMeObserver(this); frame = new JFrame(); statusbar = new JLabel(" 0"); board = new Board(); frame.add(board); JMenuBar menubar = new JMenuBar(); JMenu file = new JMenu("Settings"); file.setMnemonic(KeyEvent.VK_F); JMenuItem eMenuItem = new JMenuItem("New game"); eMenuItem.setToolTipText("Start a new game"); eMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { menuEvent = -1; setChanged(); notifyObservers(); menuEvent = 0; } }); file.add(eMenuItem); eMenuItem = new JMenuItem("Pause"); eMenuItem.setMnemonic(KeyEvent.VK_P); eMenuItem.setToolTipText("Set pause"); eMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { menuEvent = 1; setChanged(); notifyObservers(); menuEvent = 0; } }); file.add(eMenuItem); JMenu imp = new JMenu("Set level"); imp.setMnemonic(KeyEvent.VK_M); JMenuItem lvl1 = new JMenuItem("level 1"); lvl1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { menuEvent = 2; setChanged(); notifyObservers(); menuEvent = 0; } }); JMenuItem lvl2 = new JMenuItem("level 2"); lvl2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { menuEvent = 3; setChanged(); notifyObservers(); menuEvent = 0; } }); JMenuItem lvl3 = new JMenuItem("level 3"); lvl3.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { menuEvent = 4; setChanged(); notifyObservers(); menuEvent = 0; } }); JMenuItem lvl4 = new JMenuItem("level 4"); lvl4.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { menuEvent = 5; setChanged(); notifyObservers(); menuEvent = 0; } }); JMenuItem lvl5 = new JMenuItem("level 5"); lvl5.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { menuEvent = 6; setChanged(); notifyObservers(); menuEvent = 0; } }); imp.add(lvl1); imp.add(lvl2); imp.add(lvl3); imp.add(lvl4); imp.add(lvl5); file.add(imp); eMenuItem = new JMenuItem("Table of recorgs"); eMenuItem.setToolTipText("Show table of records"); eMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { recordDialog ad; try { ad = new recordDialog(); ad.setVisible(true); } catch (IOException e) { e.printStackTrace(); } } }); file.add(eMenuItem); eMenuItem = new JMenuItem("Exit"); eMenuItem.setMnemonic(KeyEvent.VK_C); eMenuItem.setToolTipText("Exit application"); eMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); file.add(eMenuItem); menubar.add(file); frame.setJMenuBar(menubar); statusbar.setPreferredSize(new Dimension(-1, 22)); statusbar.setBorder(LineBorder.createGrayLineBorder()); frame.add(statusbar, BorderLayout.SOUTH); frame.setSize(200, 400); frame.setTitle("Tetris"); frame.setLocationRelativeTo(null); }
public static void main(String args[]) throws Exception { final JFrame frame = new JFrame(); final JTextArea textArea = new JTextArea(30, 60); final JScrollPane scrollPane = new JScrollPane(textArea); frame.getContentPane().add(scrollPane); JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); JMenu menu = new JMenu("File"); ScreenCapture.createImage(menu, "menu.jpg"); menuBar.add(menu); JMenuItem menuItem = new JMenuItem("Frame Image"); menu.add(menuItem); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // Let the menu close and repaint itself before taking the image new Thread() { public void run() { try { Thread.sleep(50); System.out.println("Creating frame.jpg"); frame.repaint(); ScreenCapture.createImage(frame, "frame.jpg"); } catch (Exception exc) { System.out.println(exc); } } }.start(); }; }); final JButton button = new JButton("Create Images"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { System.out.println("Creating desktop.jpg"); ScreenCapture.createDesktopImage("desktop.jpg"); System.out.println("Creating frame.jpg"); ScreenCapture.createImage(frame, "frame.jpg"); System.out.println("Creating scrollpane.jpg"); ScreenCapture.createImage(scrollPane, "scrollpane.jpg"); System.out.println("Creating textarea.jpg"); ScreenCapture.createImage(textArea, "textarea.jpg"); System.out.println("Creating button.jpg"); ScreenCapture.createImage(button, "button.jpg"); button.setText("button refreshed"); button.paintImmediately(button.getBounds()); System.out.println("Creating refresh.jpg"); ScreenCapture.createImage(button, "refresh.jpg"); System.out.println("Creating region.jpg"); Rectangle r = new Rectangle(0, 0, 100, 16); ScreenCapture.createImage(textArea, r, "region.png"); } catch (Exception exc) { System.out.println(exc); } } }); frame.getContentPane().add(button, BorderLayout.SOUTH); try { FileReader fr = new FileReader("ScreenCapture.java"); BufferedReader br = new BufferedReader(fr); textArea.read(br, null); br.close(); } catch (Exception e) { } frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
public Ssys3() { store = new Storage(); tableSorter = new TableRowSorter<Storage>(store); jobs = new LinkedList<String>(); makeGUI(); frm.setSize(800, 600); frm.addWindowListener( new WindowListener() { public void windowActivated(WindowEvent evt) {} public void windowClosed(WindowEvent evt) { try { System.out.println("joining EDT's"); for (EDT edt : encryptDecryptThreads) { edt.weakStop(); try { edt.join(); System.out.println(" - joined"); } catch (InterruptedException e) { System.out.println(" - Not joined"); } } System.out.println("saving storage"); store.saveAll(tempLoc); } catch (IOException e) { e.printStackTrace(); System.err.println( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nFailed to save properly\n\n!!!!!!!!!!!!!!!!!!!!!!!!!"); System.exit(1); } clean(); System.exit(0); } public void windowClosing(WindowEvent evt) { windowClosed(evt); } public void windowDeactivated(WindowEvent evt) {} public void windowDeiconified(WindowEvent evt) {} public void windowIconified(WindowEvent evt) {} public void windowOpened(WindowEvent evt) {} }); ImageIcon ico = new ImageIcon(ICON_NAME); frm.setIconImage(ico.getImage()); frm.setLocationRelativeTo(null); frm.setVisible(true); // load config storeLocs = new ArrayList<File>(); String ossl = "openssl"; int numThreadTemp = 2; boolean priorityDecryptTemp = true; boolean allowExportTemp = false; boolean checkImportTemp = true; try { Scanner sca = new Scanner(CONF_FILE); while (sca.hasNextLine()) { String ln = sca.nextLine(); if (ln.startsWith(CONF_SSL)) { ossl = ln.substring(CONF_SSL.length()); } else if (ln.startsWith(CONF_THREAD)) { try { numThreadTemp = Integer.parseInt(ln.substring(CONF_THREAD.length())); } catch (Exception exc) { // do Nothing } } else if (ln.equals(CONF_STORE)) { while (sca.hasNextLine()) storeLocs.add(new File(sca.nextLine())); } else if (ln.startsWith(CONF_PRIORITY)) { try { priorityDecryptTemp = Boolean.parseBoolean(ln.substring(CONF_PRIORITY.length())); } catch (Exception exc) { // do Nothing } } else if (ln.startsWith(CONF_EXPORT)) { try { allowExportTemp = Boolean.parseBoolean(ln.substring(CONF_EXPORT.length())); } catch (Exception exc) { // do Nothing } } else if (ln.startsWith(CONF_CONFIRM)) { try { checkImportTemp = Boolean.parseBoolean(ln.substring(CONF_CONFIRM.length())); } catch (Exception exc) { // do Nothing } } } sca.close(); } catch (IOException e) { } String osslWorks = OpenSSLCommander.test(ossl); while (osslWorks == null) { ossl = JOptionPane.showInputDialog( frm, "Please input the command used to run open ssl\n We will run \"<command> version\" to confirm\n Previous command: " + ossl, "Find open ssl", JOptionPane.OK_CANCEL_OPTION); if (ossl == null) { System.err.println("Refused to provide openssl executable location"); System.exit(1); } osslWorks = OpenSSLCommander.test(ossl); if (osslWorks == null) JOptionPane.showMessageDialog( frm, "Command " + ossl + " unsuccessful", "Unsuccessful", JOptionPane.ERROR_MESSAGE); } if (storeLocs.size() < 1) JOptionPane.showMessageDialog( frm, "Please select an initial sotrage location\nIf one already exists, or there are more than one, please select it"); while (storeLocs.size() < 1) { JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (jfc.showOpenDialog(frm) != JFileChooser.APPROVE_OPTION) { System.err.println("Refused to provide an initial store folder"); System.exit(1); } File sel = jfc.getSelectedFile(); if (sel.isDirectory()) storeLocs.add(sel); } numThreads = numThreadTemp; priorityExport = priorityDecryptTemp; allowExport = allowExportTemp; checkImports = checkImportTemp; try { PrintWriter pw = new PrintWriter(CONF_FILE); pw.println(CONF_SSL + ossl); pw.println(CONF_THREAD + numThreads); pw.println(CONF_PRIORITY + priorityExport); pw.println(CONF_EXPORT + allowExport); pw.println(CONF_CONFIRM + checkImports); pw.println(CONF_STORE); for (File fi : storeLocs) { pw.println(fi.getAbsolutePath()); } pw.close(); } catch (IOException e) { System.err.println("Failed to save config"); } File chk = null; for (File fi : storeLocs) { File lib = new File(fi, LIBRARY_NAME); if (lib.exists()) { chk = lib; // break; } } char[] pass = null; if (chk == null) { JOptionPane.showMessageDialog( frm, "First time run\n Create your password", "Create Password", JOptionPane.INFORMATION_MESSAGE); char[] p1 = askPassword(); char[] p2 = askPassword(); boolean same = p1.length == p2.length; for (int i = 0; i < Math.min(p1.length, p2.length); i++) { if (p1[i] != p2[i]) same = false; } if (same) { JOptionPane.showMessageDialog( frm, "Password created", "Create Password", JOptionPane.INFORMATION_MESSAGE); pass = p1; } else { JOptionPane.showMessageDialog( frm, "Passwords dont match", "Create Password", JOptionPane.ERROR_MESSAGE); System.exit(1); } } else { pass = askPassword(); } sec = OpenSSLCommander.getCommander(chk, pass, ossl); if (sec == null) { System.err.println("Wrong Password"); System.exit(1); } store.useSecurity(sec); store.useStorage(storeLocs); tempLoc = new File("temp"); if (!tempLoc.exists()) tempLoc.mkdirs(); // load stores try { store.loadAll(tempLoc); store.fireTableDataChanged(); } catch (IOException e) { System.err.println("Storage loading failure"); System.exit(1); } needsSave = false; encryptDecryptThreads = new EDT[numThreads]; for (int i = 0; i < encryptDecryptThreads.length; i++) { encryptDecryptThreads[i] = new EDT(i); encryptDecryptThreads[i].start(); } updateStatus(); txaSearch.grabFocus(); }
public void actionPerformed(ActionEvent e) { Object source = e.getSource(); // (De)Activate the server if (source == hostItem) { if (hostItem.getState()) { server.running = true; } else { server.running = false; } } // Set Client Process to Use Port / Pasv if (source == portItem) { link.setPasv(portItem.getState()); } // Kill the program if (source == exitItem) { System.exit(0); } // Show the About Box if (source == aboutItem) { (new P2PFTP()).start(); } // Show the Help / FAQ if (source == helpItem) { JFrame helpFrame = new JFrame("LeetFTP Help"); helpFrame.getContentPane().setLayout(new GridLayout(0, 1)); helpFrame.getContentPane().add(new JLabel("LeetFTP Help")); helpFrame.getContentPane().add(new JLabel("")); helpFrame .getContentPane() .add( new JLabel( "Use the Connect/Disconnect toggle button to connect and disconnect from the name server.")); helpFrame .getContentPane() .add( new JLabel( "Turn off hosting or disable passive connections from the 'File' menu.")); helpFrame .getContentPane() .add(new JLabel("See the Ub3r-L337 creator by clicking 'About' via the 'Help' menu.")); helpFrame .getContentPane() .add(new JLabel("Connect to other hosts and download files on the 'Server' tab:")); helpFrame.getContentPane().add(new JLabel(" - Double-click on users to view their files")); helpFrame .getContentPane() .add(new JLabel(" - Double-click on files to download them to your workspace")); helpFrame .getContentPane() .add( new JLabel( "Search for files by typing in the search phrase and clicking 'Search':")); helpFrame .getContentPane() .add(new JLabel(" - Double-click on found files to download them")); helpFrame.setSize(600, 400); helpFrame.setLocationRelativeTo(null); helpFrame.setVisible(true); } }