/** This method installs listeners for the JToolBar. */ protected void installListeners() { dockingListener = createDockingListener(); toolBar.addMouseListener(dockingListener); toolBar.addMouseMotionListener(dockingListener); propertyListener = createPropertyListener(); toolBar.addPropertyChangeListener(propertyListener); toolBarContListener = createToolBarContListener(); toolBar.addContainerListener(toolBarContListener); windowListener = createFrameListener(); floatFrame.addWindowListener(windowListener); toolBarFocusListener = createToolBarFocusListener(); if (toolBarFocusListener != null) { int count = toolBar.getComponentCount(); for (int i = 0; i < count; i++) toolBar.getComponent(i).addFocusListener(toolBarFocusListener); } }
/** * Fill the given panel by adding all necessary components to the different locations. * * @param panel The container to fill. Must have an BorderLayout. */ public void fillPanel(Container panel) { panel.add(this, BorderLayout.CENTER); JToolBar jb = new JToolBar(JToolBar.VERTICAL); jb.setFloatable(false); toolBarActions.setAlignmentX(0.5f); jb.add(toolBarActions); listAllMapModesButton.setAlignmentX(0.5f); listAllMapModesButton.setBorder(null); listAllMapModesButton.setFont(listAllMapModesButton.getFont().deriveFont(Font.PLAIN)); jb.add(listAllMapModesButton); if (Main.pref.getBoolean("sidetoolbar.togglevisible", true)) { jb.addSeparator(new Dimension(0, 18)); toolBarToggle.setAlignmentX(0.5f); jb.add(toolBarToggle); listAllToggleDialogsButton.setAlignmentX(0.5f); listAllToggleDialogsButton.setBorder(null); listAllToggleDialogsButton.setFont( listAllToggleDialogsButton.getFont().deriveFont(Font.PLAIN)); jb.add(listAllToggleDialogsButton); } final Component toToggle; if (Main.pref.getBoolean("sidetoolbar.scrollable", true)) { final ScrollViewport svp = new ScrollViewport(jb, ScrollViewport.VERTICAL_DIRECTION); toToggle = svp; panel.add(svp, BorderLayout.WEST); jb.addMouseWheelListener( new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent e) { svp.scroll(0, e.getUnitsToScroll() * 5); } }); } else { toToggle = jb; panel.add(jb, BorderLayout.WEST); } toToggle.setVisible(Main.pref.getBoolean("sidetoolbar.visible", true)); jb.addMouseListener( new PopupMenuLauncher( new JPopupMenu() { { add( new AbstractAction(tr("Hide edit toolbar")) { @Override public void actionPerformed(ActionEvent e) { Main.pref.put("sidetoolbar.visible", false); } }); } })); Main.pref.addPreferenceChangeListener( new Preferences.PreferenceChangedListener() { @Override public void preferenceChanged(PreferenceChangeEvent e) { if ("sidetoolbar.visible".equals(e.getKey())) { toToggle.setVisible(Main.pref.getBoolean("sidetoolbar.visible")); } } }); if (statusLine != null && Main.pref.getBoolean("statusline.visible", true)) { panel.add(statusLine, BorderLayout.SOUTH); } }