/** * Initializes the components. * * @param nameSpace The name space to use to determine the name. * @param index The value of the results. */ private void initComponents(String nameSpace, int index) { attachments = new ArrayList<FileAnnotationData>(); this.nameSpace = nameSpace; resultsButton = new JButton(); resultsButton.setText(convertNameSpace(nameSpace) + " #" + index); resultsButton.setOpaque(false); resultsButton.setForeground(UIUtilities.HYPERLINK_COLOR); resultsButton.setBackground(UIUtilities.BACKGROUND_COLOR); UIUtilities.unifiedButtonLookAndFeel(resultsButton); resultsButton.setActionCommand("" + VIEW); resultsButton.addActionListener(this); cancelButton = new JButton(); cancelButton.setText("Cancel"); cancelButton.setToolTipText("Cancel results loading."); cancelButton.setOpaque(false); cancelButton.setForeground(UIUtilities.HYPERLINK_COLOR); cancelButton.setBackground(UIUtilities.BACKGROUND_COLOR); UIUtilities.unifiedButtonLookAndFeel(cancelButton); cancelButton.setActionCommand("" + CANCEL); cancelButton.addActionListener(this); IconManager icons = IconManager.getInstance(); deleteButton = new JMenuItem(icons.getIcon(IconManager.DELETE_12)); deleteButton.setText("Delete"); deleteButton.setToolTipText("Delete the results."); deleteButton.setActionCommand("" + DELETE); deleteButton.addActionListener(this); downloadButton = new JMenuItem(icons.getIcon(IconManager.DOWNLOAD_12)); downloadButton.setText("Download..."); downloadButton.setToolTipText("Download the selected file."); downloadButton.setActionCommand("" + DOWNLOAD); downloadButton.addActionListener(this); menuButton = new JButton(icons.getIcon(IconManager.UP_DOWN_9_12)); UIUtilities.unifiedButtonLookAndFeel(menuButton); menuButton.setBackground(UIUtilities.BACKGROUND_COLOR); menuButton.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent e) { Point p = e.getPoint(); showMenu(menuButton, p); } }); infoButton = new JMenuItem(icons.getIcon(IconManager.INFO)); infoButton.setText("Info..."); infoButton.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent e) { Point p = e.getPoint(); displayInformation(p); } }); setBackground(UIUtilities.BACKGROUND_COLOR); }
/** Populate recent bookmarks. */ public void populateRecentBookmarks() { JMenu bookmarksMenu = this.recentBookmarksMenu; bookmarksMenu.removeAll(); Collection<HistoryEntry<BookmarkInfo>> historyEntries = BookmarksHistory.getInstance().getRecentEntries(PREFERRED_MAX_MENU_SIZE); for (HistoryEntry<BookmarkInfo> hentry : historyEntries) { BookmarkInfo binfo = hentry.getItemInfo(); String text = binfo.getTitle(); URL url = binfo.getUrl(); String urlText = url.toExternalForm(); if ((text == null) || (text.length() == 0)) { text = urlText; } long elapsed = System.currentTimeMillis() - hentry.getTimetstamp(); text = text + " (" + Timing.getElapsedText(elapsed) + " ago)"; Action action = this.actionPool.createBookmarkNavigateAction(url); JMenuItem menuItem = ComponentSource.menuItem(text, action); StringBuffer toolTipText = new StringBuffer(); toolTipText.append("<html>"); toolTipText.append(urlText); String description = binfo.getDescription(); if ((description != null) && (description.length() != 0)) { toolTipText.append("<br>"); toolTipText.append(description); } menuItem.setToolTipText(toolTipText.toString()); bookmarksMenu.add(menuItem); } }
public void notifyGenomeServerReachable(boolean reachable) { if (loadFromServerMenuItem != null) { loadFromServerMenuItem.setEnabled(reachable); String tooltip = reachable ? LOAD_GENOME_SERVER_TOOLTIP : CANNOT_LOAD_GENOME_SERVER_TOOLTIP; loadFromServerMenuItem.setToolTipText(tooltip); } }
public void setLegendMenu(final LegendMap map) { // grab set of names/attributes // alphabetize // make menuitem for each name/attribute // add listener which grabs legend _legend.removeAll(); _legend.add(_legendDefaultColoring); _legend.add(new JSeparator()); Object[] items = map.datumSet().toArray(); java.util.Arrays.sort(items); for (int j = 0; j < items.length; j++) { final String name = ((nv2d.graph.Datum) items[j]).name(); JMenuItem item = new JMenuItem(name); item.setToolTipText("Color vertices according to " + name); _legend.add(item); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ColorLegendUI colorLegendUI = new ColorLegendUI(_ctl, map.getLegend(name)); map.getLegend(name).updateRendererObjects(); // _ctl.getView().addComponent(new ColorLegendUI(map.getLegend(name)), "Legend", // ViewInterface.SIDE_PANEL); _viewLegendMenuActionPerformed(e, colorLegendUI); } }); } }
private void initUI() { JMenuBar menubar = new JMenuBar(); ImageIcon icon = new ImageIcon("exit.png"); JMenu file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); JMenuItem eMenuItem = new JMenuItem("Exit", icon); eMenuItem.setMnemonic(KeyEvent.VK_E); eMenuItem.setToolTipText("Exit application"); eMenuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent event) { System.exit(0); } }); file.add(eMenuItem); menubar.add(file); setJMenuBar(menubar); setTitle("Simple menu"); setSize(300, 200); setLocationRelativeTo(null); setDefaultCloseOperation(EXIT_ON_CLOSE); }
/** * Gets the native menu component for the item * * @return the native menu component for the item */ public JComponent getMenuItem() { if (component != null) { return component; } if ((menuItem == null) && !disposed) { menuItem = checkable ? new JCheckBoxMenuItemEx() : new JMenuItemEx(); menuItem.addActionListener(this); menuItem.setText((theValue == null) ? "" : theValue.toString()); menuItem.setToolTipText(null); iPlatformIcon icon = this.getIcon(); if (!checkable && (icon == null)) { icon = Platform.getResourceAsIconEx("Rare.MenuItem.defaultIcon"); if (icon == null) { icon = Platform.getResourceAsIconEx("Rare.icon.empty16"); } setIcon(icon); } } return menuItem; }
/** * Set the content and visibility of menu items and menu separator, based on the recent file * stored user preferences. */ private static void updateMenuItems(List<JComponent> menuItems) { // Assume no recent files boolean someRecentFiles = false; // Update the menu items for (int i = 0; i < NUMBER_OF_MENU_ITEMS; i++) { // Get the menu item JMenuItem recentFile = (JMenuItem) menuItems.get(i); // Find and set the file for this recent file command String recentFilePath = getRecentFile(i); if (recentFilePath != null) { File file = new File(recentFilePath); StringBuilder sb = new StringBuilder(60); if (i < 9) { sb.append(i + 1).append(" "); // $NON-NLS-1$ } sb.append(getMenuItemDisplayName(file)); recentFile.setText(sb.toString()); recentFile.setToolTipText(recentFilePath); recentFile.setEnabled(true); recentFile.setVisible(true); // At least one recent file menu item is visible someRecentFiles = true; } else { recentFile.setEnabled(false); recentFile.setVisible(false); } } // If there are some recent files, we must make the separator visisble // The separator is the last item in the list JSeparator separator = (JSeparator) menuItems.get(menuItems.size() - 1); separator.setVisible(someRecentFiles); }
/** * Constructor creates graphic components and adds them to the JPanel this class inherits from. */ public SlidePuzzleGUI(String solver) { // default settings for internal attributes: unsolved 15 puzzle nPuzzle = 15; solved = false; this.solver = solver; // create graphics // create menu bar with pull down menu for puzzle configuration // this needs a menu and a menu item in it menuBar = new JMenuBar(); menuBar.setBorder(new BevelBorder(BevelBorder.RAISED)); // create a menu and add it to the menu bar. JMenu menu = new JMenu("Menu"); menu.setMnemonic(KeyEvent.VK_M); // create menu item JMenuItem eMenuItem = new JMenuItem("Configuration"); eMenuItem.setMnemonic(KeyEvent.VK_C); eMenuItem.setToolTipText("Set Puzzle Configuration"); eMenuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent event) { createFrame(); // create configuration frame } }); menu.add(eMenuItem); menuBar.add(menu); // create button to solve puzzle in a step by step manner // The listener is too lengthy for an anonymous class, // code for the listener resides in internal NewGameAction class. JButton newGameButton = new JButton("Solve"); ActionListener gameAction = new NewGameAction(); newGameButton.addActionListener(gameAction); // create control panel that holds the solve button JPanel controlPanel = new JPanel(); controlPanel.setLayout(new FlowLayout()); controlPanel.add(newGameButton); // create graphics panel initalPuzzleGraphics = new GraphicsPanel(nPuzzle, PanelType.INITIALPANEL); intermediatePuzzleGraphics = new GraphicsPanel(nPuzzle, PanelType.INTERMEDIATEPANEL); finalPuzzleGraphics = new GraphicsPanel(nPuzzle, PanelType.GOALPANEL); // create and configure a solver constructPuzzleSolver(); // the panel uses a borderlayout // the menubar goes on top setLayout(new BorderLayout()); add(menuBar, BorderLayout.NORTH); add(controlPanel, BorderLayout.SOUTH); add(initalPuzzleGraphics, BorderLayout.WEST); add(intermediatePuzzleGraphics, BorderLayout.CENTER); add(finalPuzzleGraphics, BorderLayout.EAST); }
/** * Creates the selection menu. * * @return See above. */ private JPopupMenu createDocSelectionMenu() { if (docSelectionMenu != null) return docSelectionMenu; docSelectionMenu = new JPopupMenu(); JMenuItem item = new JMenuItem("Local document..."); item.setToolTipText("Import a local document to the server " + "and attach it."); item.addActionListener(controller); item.setActionCommand("" + EditorControl.ADD_LOCAL_DOCS); docSelectionMenu.add(item); item = new JMenuItem("Uploaded document..."); item.setToolTipText("Attach a document already uploaded " + "to the server."); item.addActionListener(controller); item.setActionCommand("" + EditorControl.ADD_UPLOADED_DOCS); docSelectionMenu.add(item); item = new JMenuItem("New Experiment..."); item.setEnabled(controller.isSingleMode()); item.setToolTipText("Create a new experiment."); item.addActionListener(controller); item.setActionCommand("" + EditorControl.CREATE_NEW_EXPERIMENT); docSelectionMenu.add(item); return docSelectionMenu; }
/** * This method initializes addGroupPopupMenuItem * * @return javax.swing.JMenuItem */ public JMenuItem getAddGroupPopupMenuItem() { if (addGroupPopupMenuItem == null) { addGroupPopupMenuItem = new JMenuItem(); addGroupPopupMenuItem.addActionListener(actionListener); addGroupPopupMenuItem.setActionCommand(ActionConstants.ADD_GROUP_ACTION); addGroupPopupMenuItem.setIcon(ResourceUtil.addGroupIcon); addGroupPopupMenuItem.setText(ResourceUtil.getString("button.add")); addGroupPopupMenuItem.setToolTipText( ResourceUtil.getString("mainframe.button.addgroup.tooltip")); } return addGroupPopupMenuItem; }
private void addMenuToTray() { HashMap categories = new HashMap(); // create menu list Iterator plugins = PluginManager.getInstance().getAvailablePlugins(); plugins = PluginComparator.sortPlugins(plugins); while (plugins.hasNext()) { Plugin p = (Plugin) plugins.next(); JMenu category = (JMenu) categories.get(p.getCategory()); if (category == null) { category = new JMenu(p.getCategory()); categories.put(p.getCategory(), category); // copy menu to real one if (!p.getCategory().equals("Invisible")) this.trayIcon.add(category); } ImageIcon icon = new ImageIcon(); try { icon = new ImageIcon(new URL(p.getDirectory() + p.getIcon())); icon = new ImageIcon(icon.getImage().getScaledInstance(16, 16, Image.SCALE_SMOOTH)); } catch (Exception e) { // error at icon loading } JMenuItem menu = new JMenuItem(p.getTitle(), icon); menu.setName(p.getName()); menu.setToolTipText(p.getToolTip()); menu.addActionListener(this); category.add(menu); } this.trayIcon.addSeparator(); // windows this.trayIcon.add(new WindowMenu(this)); // open main interface JMenuItem menu = new JMenuItem(tr("open")); menu.setName("org.lucane.applications.maininterface"); menu.addActionListener(this); this.trayIcon.add(menu); // exit menu = new JMenuItem(tr("exit")); menu.setName("exit"); menu.addActionListener(this); this.trayIcon.add(menu); }
/** * This method initializes deleteGroupPopupMenuItem. * * @return javax.swing.JMenuItem */ public JMenuItem getDeleteGroupPopupMenuItem() { if (deleteGroupPopupMenuItem == null) { deleteGroupPopupMenuItem = new JMenuItem(); deleteGroupPopupMenuItem.addActionListener(actionListener); deleteGroupPopupMenuItem.setActionCommand(ActionConstants.DELETE_GROUP_ACTION); deleteGroupPopupMenuItem.setIcon(ResourceUtil.deleteGroupIcon); deleteGroupPopupMenuItem.setText(ResourceUtil.getString("button.delete")); deleteGroupPopupMenuItem.setToolTipText( ResourceUtil.getString("mainframe.button.deletegroup.tooltip")); deleteGroupPopupMenuItem.setEnabled(false); } return deleteGroupPopupMenuItem; }
/** * This method initializes renameGroupPopupMenuItem. * * @return javax.swing.JMenuItem */ public JMenuItem getRenameGroupPopupMenuItem() { if (renameGroupPopupMenuItem == null) { renameGroupPopupMenuItem = new JMenuItem(); renameGroupPopupMenuItem.addActionListener(actionListener); renameGroupPopupMenuItem.setActionCommand(ActionConstants.RENAME_GROUP_ACTION); renameGroupPopupMenuItem.setIcon(ResourceUtil.renameGroupIcon); renameGroupPopupMenuItem.setText(ResourceUtil.getString("button.rename")); renameGroupPopupMenuItem.setToolTipText( ResourceUtil.getString("mainframe.button.renamegroup.tooltip")); renameGroupPopupMenuItem.setEnabled(false); } return renameGroupPopupMenuItem; }
public storeGUI() { // Create Form Frame super("Video Store"); setLayout(new FlowLayout()); setSize(679, 385); setLocation(500, 280); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Menu Bar JMenuBar menuBar = new JMenuBar(); JMenu file = new JMenu("File"); JMenuItem exit = new JMenuItem("Exit"); exit.setToolTipText("close"); exit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { JOptionPane.showMessageDialog(null, "See You!"); System.exit(0); } }); JMenuItem logout = new JMenuItem("Logout"); logout.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { getContentPane().removeAll(); JOptionPane.showMessageDialog(null, "logged out!"); LoginDialog(); } }); file.add(logout); file.add(exit); menuBar.add(file); setJMenuBar(menuBar); lblWelcome = new JLabel("Message", JLabel.LEFT); lblWelcome.setFont(new Font("Tahoma", Font.PLAIN, 20)); lblWelcome.setBounds(0, 0, 336, 25); getContentPane().add(lblWelcome); // When Frame Loaded addWindowListener( new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { LoginDialog(); } }); }
/** * This method initializes addRemoveMembersPopupMenuItem. * * @return javax.swing.JMenuItem */ public JMenuItem getAddRemoveMembersPopupMenuItem() { if (addRemoveMembersPopupMenuItem == null) { addRemoveMembersPopupMenuItem = new JMenuItem(); addRemoveMembersPopupMenuItem.addActionListener(actionListener); addRemoveMembersPopupMenuItem.setActionCommand(ActionConstants.ADD_REMOVE_MEMBERS_ACTION); addRemoveMembersPopupMenuItem.setIcon(ResourceUtil.addRemoveMembersIcon); addRemoveMembersPopupMenuItem.setText( ResourceUtil.getString("mainframe.button.addremovemembers")); addRemoveMembersPopupMenuItem.setToolTipText( ResourceUtil.getString("mainframe.button.addremovemembers.tooltip")); addRemoveMembersPopupMenuItem.setEnabled(false); } return addRemoveMembersPopupMenuItem; }
private void createHelpMenu() { // Help menu helpMenu = new JMenu("Help"); helpMenu.setMnemonic(KeyEvent.VK_H); helpMenu.setToolTipText("Help"); add(helpMenu); // Help/About menu item aboutMenuItem = new JMenuItem("About"); aboutMenuItem.setMnemonic(KeyEvent.VK_A); aboutMenuItem.setToolTipText("Display the About window."); aboutMenuItem.setActionCommand("MainMenu--Display About"); aboutMenuItem.addActionListener(actionListener); helpMenu.add(aboutMenuItem); // Help/Help menu item helpMenuItem = new JMenuItem("Help"); helpMenuItem.setMnemonic(KeyEvent.VK_H); helpMenuItem.setToolTipText("Display the Help window."); helpMenuItem.setActionCommand("MainMenu--Display Help"); helpMenuItem.addActionListener(actionListener); helpMenu.add(helpMenuItem); } // end of MainMenu::createHelpMenu
private void createCustomerMenu() { // Customer menu customerMenu = new JMenu("Customer"); customerMenu.setMnemonic(KeyEvent.VK_C); customerMenu.setToolTipText("Customer"); add(customerMenu); // Customer/View All Customers menu item viewAllCustomersMenuItem = new JMenuItem("View All Customers"); viewAllCustomersMenuItem.setToolTipText("View all customers."); viewAllCustomersMenuItem.setActionCommand("MainMenu--View All Customers"); viewAllCustomersMenuItem.addActionListener(actionListener); customerMenu.add(viewAllCustomersMenuItem); } // end of MainMenu::createCustomerMenu
private void createFileMenu() { // File menu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); fileMenu.setToolTipText("File"); add(fileMenu); // File/Exit menu item exitMenuItem = new JMenuItem("Exit"); exitMenuItem.setMnemonic(KeyEvent.VK_X); exitMenuItem.setToolTipText("Exit the program."); exitMenuItem.setActionCommand("MainMenu--Exit"); exitMenuItem.addActionListener(actionListener); fileMenu.add(exitMenuItem); } // end of MainMenu::createFileMenu
/** Populate forward more. */ public void populateForwardMore() { NavigationEntry[] entries = this.window.getForwardNavigationEntries(); JMenu forwardMoreMenu = this.forwardMoreMenu; forwardMoreMenu.removeAll(); for (NavigationEntry entry : entries) { String method = entry.getMethod(); if ("GET".equals(method)) { String title = entry.getTitle(); URL url = entry.getUrl(); String text = (title == null) || (title.length() == 0) ? url.toExternalForm() : title; Action action = this.actionPool.createGoToAction(entry); JMenuItem menuItem = menuItem(text, action); menuItem.setToolTipText(url.toExternalForm()); forwardMoreMenu.add(menuItem); } } }
private JMenuItem getMntmNuevo() { if (mntmNuevo == null) { mntmNuevo = new JMenuItem("Nuevo"); mntmNuevo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { carrera.inicializarJuego(); representarEstadoJuego(); modificarPanel(jPanel_Liebre, false); modificarPanel(jPanelTortuga, false); btDado.setEnabled(true); } }); mntmNuevo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)); mntmNuevo.setToolTipText(""); mntmNuevo.setMnemonic('n'); } return mntmNuevo; }
/** 创建具有子目录的目录 */ private void createMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenu importMenu = new JMenu("Import"); JMenuItem newsMenuItem = new JMenuItem("Import newsfeed list..."); JMenuItem bookMenuItem = new JMenuItem("Import bookmarks..."); JMenuItem mailMenuItem = new JMenuItem("Import mail..."); importMenu.add(newsMenuItem); importMenu.add(bookMenuItem); importMenu.add(mailMenuItem); JMenuItem newMenuItem = new JMenuItem("New"); JMenuItem openMenuItem = new JMenuItem("Open"); JMenuItem saveMenuItem = new JMenuItem("Save"); JMenuItem exitMenuItem = new JMenuItem("Exit"); exitMenuItem.setToolTipText("Exit application"); exitMenuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); fileMenu.add(newMenuItem); fileMenu.add(openMenuItem); fileMenu.add(saveMenuItem); // fileMenu.addSeparator(); fileMenu.add(importMenu); // fileMenu.addSeparator(); fileMenu.add(exitMenuItem); menuBar.add(fileMenu); setJMenuBar(menuBar); }
/** Populate tagged bookmarks. */ public void populateTaggedBookmarks() { JMenu bookmarksMenu = this.taggedBookmarksMenu; bookmarksMenu.removeAll(); Collection<BookmarkInfo> bookmarkInfoList = BookmarksHistory.getInstance() .getRecentItemInfo(PREFERRED_MAX_MENU_SIZE * PREFERRED_MAX_MENU_SIZE); Map<String, JMenu> tagMenus = new HashMap<String, JMenu>(); for (BookmarkInfo binfo : bookmarkInfoList) { URL url = binfo.getUrl(); String urlText = url.toExternalForm(); String[] tags = binfo.getTags(); if (tags != null) { for (String tag : tags) { JMenu tagMenu = tagMenus.get(tag); if (tagMenu == null) { if (tagMenus.size() < PREFERRED_MAX_MENU_SIZE) { tagMenu = new JMenu(tag); tagMenus.put(tag, tagMenu); bookmarksMenu.add(tagMenu); } } if ((tagMenu != null) && (tagMenu.getItemCount() < PREFERRED_MAX_MENU_SIZE)) { String text = binfo.getTitle(); if ((text == null) || (text.length() == 0)) { text = urlText; } Action action = this.actionPool.createBookmarkNavigateAction(url); JMenuItem menuItem = ComponentSource.menuItem(text, action); StringBuffer toolTipText = new StringBuffer(); toolTipText.append("<html>"); toolTipText.append(urlText); String description = binfo.getDescription(); if ((description != null) && (description.length() != 0)) { toolTipText.append("<br>"); toolTipText.append(description); } menuItem.setToolTipText(toolTipText.toString()); tagMenu.add(menuItem); } } } } }
/** * Add an action to a menu and return the menu item created. If the tool tip is null, use the * "tooltip" property already in the action, otherwise add the property to the action. (The * mnemonic isn't added.) The new menu item is added to the action as the "menuItem" property. The * menu item's text is set to be "label", and is disabled or enabled according to "isEnabled." */ public static JMenuItem addMenuItem( JMenu menu, String label, Action action, int mnemonic, String tooltip, boolean isEnabled) { if (tooltip == null) { tooltip = (String) action.getValue("tooltip"); } else { action.putValue("tooltip", tooltip); } action.putValue("tooltip", tooltip); JMenuItem item = menu.add(action); item.setText(label); item.setEnabled(isEnabled); item.setMnemonic(mnemonic); item.setToolTipText(tooltip); KeyStroke key = (KeyStroke) action.getValue(ACCELERATOR_KEY); item.setAccelerator(key); action.putValue("menuItem", item); return item; }
private void updateMenuItem(JMenuItem menuItem, String prefix) { menuItem.setName(prefix); try { String text = bundle.getString(prefix + ".text"); menuItem.setText(text); } catch (MissingResourceException exception) { // ok not to set mnemonic } try { String mnemonic = bundle.getString(prefix + ".mnemonic"); menuItem.setMnemonic(mnemonic.charAt(0)); } catch (MissingResourceException exception) { // ok not to set mnemonic } try { String accelerator = bundle.getString(prefix + ".accelerator"); menuItem.setAccelerator(KeyStroke.getKeyStroke(accelerator)); } catch (MissingResourceException exception) { // ok not to set accelerator } try { String tooltip = bundle.getString(prefix + ".tooltip"); menuItem.setToolTipText(tooltip); } catch (MissingResourceException exception) { // ok not to set tooltip } try { String iconPath = bundle.getString(prefix + ".icon"); if (iconPath != null) { ImageIcon icon = new ImageIcon(this.referenceClass.getResource(iconPath)); menuItem.setIcon(icon); } } catch (MissingResourceException exception) { // ok not to set tooltip } }
/** * Gets the chronology menu. * * @return the chronology menu */ public JMenu getChronologyMenu() { JMenu menu = new JMenu("Recent Hosts"); menu.removeAll(); Collection<HostEntry> hostEntries = NavigationHistory.getInstance().getRecentHostEntries(PREFERRED_MAX_MENU_SIZE); for (HostEntry entry : hostEntries) { String urlText = "http://" + entry.getHost(); try { URL url = new URL(urlText); long elapsed = System.currentTimeMillis() - entry.getTimestamp(); String menuText = entry.getHost() + " (" + Timing.getElapsedText(elapsed) + " ago)"; Action action = this.actionPool.createNavigateAction(url); JMenuItem menuItem = menuItem(menuText, action); menuItem.setToolTipText(url.toExternalForm()); menu.add(menuItem); } catch (MalformedURLException mfu) { logger.log(Level.WARNING, "populateRecentHosts(): Bad URL=" + urlText, mfu); } } menu.addSeparator(); menu.add(menuItem("Show All Recent Hosts", new ShowRecentHostsAction(this, window))); return menu; }
public static JMenuBar creaetMenuBar() { JMenuBar menubar = new JMenuBar(); ImageIcon icon = new ImageIcon("exit.png"); JMenu file = new JMenu("Password Manager"); file.setMnemonic(KeyEvent.VK_F); JMenu profileItem = new JMenu("Profile"); profileItem.setMnemonic(KeyEvent.VK_E); profileItem.setToolTipText("User Profile"); JMenuItem changePassword = new JMenuItem("Change Password", icon); changePassword.setMnemonic(KeyEvent.VK_E); changePassword.setToolTipText("Change User Login Password"); JMenuItem changeSecurityKey = new JMenuItem("Change SecutrityKey", icon); changeSecurityKey.setMnemonic(KeyEvent.VK_E); changeSecurityKey.setToolTipText("Change SecutrityKey"); JMenuItem changeIdleTimeOut = new JMenuItem("Change Idle TimeOut", icon); changeIdleTimeOut.setMnemonic(KeyEvent.VK_E); changeIdleTimeOut.setToolTipText("Change Idle TimeOut"); changeIdleTimeOut.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // JOptionPane.showMessageDialog(null, "Successfully Register"); cardLayout = (CardLayout) PasswordManager.cards.getLayout(); cardLayout.show(PasswordManager.cards, PasswordManager.updateIdleTimeOut.getName()); } }); changePassword.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // JOptionPane.showMessageDialog(null, "Successfully Register"); cardLayout = (CardLayout) PasswordManager.cards.getLayout(); cardLayout.show(PasswordManager.cards, PasswordManager.updateLoginPassword.getName()); } }); profileItem.add(changePassword); profileItem.add(changeSecurityKey); profileItem.add(changeIdleTimeOut); JMenuItem settings = new JMenuItem("Settings", icon); settings.setMnemonic(KeyEvent.VK_E); settings.setToolTipText("User Settings"); JMenuItem eMenuItem = new JMenuItem("Exit", icon); eMenuItem.setMnemonic(KeyEvent.VK_E); eMenuItem.setToolTipText("Exit application"); eMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); file.add(profileItem); file.add(settings); file.add(eMenuItem); menubar.add(file); return menubar; }
private void jbInit() throws Exception { borderForProjectView = BorderFactory.createLineBorder(Color.black, 2); titleBoderForProjectView = new TitledBorder(borderForProjectView, "Project view"); borderForEntitiesView = BorderFactory.createLineBorder(Color.black, 2); titledBorderForEntitiesView = new TitledBorder(borderForEntitiesView, "Entities view"); titledBorderForMessagesPane = new TitledBorder( BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140)), "Messages"); this.getContentPane().setLayout(borderLayout2); file.setText("File"); save.setEnabled(false); save.setText("Save"); save.setName("Savefilemenu"); save.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { save_actionPerformed(e); } }); load.setText("Load"); load.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { load_actionPerformed(e); } }); this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); this.setJMenuBar(mainMenuBar); this.setTitle("INGENIAS Development Kit"); this.setSize(625, 470); this.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosed(WindowEvent e) { this_windowClosed(e); } public void windowClosing(WindowEvent e) { this_windowClosing(e); } }); splitPaneSeparatingProjectsAndEntitiesView.setOrientation(JSplitPane.VERTICAL_SPLIT); splitPaneSeparatingProjectsAndEntitiesView.setBottomComponent(scrollPaneForEntitiesView); splitPaneSeparatingProjectsAndEntitiesView.setTopComponent(scrollPaneForProyectView); jPanel1.setLayout(gridLayout1); arbolObjetos.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { arbolObjetos_mouseClicked(e); } }); scrollPaneForProyectView.setAutoscrolls(true); scrollPaneForProyectView.setBorder(titleBoderForProjectView); scrollPaneForEntitiesView.setBorder(titledBorderForEntitiesView); edit.setText("Edit"); copyImage.setText("Copy diagram as a file"); copyImage.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { capture_actionPerformed(e); } }); saveas.setText("Save as"); saveas.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { saveas_actionPerformed(e); } }); help.setText("Help"); manual.setText("Tool manual"); manual.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { manual_actionPerformed(e); } }); about.setText("About"); about.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { about_actionPerformed(e); } }); project.setText("Project"); copy.setText("Copy"); copy.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { copy_actionPerformed(e); } }); paste.setText("Paste"); paste.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { paste_actionPerformed(e); } }); exit.setText("Exit"); exit.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { exit_actionPerformed(e); } }); splitPanelDiagramMessagesPaneSeparator.setOrientation(JSplitPane.VERTICAL_SPLIT); splitPanelDiagramMessagesPaneSeparator.setLastDividerLocation(150); pprin.setLayout(new BorderLayout()); pprin.setName("DiagramPane"); pprin.setPreferredSize(new Dimension(400, 300)); pprin.add(BorderLayout.SOUTH, pbar); pbar.setVisible(false); jSplitPane1.setOrientation(JSplitPane.HORIZONTAL_SPLIT); scrollLogs.setBorder(titledBorderForMessagesPane); scrollLogs.addKeyListener( new java.awt.event.KeyAdapter() { public void keyPressed(KeyEvent e) { jScrollPane3_keyPressed(e); } }); this.clearMessages.setText("Clear"); clearMessages.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { clearMessages_actionPerformed(e, (JTextPane) messagesMenu.getInvoker()); } }); forcegc.setText("Force GC"); forcegc.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { forcegc_actionPerformed(e); } }); menuTools.setText("Tools"); menuCodeGenerator.setText("Code Generator"); profiles.setText("Profiles"); menuModules.setText("Modules"); this.properties.setText("Properties"); properties.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { properties_actionPerformed(e); } }); moutput.setEditable(false); moutput.setSelectionStart(0); moutput.setText(""); moduleOutput.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { moduleOutput_mouseClicked(e); } }); moduleOutput.setFont(new java.awt.Font("Monospaced", 0, 11)); logs.setContentType("text/html"); logs.setEditable(false); logs.setText(""); logs.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { logs_mouseClicked(e); } }); logs.addComponentListener( new java.awt.event.ComponentAdapter() { public void componentResized(ComponentEvent e) { logs_componentResized(e); } }); newProject.setText("New"); newProject.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { newProject_actionPerformed(e); } }); undo.setText("Undo"); undo.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { undo_actionPerformed(e); } }); redo.setText("Redo"); redo.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { redo_actionPerformed(e); } }); delete.setText("Delete"); delete.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { delete_actionPerformed(e); } }); selectall.setText("Select all"); selectall.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { selectall_actionPerformed(e); } }); cpClipboard.setText("Copy diagram to clipboard"); cpClipboard.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { cpClipboard_actionPerformed(e); } }); preferences.setText("Preferences"); enableUMLView.setToolTipText("UML view" + "instead of its type"); enableUMLView.setText("Enable UML view from now on"); enableUMLView.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { enableUMLView_actionPerformed(e); } }); enableINGENIASView.setToolTipText("INGENIAS view"); enableINGENIASView.setText("Enable INGENIAS view from now on"); enableINGENIASView.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { enableINGENIASView_actionPerformed(e); } }); switchINGENIASView.setToolTipText("Switch to INGENIAS view"); switchINGENIASView.setText("Switch to INGENIAS view"); switchINGENIASView.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { switchINGENIASView_actionPerformed(e); } }); switchUMLView.setToolTipText("Switch to UML view"); switchUMLView.setText("Switch to UML view"); switchUMLView.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { switchUMLView_actionPerformed(e); } }); resizeAll.setToolTipText("Resize all"); resizeAll.setText("Resize all entities within current diagram"); resizeAll.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { resizeAll_actionPerformed(e); } }); resizeAllDiagrams.setToolTipText("Resize all diagrams"); resizeAllDiagrams.setText("Resize all entities within all defined diagram"); resizeAllDiagrams.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { resizeAllDiagrams_actionPerformed(e); } }); JMenuItem workspaceEntry = new JMenuItem("Switch workspace"); workspaceEntry.setToolTipText("Change current workspace"); workspaceEntry.setText("Switch workspace"); workspaceEntry.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { changeWorkspace(e); } }); preferences.add(workspaceEntry); preferences.add(resizeAll); preferences.add(resizeAllDiagrams); { elimOverlap = new JMenuItem(); preferences.add(elimOverlap); elimOverlap.setText("Eliminate overlap"); elimOverlap.setAccelerator(KeyStroke.getKeyStroke("F3")); elimOverlap.addMenuKeyListener( new MenuKeyListener() { public void menuKeyPressed(MenuKeyEvent evt) { System.out.println("elimOverlap.menuKeyPressed, event=" + evt); // TODO add your code for elimOverlap.menuKeyPressed } public void menuKeyReleased(MenuKeyEvent evt) { System.out.println("elimOverlap.menuKeyReleased, event=" + evt); // TODO add your code for elimOverlap.menuKeyReleased } public void menuKeyTyped(MenuKeyEvent evt) { elimOverlapMenuKeyTyped(evt); } }); elimOverlap.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent evt) { elimOverlapKeyPressed(evt); } }); elimOverlap.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { elimOverlapActionPerformed(evt); } }); } { modelingLanguageNotationSwitchMenu = new JMenu(); preferences.add(modelingLanguageNotationSwitchMenu); modelingLanguageNotationSwitchMenu.setText("Modelling language"); modelingLanguageNotationSwitchMenu.add(enableINGENIASView); viewSelection.add(enableINGENIASView); modelingLanguageNotationSwitchMenu.add(enableUMLView); viewSelection.add(enableUMLView); enableINGENIASView.setSelected(true); modelingLanguageNotationSwitchMenu.add(switchUMLView); modelingLanguageNotationSwitchMenu.add(switchINGENIASView); } { propertiesModeMenu = new JMenu(); preferences.add(propertiesModeMenu); propertiesModeMenu.setText("Edit Properties Mode"); { editPopUpProperties = new JCheckBoxMenuItem(); propertiesModeMenu.add(editPopUpProperties); editPopUpProperties.setText("Edit Properties in a PopUp Window"); editPopUpProperties.setSelected(true); editPopUpProperties.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { editPopUpProperties_selected(); } }); propertiesEditModeSelection.add(editPopUpProperties); } { editOnMessages = new JCheckBoxMenuItem(); propertiesModeMenu.add(editOnMessages); editOnMessages.setText("Edit Properties in Messages Panel"); propertiesEditModeSelection.add(editOnMessages); editOnMessages.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { editOnMessages_selected(); } }); } } mainMenuBar.add(file); mainMenuBar.add(edit); mainMenuBar.add(project); mainMenuBar.add(menuModules); mainMenuBar.add(profiles); mainMenuBar.add(preferences); mainMenuBar.add(help); file.add(newProject); file.add(load); { importFile = new JMenuItem(); file.add(importFile); importFile.setText("Import file"); importFile.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { importFileActionPerformed(evt); } }); } file.add(save); file.add(saveas); file.addSeparator(); file.add(exit); file.addSeparator(); rightPanel.setLayout(new BorderLayout()); rightPanel.add(buttonModelPanel, BorderLayout.WEST); this.getContentPane().add(jSplitPane1, BorderLayout.CENTER); rightPanel.add(splitPanelDiagramMessagesPaneSeparator, BorderLayout.CENTER); jSplitPane1.add(splitPaneSeparatingProjectsAndEntitiesView, JSplitPane.LEFT); splitPaneSeparatingProjectsAndEntitiesView.add(scrollPaneForProyectView, JSplitPane.TOP); { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); splitPaneSeparatingProjectsAndEntitiesView.add(jPanel2, JSplitPane.BOTTOM); jPanel2.add(jPanel1, BorderLayout.SOUTH); jPanel2.add(scrollPaneForEntitiesView, BorderLayout.CENTER); } jSplitPane1.add(rightPanel, JSplitPane.RIGHT); splitPanelDiagramMessagesPaneSeparator.add(pprin, JSplitPane.TOP); splitPanelDiagramMessagesPaneSeparator.add(messagespane, JSplitPane.BOTTOM); JScrollPane scrollSearchDiagram = new JScrollPane(); scrollSearchDiagram.getViewport().add(searchDiagramPanel, null); searchDiagramPanel.setContentType("text/html"); searchDiagramPanel.setEditable(false); messagespane.addConventionalTab(scrollLogs, "Logs"); scrollLogs.getViewport().add(logs, null); scrolloutput.getViewport().add(this.moduleOutput, null); messagespane.addConventionalTab(scrolloutput, "Module Output"); messagespane.addConventionalTab(scrollSearchDiagram, "Search"); scrolloutput.getViewport().add(moduleOutput, null); { searchPanel = new JPanel(); FlowLayout searchPanelLayout = new FlowLayout(); searchPanelLayout.setVgap(1); searchPanel.setLayout(searchPanelLayout); jPanel1.add(searchPanel, BorderLayout.SOUTH); searchPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { searchField = new JTextField(); searchPanel.add(searchField); searchField.setColumns(15); searchField.addKeyListener( new KeyAdapter() { public void keyTyped(KeyEvent evt) { searchFieldKeyTyped(evt); } }); } { Search = new JButton(); scrollPaneForProyectView.setViewportView(arbolProyectos); scrollPaneForEntitiesView.setViewportView(arbolObjetos); searchPanel.add(Search); Search.setIcon(new ImageIcon(ImageLoader.getImage(("images/lense.png")))); // Search.setPreferredSize(new java.awt.Dimension(20, 20)); Search.setIconTextGap(0); Search.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { SearchActionPerformed(evt); } }); } } edit.add(undo); edit.add(redo); edit.addSeparator(); edit.add(copy); edit.add(paste); edit.add(delete); edit.add(selectall); edit.addSeparator(); edit.add(copyImage); edit.add(cpClipboard); help.add(manual); help.add(about); help.add(forcegc); menuModules.add(menuTools); menuModules.add(menuCodeGenerator); messagesMenu.add(this.clearMessages); project.add(this.properties); project.addSeparator(); jSplitPane1.setDividerLocation(250); splitPaneSeparatingProjectsAndEntitiesView.setDividerLocation(250); arbolProyectos.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { arbolProyectos_mouseClicked(e); } }); splitPanelDiagramMessagesPaneSeparator.setDividerLocation(400); }
protected JMenu createPlotMenu() { JMenu menu; JMenuItem menuItem; menu = new JMenu("Plot"); ButtonGroup group; group = new ButtonGroup(); menuItem = new JRadioButtonMenuItem("State space plot"); menuItem.setMnemonic(KeyEvent.VK_N); group.add(menuItem); menu.add(menuItem); menuItem.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { stateMachine.parseInput(UserMenuInput.normalMode); controlForm.updateSamplesMenu(); getSaveDataAction().setEnabled(true); } }); normalPlotMenuItem = menuItem; menuItem = new JRadioButtonMenuItem("Time plot"); menuItem.setMnemonic(KeyEvent.VK_T); group.add(menuItem); menu.add(menuItem); menuItem.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { stateMachine.parseInput(UserMenuInput.timeMode); controlForm.updateSamplesMenu(); getSaveDataAction().setEnabled(true); } }); timePlotMenuItem = menuItem; menu.addSeparator(); menuItem = new JCheckBoxMenuItem("Variation"); menuItem.setMnemonic(KeyEvent.VK_T); menu.add(menuItem); menuItem.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { boolean state; state = ((JCheckBoxMenuItem) e.getSource()).isSelected(); privateControlForm.setVariation(state); privateControlForm.updateSamplesMenu(); getSaveDataAction().setEnabled(false); } }); variationMenuItem = menuItem; menu.addSeparator(); group = new ButtonGroup(); menuItem = new JRadioButtonMenuItem("Automatic bounds"); menuItem.setMnemonic(KeyEvent.VK_A); group.add(menuItem); menu.add(menuItem); menuItem.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { privateControlForm.setAutoRanges(true); privateControlForm.updateSamplesMenu(); } }); autoBoundsMenuItem = menuItem; menuItem = new JRadioButtonMenuItem("Manual bounds"); menuItem.setMnemonic(KeyEvent.VK_M); group.add(menuItem); menu.add(menuItem); menuItem.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { privateControlForm.setAutoRanges(false); controlForm.updateSamplesMenu(); } }); manualBoundsMenuItem = menuItem; setAutomaticBounds(autoBoundsDefault); /* Step Function */ class SetStepFunctionPerform implements ActionListener { private int i; SetStepFunctionPerform(final int i) { this.i = i; } public void actionPerformed(final ActionEvent e) { ((TrajectoryManager) manager).setOdeStepFunction(i); } } if (model instanceof ODE) { menu.addSeparator(); JMenu stepFuctionMenu = new JMenu("Step function"); stepFuctionMenu.setMnemonic(KeyEvent.VK_S); group = new ButtonGroup(); int i = 0; do { String name = Lua.getStepFunctionName(i); if (name == null) break; menuItem = new JRadioButtonMenuItem(name); group.add(menuItem); stepFuctionMenu.add(menuItem); menuItem.setToolTipText(Lua.getStepFunctionDescription(i)); if (name.equals("rkf45")) { menuItem.setSelected(true); } menuItem.addActionListener(new SetStepFunctionPerform(i)); i++; } while (true); menu.add(stepFuctionMenu); stateMachine.addNoRunItem(stepFuctionMenu); } return menu; }
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); }
protected final synchronized void updateMenu() { if (parentWindow == null) return; List<String> panels = this.parentWindow.getPanelLabels(); if (CollectionUtil.isEmpty(panels)) return; int count = this.getItemCount(); // Make sure none of the items has an ActionListener attached for (int i = 0; i < count; i++) { JMenuItem item = this.getItem(i); if (item != null && target != null) { item.removeActionListener(target); } } this.removeAll(); int current = this.parentWindow.getCurrentPanelIndex(); JMenuItem show = new WbMenuItem(ResourceMgr.getString("LblShowDataInNewTab")); show.setActionCommand(PANEL_CMD_PREFIX + "-1"); show.setToolTipText(newTabTooltip); show.addActionListener(target == null ? this : target); this.add(show); if (withClipboard) { JMenuItem clipboard = new WbMenuItem(ResourceMgr.getString("MnuTxtStmtClip")); clipboard.setToolTipText(ResourceMgr.getDescription("MnuTxtStmtClip", true)); clipboard.setActionCommand(CMD_CLIPBOARD); clipboard.addActionListener(target); this.add(clipboard); } Font boldFont = show.getFont(); if (boldFont != null) boldFont = boldFont.deriveFont(Font.BOLD); addSeparator(); for (int i = 0; i < panels.size(); i++) { if (panels.get(i) == null) continue; String menuText = panels.get(i); if (i < 9) { menuText += " &" + NumberStringCache.getNumberString(i + 1); } else { menuText += NumberStringCache.getNumberString(i + 1); } JMenuItem item = new WbMenuItem(menuText); item.setActionCommand( EditorTabSelectMenu.PANEL_CMD_PREFIX + NumberStringCache.getNumberString(i)); if (i == current && boldFont != null) { item.setFont(boldFont); } // The tooltip is the same for all items item.setToolTipText(regularTooltip); item.addActionListener(target == null ? this : target); this.add(item); } List<TableIdentifier> tables = DbObjectList.Util.getSelectedTableObjects(objectList); setEnabled(tables.size() > 0); }