public ConnectionForm() { setContentPane(contentPane); setModal(true); getRootPane().setDefaultButton(buttonOK); JMenuBar menuBar = new JMenuBar(); menuBar.setVisible(true); JMenu menu = new JMenu("Menu"); menu.setVisible(true); JMenuItem statementItem = new JMenuItem("SQL Insert"); statementItem.setVisible(true); statementItem.addActionListener(new SQLImportActionListener()); statementItem.setEnabled(false); JMenuItem importItem = new JMenuItem("Files Import"); importItem.setEnabled(false); importItem.setVisible(true); menu.add(statementItem); menu.add(importItem); menuBar.add(menu); setJMenuBar(menuBar); buttonOK.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setCurrentDirectory(new File(System.getProperty("user.home"))); int result = fileChooser.showOpenDialog(getParent()); } }); dbField.addMouseListener(new DBFileMouseListener(getParent())); filesField.addMouseListener(new SQLFilesMouseListener(getParent())); // call onCancel() when cross is clicked setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { onCancel(); } }); // call onCancel() on ESCAPE contentPane.registerKeyboardAction( new ActionListener() { public void actionPerformed(ActionEvent e) { onCancel(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); }
private JMenu createGenomeSpaceMenu() { JMenu menu = new JMenu("GenomeSpace"); MenuAction menuAction = null; menuAction = new LoadFromGSMenuAction("Load File from GenomeSpace...", KeyEvent.VK_U, igv); menu.add(MenuAndToolbarUtils.createMenuItem(menuAction)); menu.addSeparator(); menuAction = new LoadGenomeFromGSMenuAction("Load Genome from GenomeSpace...", KeyEvent.VK_Z, igv); menu.add(MenuAndToolbarUtils.createMenuItem(menuAction)); menu.addSeparator(); menuAction = new GSSaveSessionMenuAction("Save Session to GenomeSpace...", igv); menu.add(MenuAndToolbarUtils.createMenuItem(menuAction)); menuAction = new GSOpenSessionMenuAction("Load Session from GenomeSpace...", igv); menu.add(MenuAndToolbarUtils.createMenuItem(menuAction)); menu.add(new JSeparator()); menuAction = new MenuAction("Logout") { @Override public void actionPerformed(ActionEvent e) { GSUtils.logout(); if (MessageUtils.confirm( "You must shutdown IGV to complete the GenomeSpace logout. Shutdown now?")) { doExitApplication(); } } }; menu.add(MenuAndToolbarUtils.createMenuItem(menuAction)); menu.add(new JSeparator()); menuAction = new MenuAction("Register... ") { @Override public void actionPerformed(ActionEvent e) { try { BrowserLauncher.openURL(GENOMESPACE_REG_PAGE); } catch (IOException ex) { log.error("Error opening browser", ex); } } }; menuAction.setToolTipText(GENOMESPACE_REG_TOOLTIP); menu.add(MenuAndToolbarUtils.createMenuItem(menuAction)); menu.setVisible( PreferenceManager.getInstance().getAsBoolean(PreferenceManager.GENOME_SPACE_ENABLE)); return menu; }
public MainWindow() { try { LoginWindow loginDlg = new LoginWindow(this); loginDlg.setVisible(true); final User user; // if logon fail if (!loginDlg.ResultLogin()) { System.exit(0); } else { user = loginDlg.getUser(); sessionController.setUser(user); } } catch (Exception ex) { JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); ex.printStackTrace(System.err); } this.initComponents(); this.setJMenuBar(mb); this.add(mainBar, BorderLayout.NORTH); this.add(imgPanel, BorderLayout.CENTER); this.setSize(800, 535); this.setTitle("Diagnosis Helper"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); // Check if User logged is Administrator if (sessionController.isAdministrator()) { mnuMaintenance.setVisible(true); } else { mnuMaintenance.setVisible(false); } this.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { safeExit(); } }); }
@Override public void run() { // Frame final JFrame frame = new JFrame("Keyword"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(800, 600); frame.setLocationRelativeTo(null); frame.setVisible(true); // FileChooser final JFileChooser fileChooser = new JFileChooser(); fileChooser.setSize(800, 600); // Menubar JMenuBar menubar = new JMenuBar(); frame.setJMenuBar(menubar); // Menus JMenu menuFile = new JMenu("File"); menuFile.setVisible(true); menubar.add(menuFile); // MenuItems JMenuItem itemOpenFile = new JMenuItem( new AbstractAction("Open File") { @Override public void actionPerformed(ActionEvent actionEvent) { int returnVal = fileChooser.showOpenDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); // This is where a real application would open the file. System.out.println("Opening: " + file.getPath() + "."); } else { System.out.println("Open command cancelled by user."); } } }); menuFile.add(itemOpenFile); }
private JMenu createExtrasMenu() { List<JComponent> menuItems = new ArrayList<JComponent>(); MenuAction menuAction = null; final JCheckBoxMenuItem exomeModeItem = new JCheckBoxMenuItem("Exome mode"); exomeModeItem.setSelected(FrameManager.isExomeMode()); exomeModeItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { FrameManager.setExomeMode(exomeModeItem.isSelected(), true); igv.resetFrames(); } }); menuItems.add(exomeModeItem); menuItems.add(new JSeparator()); // Preferences reset menuAction = new ResetPreferencesAction("Reset Preferences", IGV.getInstance()); menuItems.add(MenuAndToolbarUtils.createMenuItem(menuAction)); menuItems.add(new JSeparator()); menuAction = new MenuAction("Variant list ... *EXPERIMENTAL*") { @Override public void actionPerformed(ActionEvent e) { VariantListManager.openNavigator(IGV.getMainFrame()); } }; menuItems.add(MenuAndToolbarUtils.createMenuItem(menuAction)); menuItems.add(new JSeparator()); // Set frame dimensions menuAction = new MenuAction("Set window dimensions", null, KeyEvent.VK_C) { @Override public void actionPerformed(ActionEvent e) { String value = JOptionPane.showInputDialog("Enter dimensions, e.g. 800x400"); if (value != null) { String[] vals = value.split("x"); if (vals.length == 2) { int w = Integer.parseInt(vals[0]); int h = Integer.parseInt(vals[1]); IGV.getMainFrame().setSize(w, h); } } } }; menuItems.add(MenuAndToolbarUtils.createMenuItem(menuAction)); // Save entire window menuAction = new MenuAction("Save Screenshot ...", null, KeyEvent.VK_A) { @Override public void actionPerformed(ActionEvent e) { IGV.getInstance().saveImage(IGV.getInstance().getContentPane()); } }; menuItems.add(MenuAndToolbarUtils.createMenuItem(menuAction)); menuAction = new ExportTrackNamesMenuAction("Export track names...", IGV.getInstance()); menuItems.add(MenuAndToolbarUtils.createMenuItem(menuAction)); menuAction = new MenuAction("Scatter Plot ...") { @Override public void actionPerformed(ActionEvent e) { final ReferenceFrame defaultFrame = FrameManager.getDefaultFrame(); String chr = defaultFrame.getChrName(); int start = (int) defaultFrame.getOrigin(); int end = (int) defaultFrame.getEnd(); int zoom = defaultFrame.getZoom(); ScatterPlotUtils.openPlot(chr, start, end, zoom); } }; menuItems.add(MenuAndToolbarUtils.createMenuItem(menuAction)); MenuAction extrasMenuAction = new MenuAction("Extras"); JMenu menu = MenuAndToolbarUtils.createMenu(menuItems, extrasMenuAction); // JMenu lfMenu = new JMenu("L&F"); LookAndFeel lf = UIManager.getLookAndFeel(); for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { final String lfName = info.getName(); JMenuItem cb = new JMenuItem(lfName); // cb.setSelected(info.getClassName().equals(lf.getClass().getName()); cb.addActionListener( new AbstractAction() { public void actionPerformed(ActionEvent actionEvent) { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (lfName.equals(info.getName())) { try { UIManager.setLookAndFeel(info.getClassName()); } catch (Exception e) { e.printStackTrace(); } break; } } } }); lfMenu.add(cb); } menu.add(lfMenu); menu.setVisible(false); return menu; }
public void enableExtrasMenu() { extrasMenu.setVisible(true); }