List of usage examples for javax.swing JPopupMenu setVisible
@BeanProperty(description = "Makes the popup visible") public void setVisible(boolean b)
From source file:Main.java
/** * This method exists because popup menus can not be directly moved * (the have to be hidden and re-shown). *///from w w w . j a v a 2 s. co m public static void setLocationOnScreen(JPopupMenu visibleMenu, int x, int y) { Point invokerLocation = visibleMenu.getInvoker().getLocationOnScreen(); visibleMenu.setVisible(false); visibleMenu.show(visibleMenu.getInvoker(), x - invokerLocation.x, y - invokerLocation.y); }
From source file:Main.java
/** * Gives a tray icon a popup menu./*from w w w . jav a 2s . c o m*/ * * @param trayIcon * The tray icon * @param popup * The popup menu */ public static void setPopupMenu(final TrayIcon trayIcon, final JPopupMenu popup) { trayIcon.addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { if (e.isPopupTrigger()) { popup.setLocation(e.getX(), e.getY()); popup.setInvoker(popup); popup.setVisible(true); } } @Override public void mouseReleased(final MouseEvent e) { mousePressed(e); } }); }
From source file:org.cds06.speleograph.graph.SeriesMenu.java
private JPopupMenu createPopupMenuForSeries(final Series series) { if (series == null) return new JPopupMenu(); final JPopupMenu menu = new JPopupMenu(series.getName()); menu.removeAll();/*w w w . j ava 2 s. c o m*/ menu.add(new AbstractAction() { { putValue(NAME, "Renommer la srie"); } @Override public void actionPerformed(ActionEvent e) { menu.setVisible(false); String newName = ""; while (newName == null || newName.equals("")) { newName = (String) JOptionPane.showInputDialog(application, "Entrez un nouveau nom pour la srie", null, JOptionPane.QUESTION_MESSAGE, null, null, series.getName()); } series.setName(newName); } }); if (series.hasOwnAxis()) { menu.add(new AbstractAction() { { putValue(NAME, "Supprimer l'axe spcifique"); } @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes vous sr de vouloir supprimer cet axe ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { series.setAxis(null); } } }); } else { menu.add(new JMenuItem(new AbstractAction() { { putValue(NAME, "Crer un axe spcifique pour la srie"); } @Override public void actionPerformed(ActionEvent e) { String name = JOptionPane.showInputDialog(application, "Quel titre pour cet axe ?", series.getAxis().getLabel()); if (name == null || "".equals(name)) return; // User has canceled series.setAxis(new NumberAxis(name)); } })); } menu.add(new SetTypeMenu(series)); if (series.isWater()) { menu.addSeparator(); menu.add(new SumOnPeriodAction(series)); menu.add(new CreateCumulAction(series)); } if (series.isWaterCumul()) { menu.addSeparator(); menu.add(new SamplingAction(series)); } if (series.isPressure()) { menu.addSeparator(); menu.add(new CorrelateAction(series)); menu.add(new WaterHeightAction(series)); } menu.addSeparator(); menu.add(new AbstractAction() { { String name; if (series.canUndo()) name = "Annuler " + series.getItemsName(); else name = series.getLastUndoName(); putValue(NAME, name); if (series.canUndo()) setEnabled(true); else { setEnabled(false); } } @Override public void actionPerformed(ActionEvent e) { series.undo(); } }); menu.add(new AbstractAction() { { String name; if (series.canRedo()) { name = "Refaire " + series.getNextRedoName(); setEnabled(true); } else { name = series.getNextRedoName(); setEnabled(false); } putValue(NAME, name); } @Override public void actionPerformed(ActionEvent e) { series.redo(); } }); menu.add(new AbstractAction() { { putValue(NAME, I18nSupport.translate("menus.serie.resetSerie")); if (series.canUndo()) setEnabled(true); else setEnabled(false); } @Override public void actionPerformed(ActionEvent e) { series.reset(); } }); menu.add(new LimitDateRangeAction(series)); menu.add(new HourSettingAction(series)); menu.addSeparator(); { JMenuItem deleteItem = new JMenuItem("Supprimer la srie"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes-vous sur de vouloir supprimer cette srie ?\n" + "Cette action est dfinitive.", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { series.delete(); } } }); menu.add(deleteItem); } menu.addSeparator(); { final JMenuItem up = new JMenuItem("Remonter dans la liste"), down = new JMenuItem("Descendre dans la liste"); ActionListener listener = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(up)) { series.upSeriesInList(); } else { series.downSeriesInList(); } } }; up.addActionListener(listener); down.addActionListener(listener); if (series.isFirst()) { menu.add(down); } else if (series.isLast()) { menu.add(up); } else { menu.add(up); menu.add(down); } } menu.addSeparator(); { menu.add(new SeriesInfoAction(series)); } { JMenuItem colorItem = new JMenuItem("Couleur de la srie"); colorItem.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { series.setColor(JColorChooser.showDialog(application, I18nSupport.translate("actions.selectColorForSeries"), series.getColor())); } }); menu.add(colorItem); } { JMenu plotRenderer = new JMenu("Affichage de la srie"); final ButtonGroup modes = new ButtonGroup(); java.util.List<DrawStyle> availableStyles; if (series.isMinMax()) { availableStyles = DrawStyles.getDrawableStylesForHighLow(); } else { availableStyles = DrawStyles.getDrawableStyles(); } for (final DrawStyle s : availableStyles) { final JRadioButtonMenuItem item = new JRadioButtonMenuItem(DrawStyles.getHumanCheckboxText(s)); item.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (item.isSelected()) series.setStyle(s); } }); modes.add(item); if (s.equals(series.getStyle())) { modes.setSelected(item.getModel(), true); } plotRenderer.add(item); } menu.add(plotRenderer); } menu.addSeparator(); menu.add(new AbstractAction() { { putValue(Action.NAME, "Fermer le fichier"); } @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes-vous sur de vouloir fermer toutes les sries du fichier ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { final File f = series.getOrigin(); for (final Series s : Series.getInstances().toArray(new Series[Series.getInstances().size()])) { if (s.getOrigin().equals(f)) s.delete(); } } } }); return menu; }
From source file:net.minelord.gui.panes.IRCPane.java
public void connected() { SwingUtilities.invokeLater(new Runnable() { @Override/*from w w w. j a v a 2 s. co m*/ public void run() { scroller.setBounds(scrollerWithoutTopicWithUserlist); scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); status = "Connected"; client.connectAlertListener(); TitledBorder title = BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Connected"); title.setTitleJustification(TitledBorder.RIGHT); userList = new JList(client.getUserList().toArray()); userScroller = new JScrollPane(userList); userScroller.setBounds(userScrollerWithoutTopic); userList.setBounds(0, 0, 210, 250); userList.setBackground(Color.gray); userList.setForeground(Color.gray.darker().darker().darker()); userScroller.setBorder(title); userScroller.getVerticalScrollBar().setUnitIncrement(5); scroller.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "")); if (client.getTopic().trim().length() > 0) { topic = new JLabel(client.getTopic()); scroller.setBounds(scrollerWithTopicWithUserlist); userScroller.setBounds(userScrollWithTopic); userList.setBounds(0, 0, 210, 225); title = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Topic set by " + client.getTopicSetter()); title.setTitleJustification(TitledBorder.LEFT); topic.setBorder(title); topic.setBounds(topicBounds); add(topic); } else topic = new JLabel(""); input.setEnabled(true); input.requestFocus(); final JPopupMenu userPopup = new JPopupMenu(); JLabel breakLine = new JLabel("____"); JLabel help = new JLabel("Politely ask for help"); JLabel message = new JLabel("Message"); JLabel sortNormal = new JLabel("Normal"); JLabel sortAlphabetical = new JLabel("Alphabetical"); JLabel sortRoles = new JLabel("Roles"); help.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { userPopup.setVisible(false); sendMessage("/me kicks " + userList.getModel().getElementAt(userList.getSelectedIndex()) + " in the shins"); sendMessage("I need help you pleb"); } public void mouseReleased(MouseEvent e) { } }); message.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent paramMouseEvent) { userPopup.setVisible(false); input.setText("/msg " + userList.getModel().getElementAt(userList.getSelectedIndex()) + (input.getText().length() > 0 && input.getText().charAt(0) == ' ' ? input.getText() : " " + input.getText())); input.select(0, ("/msg " + userList.getModel().getElementAt(userList.getSelectedIndex()) + (input.getText().length() > 0 && input.getText().charAt(0) == ' ' ? "" : " ")) .length()); input.requestFocus(); } }); sortNormal.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent paramMouseEvent) { userPopup.setVisible(false); updateUserList(0); } }); sortAlphabetical.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent paramMouseEvent) { userPopup.setVisible(false); updateUserList(1); } }); sortRoles.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent paramMouseEvent) { userPopup.setVisible(false); updateUserList(2); } }); userPopup.add(help); userPopup.add(message); userPopup.add(breakLine); userPopup.add(sortNormal); userPopup.add(sortAlphabetical); userPopup.add(sortRoles); userList.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { check(e); } public void mouseReleased(MouseEvent e) { check(e); } public void check(MouseEvent e) { userList.setSelectedIndex(userList.locationToIndex(e.getPoint())); userPopup.show(userList, e.getX(), e.getY()); } }); add(userScroller); final JPopupMenu textPopup = new JPopupMenu(); JLabel copy = new JLabel("Copy"); copy.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent paramMouseEvent) { textPopup.setVisible(false); if (text.getSelectedText() != null && text.getSelectedText().length() != 0) { StringSelection selection = new StringSelection(text.getSelectedText()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(selection, selection); } } }); textPopup.add(copy); text.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) textPopup.show(text, e.getX(), e.getY()); } }); add(userScroller); repaint(); } }); }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java
/** * Opens the <tt>WritePanelRightButtonMenu</tt> when user clicks with the * right mouse button on the editor area. * * @param e the <tt>MouseEvent</tt> that notified us *//*w w w . j av a2 s . c o m*/ public void mouseClicked(MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || (e.isControlDown() && !e.isMetaDown())) { Point p = e.getPoint(); SwingUtilities.convertPointToScreen(p, e.getComponent()); //SPELLCHECK ArrayList<JMenuItem> contributedMenuEntries = new ArrayList<JMenuItem>(); for (ChatMenuListener listener : this.menuListeners) { contributedMenuEntries.addAll(listener.getMenuElements(this.chatPanel, e)); } for (JMenuItem item : contributedMenuEntries) { rightButtonMenu.add(item); } JPopupMenu rightMenu = rightButtonMenu.makeMenu(contributedMenuEntries); rightMenu.setInvoker(editorPane); rightMenu.setLocation(p.x, p.y); rightMenu.setVisible(true); } }
From source file:edu.ku.brc.ui.UIHelper.java
/** * Adds a special key listener to process a RETURN key for selecting and item * in the popup list. This is installed only for Windows and Linux. * @param popupMenu the popup menu to be altered. *///from ww w. ja v a 2 s . com public static void addSpecialKeyListenerForPopup(final JPopupMenu popupMenu) { if (!UIHelper.isMacOS()) { popupMenu.addKeyListener(new KeyAdapter() { //@Override public void keyPressed(KeyEvent e) { super.keyPressed(e); if (e.getKeyCode() == VK_ENTER) { for (int i = 0; i < popupMenu.getComponentCount(); i++) { Component c = popupMenu.getComponent(i); if (c instanceof JMenuItem) { JMenuItem mi = (JMenuItem) c; if (mi.isArmed()) { mi.doClick(); popupMenu.setVisible(false); } } } } } }); } }
From source file:base.BasePlayer.Main.java
void setMenuBar() { //filemenu.addMouseListener(this); //toolmenu.addMouseListener(this); filemenu = new JMenu("File"); toolmenu = new JMenu("Tools"); help = new JMenu("Help"); about = new JMenu("About"); menubar = new JMenuBar(); //help.addMouseListener(this); exit = new JMenuItem("Exit"); manual = new JButton("Online manual"); manual.addActionListener(new ActionListener() { @Override/*from www. j av a 2 s . co m*/ public void actionPerformed(ActionEvent arg0) { Main.gotoURL("https://baseplayer.fi/BPmanual"); } }); // opensamples = new JMenuItem("Add samples"); zoomout = new JButton("Zoom out"); back = new JButton("<<"); forward = new JButton(">>"); manage = new JButton("Variant Manager"); openvcfs = new JMenuItem("Add VCFs", open); openbams = new JMenuItem("Add BAMs", open); average = new JMenuItem("Coverage calculator"); update = new JMenuItem("Update"); update.setVisible(false); errorlog = new JMenuItem("View log"); //helpLabel = new JLabel("This is pre-release version of BasePlayer\nContact: help@baseplayer.fi\n\nUniversity of Helsinki"); addURL = new JMenu("Add from URL"); urlField = new JTextField("Enter URL"); addtracks = new JMenuItem("Add tracks"); fromURL = new JMenuItem("Add track from URL"); addcontrols = new JMenuItem("Add controls"); pleiadesButton = new JMenuItem("PLEIADES"); saveProject = new JMenuItem("Save project"); saveProjectAs = new JMenuItem("Save project as..."); openProject = new JMenuItem("Open project"); clear = new JMenuItem("Clear data"); clearMemory = new JMenuItem("Clean memory"); // welcome = new JMenuItem("Welcome screen"); filemenu.add(openvcfs); filemenu.add(openbams); variantCaller = new JMenuItem("Variant Caller"); tbrowser = new JMenuItem("Table Browser"); bconvert = new JMenuItem("BED converter"); peakCaller = new JMenuItem("Peak Caller"); addtracks = new JMenuItem("Add tracks", open); filemenu.add(addtracks); addcontrols = new JMenuItem("Add controls", open); filemenu.add(addcontrols); filemenu.add(fromURL); if (pleiades) { pleiadesButton.setPreferredSize(buttonDimension); pleiadesButton.addActionListener(this); filemenu.add(pleiadesButton); } filemenu.add(new JSeparator()); openProject = new JMenuItem("Open project", open); filemenu.add(openProject); saveProject = new JMenuItem("Save project", save); filemenu.add(saveProject); saveProjectAs = new JMenuItem("Save project as...", save); filemenu.add(saveProjectAs); filemenu.add(new JSeparator()); filemenu.add(genome); filemenu.add(update); filemenu.add(clear); filemenu.add(new JSeparator()); filemenu.add(exit); exit.addActionListener(this); menubar.add(filemenu); manage.addActionListener(this); manage.addMouseListener(this); update.addActionListener(this); average.addActionListener(this); average.setEnabled(false); average.setToolTipText("No bam/cram files opened"); tbrowser.addActionListener(this); bconvert.addActionListener(this); toolmenu.add(tbrowser); toolmenu.add(average); toolmenu.add(variantCaller); toolmenu.add(bconvert); fromURL.addMouseListener(this); fromURL.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { final JPopupMenu menu = new JPopupMenu(); final JTextField area = new JTextField(); JButton add = new JButton("Fetch"); JLabel label = new JLabel("Paste track URL below"); JScrollPane menuscroll = new JScrollPane(); add.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { String urltext = area.getText().trim(); Boolean size = true; if (urltext.contains("pleiades")) { openPleiades(urltext); return; } if (!FileRead.isTrackFile(urltext)) { showError("The file format is not supported.\n" + "Supported formats: bed, bigwig, bigbed, gff, bedgraph", "Error"); return; } if (!urltext.toLowerCase().endsWith(".bw") && !urltext.toLowerCase().endsWith(".bigwig") && !urltext.toLowerCase().endsWith(".bb") && !urltext.toLowerCase().endsWith(".bigbed")) { URL url = null; try { url = new URL(urltext); } catch (Exception ex) { menu.setVisible(false); Main.showError("Please paste whole url (protocol included)", "Error"); return; } URL testurl = url; HttpURLConnection huc = (HttpURLConnection) testurl.openConnection(); huc.setRequestMethod("HEAD"); int responseCode = huc.getResponseCode(); if (responseCode != 404) { SeekableStream stream = SeekableStreamFactory.getInstance().getStreamFor(url); TabixReader tabixReader = null; String index = null; try { if (stream.length() / (double) 1048576 >= Settings.settings .get("bigFile")) { size = false; } tabixReader = new TabixReader(urltext, urltext + ".tbi", stream); index = urltext + ".tbi"; testurl = new URL(index); huc = (HttpURLConnection) testurl.openConnection(); huc.setRequestMethod("HEAD"); responseCode = huc.getResponseCode(); if (responseCode == 404) { menu.setVisible(false); Main.showError("Index file (.tbi) not found in the URL.", "Error"); return; } } catch (Exception ex) { try { tabixReader = new TabixReader(urltext, urltext.substring(0, urltext.indexOf(".gz")) + ".tbi", stream); index = urltext.substring(0, urltext.indexOf(".gz")) + ".tbi"; } catch (Exception exc) { menu.setVisible(false); Main.showError("Could not read tabix file.", "Error"); } } if (tabixReader != null && index != null) { stream.close(); tabixReader.close(); menu.setVisible(false); FileRead filereader = new FileRead(); filereader.readBED(urltext, index, size); } } else { menu.setVisible(false); Main.showError("Not a valid URL", "Error"); } } else { URL url = null; try { url = new URL(urltext); } catch (Exception ex) { Main.showError("Please paste whole url (protocol included)", "Error"); return; } final URL testurl = url; HttpURLConnection huc = (HttpURLConnection) testurl.openConnection(); huc.setRequestMethod("HEAD"); int responseCode = huc.getResponseCode(); if (responseCode != 404) { menu.setVisible(false); FileRead filereader = new FileRead(); filereader.readBED(urltext, "nan", true); } else { menu.setVisible(false); Main.showError("Not a valid URL", "Error"); } } } catch (Exception ex) { ex.printStackTrace(); } } }); area.setFont(Main.menuFont); //area.setText("https://baseplayer.fi/tracks/Mappability_1000Genomes_pilot_mask.bed.gz"); menu.add(label); menu.add(menuscroll); menu.add(add); area.setPreferredSize(new Dimension(300, Main.defaultFontSize + 8)); area.setCaretPosition(0); area.revalidate(); menuscroll.getViewport().add(area); area.requestFocus(); menu.pack(); menu.show(frame, mouseX + 20, fromURL.getY()); } }); //toolmenu.add(peakCaller); variantCaller.setToolTipText("No bam/cram files opened"); variantCaller.addActionListener(this); variantCaller.setEnabled(false); peakCaller.setEnabled(true); peakCaller.addActionListener(this); settings.addActionListener(this); clearMemory.addActionListener(this); errorlog.addActionListener(this); toolmenu.add(clearMemory); toolmenu.add(errorlog); toolmenu.add(new JSeparator()); toolmenu.add(settings); menubar.add(toolmenu); menubar.add(manage); area = new JEditorPane(); String infotext = "<html><h2>BasePlayer</h2>This is a version " + version + " of BasePlayer (<a href=https://baseplayer.fi>https://baseplayer.fi</a>)<br/> Author: Riku Katainen <br/> University of Helsinki<br/>" + "Tumor Genomics Group (<a href=http://research.med.helsinki.fi/gsb/aaltonen/>http://research.med.helsinki.fi/gsb/aaltonen/</a>) <br/> " + "Contact: help@baseplayer.fi <br/> <br/>" + "Supported filetype for variants is VCF and VCF.gz (index file will be created if missing)<br/> " + "Supported filetypes for reads are BAM and CRAM. Index files required (.bai or .crai). <br/> " + "Supported filetypes for additional tracks are BED(.gz), GFF.gz, BedGraph, BigWig, BigBed.<br/> (tabix index required for bgzipped files). <br/><br/> " + "For optimal usage, you should have vcf.gz and bam -files for each sample. <br/> " + "e.g. in case you have a sample named as sample1, name all files similarly and <br/>" + "place in the same folder:<br/>" + "sample1.vcf.gz<br/>" + "sample1.vcf.gz.tbi<br/>" + "sample1.bam<br/>" + "sample1.bam.bai<br/><br/>" + "When you open sample1.vcf.gz, sample1.bam is recognized and opened<br/>" + "on the same track.<br/><br/>" + "Instructional videos can be viewed at our <a href=https://www.youtube.com/channel/UCywq-T7W0YPzACyB4LT7Q3g> Youtube channel</a>"; area = new JEditorPane(); area.setEditable(false); area.setEditorKit(JEditorPane.createEditorKitForContentType("text/html")); area.setText(infotext); area.setFont(Main.menuFont); area.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { HyperlinkEvent.EventType type = hyperlinkEvent.getEventType(); final URL url = hyperlinkEvent.getURL(); if (type == HyperlinkEvent.EventType.ACTIVATED) { Main.gotoURL(url.toString()); } } }); about.add(area); about.addMouseListener(this); help.add(about); help.add(manual); menubar.add(help); JLabel emptylab = new JLabel(" "); emptylab.setEnabled(false); emptylab.setOpaque(false); menubar.add(emptylab); chromosomeDropdown.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 1, Color.lightGray)); chromosomeDropdown.setBorder(BorderFactory.createCompoundBorder(chromosomeDropdown.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); chromlabel.setToolTipText("Current chromosome"); chromlabel.setFocusable(false); chromlabel.addMouseListener(this); chromlabel.setBackground(Color.white); chromlabel.setEditable(false); chromlabel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 0, Color.lightGray)); chromlabel.setBorder(BorderFactory.createCompoundBorder(chromlabel.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); menubar.add(chromlabel); chromosomeDropdown.setBackground(Color.white); chromosomeDropdown.setToolTipText("Current chromosome"); menubar.add(chromosomeDropdown); JLabel empty3 = new JLabel(" "); empty3.setEnabled(false); empty3.setOpaque(false); menubar.add(empty3); menubar.add(back); menubar.add(searchField); searchField.setForeground(Color.gray); searchField.setBorder(BorderFactory.createCompoundBorder(searchField.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); searchField.addMouseListener(this); menubar.add(back); menubar.add(searchField); searchField.setForeground(Color.gray); back.addMouseListener(this); back.setToolTipText("Back"); forward.addMouseListener(this); forward.setToolTipText("Forward"); back.setEnabled(false); forward.setEnabled(false); searchField.addMouseListener(this); menubar.add(back); menubar.add(searchField); searchField.setForeground(Color.gray); back.addMouseListener(this); forward.addMouseListener(this); back.setEnabled(false); forward.setEnabled(false); forward.setMargin(new Insets(0, 2, 0, 2)); back.setMargin(new Insets(0, 2, 0, 2)); menubar.add(forward); JLabel empty4 = new JLabel(" "); empty4.setOpaque(false); empty4.setEnabled(false); menubar.add(empty4); menubar.add(zoomout); JLabel empty5 = new JLabel(" "); empty5.setEnabled(false); empty5.setOpaque(false); menubar.add(empty5); positionField.setEditable(false); positionField.setBackground(new Color(250, 250, 250)); positionField.setMargin(new Insets(0, 2, 0, 0)); positionField.setBorder(BorderFactory.createCompoundBorder(widthLabel.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); menubar.add(positionField); widthLabel.setEditable(false); widthLabel.setBackground(new Color(250, 250, 250)); widthLabel.setMargin(new Insets(0, 2, 0, 0)); widthLabel.setBorder(BorderFactory.createCompoundBorder(widthLabel.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); JLabel empty6 = new JLabel(" "); empty6.setEnabled(false); empty6.setOpaque(false); menubar.add(empty6); menubar.add(widthLabel); JLabel empty7 = new JLabel(" "); empty7.setOpaque(false); empty7.setEnabled(false); menubar.add(empty7); }