public static JPanel makeScaleOptionPanel(){ // create the side panel with scale change options JPanel optionPanel = new JPanel(); optionPanel.add(Box.createVerticalStrut(20)); optionPanel.setLayout(new BoxLayout(optionPanel,BoxLayout.Y_AXIS)); optionPanel.add(makeScalePanel(pv1,"View (0,0)")); optionPanel.add(Box.createVerticalStrut(20)); optionPanel.add(new Separator()); optionPanel.add(makeScalePanel(pv2,"View (0,1)")); optionPanel.add(Box.createVerticalStrut(20)); optionPanel.add(new Separator()); optionPanel.add(makeScalePanel(pv3,"View (1,0)")); optionPanel.add(Box.createVerticalStrut(20)); optionPanel.add(new Separator()); optionPanel.add(makeScalePanel(pv4,"View (1,1)")); optionPanel.add(Box.createVerticalStrut(20)); return optionPanel; }
/** * Creates the file menu * * @return the file menu */ private JMenu createFileMenu() { JMenu fileMenu = new JMenu(getCaption("tab_file")); // Input folder folder = new JMenuItem(getCaption("tab_item_choose_input")); folder.addActionListener(new FileInputListener(new UiCallback(), frame)); // Output folder outputFolder = new JMenuItem(getCaption("tab_item_choose_output")); outputFolder.addActionListener(new FileOutputListener(frame)); // Exit button JMenuItem exit = new JMenuItem(getCaption("tab_item_exit")); exit.addActionListener(ae -> shutdown()); fileMenu.add(folder); fileMenu.add(outputFolder); fileMenu.add(new Separator()); fileMenu.add(exit); return fileMenu; }
private void disableOrEnableMenuItems() { //ce ni nobenega izbranega frejma, onemogoci //menije, ki potrebujejo sliko MenuElement[] menuElement = meni.menuBar.getSubElements(); Component[] component; //boolean isThereAnyFrame = (desktop.getAllFrames().length > 0); //TODONEW boolean isThereASelectedFrame = !( desktop.getSelectedFrame() == null ); for ( int i = 0; i < meni.menuBar.getMenuCount() ; i++ ) { component = ((JMenu) menuElement[i]).getMenuComponents(); for ( int j = 0; j < ((JMenu) menuElement[i]).getItemCount(); j++ ) { if (component[j] instanceof Separator) continue; //ce ni izbrane slike in ce meni ajtem potrebuje eno ali vec slik pol ga disejbla if ( !isThereASelectedFrame && (((MyMenuInterface)component[j]).noOfOperands() > 0) ) { component[j].setEnabled(false); } else { component[j].setEnabled(true); } } } }
/** @{hide */ private JComponent buildBottomPane() { JPanel p = new JPanel(new BorderLayout()); JPanel f = new JPanel(new FlowLayout(FlowLayout.RIGHT)); f.add(btnCancel); f.add(btnPrev); f.add(btnNext); p.add(new JSeparator(Separator.HORIZONTAL), BorderLayout.NORTH); p.add(f, BorderLayout.SOUTH); return p; }
@Messages({ "LBL_NewFileAction_File_PopupName=Other...", "NewFile.please_wait=Please wait..." }) private void fillSubMenu(final JMenu menuItem, final Lookup lookup) { menuItem.removeAll(); JMenuItem wait = new JMenuItem(NewFile_please_wait()); wait.setEnabled(false); menuItem.add(wait); final Pair<List<Project>, List<FileObject>> data = ActionsUtil.mineFromLookup(lookup); RP.post(new Runnable() { @Override public void run() { Project projects[] = ActionsUtil.getProjects(data); final Project project = projects.length > 0 ? projects[0] : null; final List<TemplateItem> items = OpenProjectList.prepareTemplates(project, getLookup()); EventQueue.invokeLater(new Runnable() { @Override public void run() { menuItem.removeAll(); ActionListener menuListener = new PopupListener(); for (TemplateItem i : items) { JMenuItem item = new JMenuItem( LBL_NewFileAction_Template_PopupName(i.displayName), i.icon); item.addActionListener(menuListener); item.putClientProperty(TEMPLATE_PROPERTY, i.template); item.putClientProperty(IN_PROJECT_PROPERTY, project != null); menuItem.add(item); } if (!items.isEmpty()) { menuItem.add(new Separator()); } JMenuItem fileItem = new JMenuItem(LBL_NewFileAction_File_PopupName(), (Icon) getValue(Action.SMALL_ICON)); fileItem.addActionListener(menuListener); fileItem.putClientProperty(TEMPLATE_PROPERTY, null); fileItem.putClientProperty(IN_PROJECT_PROPERTY, project != null); menuItem.add(fileItem); // #205616 - need to refresh please wait node menuItem.getPopupMenu().pack(); } }); } }); }
protected final void setup() { for (MenuElement me : globalCacheMenu.getSubElements()) { if (AbstractButton.class.isInstance(me)) { buttonGroup.remove((AbstractButton) me); } } globalCacheMenu.removeAll(); globalCacheRadioButtons = new JRadioButton[GlobalCacheManager.getInstance().getAutomatic().length + GlobalCacheManager.getInstance().getManual().length]; InetAddress[] automaticGlobalCaches = GlobalCacheManager.getInstance().getAutomatic(); InetAddress[] manualGlobalCaches = GlobalCacheManager.getInstance().getManual(); int index = 0; for (InetAddress ipName : manualGlobalCaches) { addGlobalCache(index, ipName.getHostName(), ipName, "Manually entered GlobalCache."); index++; } if (automaticGlobalCaches.length > 0 && manualGlobalCaches.length > 0) globalCacheMenu.add(new Separator()); String[] automaticGlobalCachesPretty = GlobalCacheManager.getInstance().getAutomaticPrettyNames(); for (int i = 0; i < automaticGlobalCaches.length; i++) { addGlobalCache(index, automaticGlobalCachesPretty[i], automaticGlobalCaches[i], "Automatically discovered GlobalCache."); index++; } globalCacheMenu.add(new Separator()); JMenuItem manualAddMenuItem = new JMenuItem("Add manually..."); manualAddMenuItem.setMnemonic('A'); globalCacheMenu.add(manualAddMenuItem); manualAddMenuItem.addActionListener((java.awt.event.ActionEvent evt) -> { try { String ip = guiUtils.getInput("Enter GlobalCache IP-Name or -address", "GlobalCache entry", GlobalCache.defaultGlobalCacheIP); if (ip != null) GlobalCacheManager.getInstance().addManualGlobalCache(InetAddress.getByName(ip)); } catch (UnknownHostException ex) { guiUtils.error(ex); } }); globalCacheMenu.repaint(); globalCacheMenu.getParent().repaint(); }
/** * Shows the appropriate user interface that would allow the user to add * the given <tt>SourceUIContact</tt> to their contact list. * * @param contact the contact to add */ private void addContact(SourceUIContact contact) { SourceContact sourceContact = (SourceContact) contact.getDescriptor(); List<ContactDetail> details = sourceContact.getContactDetails( OperationSetPersistentPresence.class); int detailsCount = details.size(); if (detailsCount > 1) { JMenuItem addContactMenu = TreeContactList.createAddContactMenu( (SourceContact) contact.getDescriptor()); JPopupMenu popupMenu = ((JMenu) addContactMenu).getPopupMenu(); // Add a title label. JLabel infoLabel = new JLabel(); infoLabel.setText("<html><b>" + GuiActivator.getResources() .getI18NString("service.gui.ADD_CONTACT") + "</b></html>"); popupMenu.insert(infoLabel, 0); popupMenu.insert(new Separator(), 1); popupMenu.setFocusable(true); popupMenu.setInvoker(treeContactList); Point location = new Point(addContactButton.getX(), addContactButton.getY() + addContactButton.getHeight()); SwingUtilities.convertPointToScreen(location, treeContactList); location.y = location.y + treeContactList.getPathBounds(treeContactList.getSelectionPath()).y; popupMenu.setLocation(location.x + 8, location.y - 8); popupMenu.setVisible(true); } else if (details.size() == 1) { TreeContactList.showAddContactDialog( details.get(0), sourceContact.getDisplayName()); } }