List of usage examples for javax.swing JToggleButton addActionListener
public void addActionListener(ActionListener l)
ActionListener
to the button. From source file:krasa.formatter.plugin.ProjectSettingsForm.java
public ProjectSettingsForm(final Project project) { DONATEButton.setBorder(BorderFactory.createEmptyBorder()); DONATEButton.setContentAreaFilled(false); this.project = project; JToggleButton[] modifiableButtons = new JToggleButton[] { useDefaultFormatter, useEclipseFormatter, optimizeImportsCheckBox, enableJavaFormatting, doNotFormatOtherFilesRadioButton, formatOtherFilesWithExceptionsRadioButton, formatSelectedTextInAllFileTypes, enableJSFormatting, enableCppFormatting, importOrderConfigurationManualRadioButton, importOrderConfigurationFromFileRadioButton, enableGWTNativeMethodsCheckBox }; for (JToggleButton button : modifiableButtons) { button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateComponents();// ww w . java 2 s . co m } }); } JTextField[] modifiableFields = new JTextField[] { pathToEclipsePreferenceFileJava, pathToEclipsePreferenceFileJS, pathToEclipsePreferenceFileCpp, disabledFileTypes, importOrder, pathToImportOrderPreferenceFile }; for (JTextField field : modifiableFields) { field.getDocument().addDocumentListener(new DocumentAdapter() { protected void textChanged(DocumentEvent e) { updateComponents(); } }); } eclipsePreferenceFilePathJavaBrowse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { browseForFile(pathToEclipsePreferenceFileJava); } }); pathToImportOrderPreferenceFileBrowse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { browseForFile(pathToImportOrderPreferenceFile); } }); eclipsePreferenceFilePathJSBrowse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { browseForFile(pathToEclipsePreferenceFileJS); } }); eclipsePreferenceFilePathCppBrowse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { browseForFile(pathToEclipsePreferenceFileCpp); } }); rootComponent.addAncestorListener(new AncestorListener() { public void ancestorAdded(AncestorEvent event) { // Called when component becomes visible, to ensure that the // popups // are visible when the form is shown for the first time. updateComponents(); } public void ancestorRemoved(AncestorEvent event) { } public void ancestorMoved(AncestorEvent event) { } }); pathToEclipsePreferenceFileJava.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { setJavaFormatterProfileModel(); } }); pathToEclipsePreferenceFileJS.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { setJavaScriptFormatterProfileModel(); } }); pathToEclipsePreferenceFileCpp.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { setCppFormatterProfileModel(); } }); newProfile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isModified(displayedSettings)) { createConfirmation("Profile was modified, save changes to current profile?", "Yes", "No", new Runnable() { @Override public void run() { apply(); createProfile(); } }, new Runnable() { @Override public void run() { importFrom(displayedSettings); createProfile(); } }, 0).showInFocusCenter(); } else { createProfile(); } } private void createProfile() { Settings settings = GlobalSettings.getInstance().newSettings(); refreshProfilesModel(); profiles.setSelectedItem(settings); } }); copyProfile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isModified(displayedSettings)) { ListPopup confirmation = createConfirmation( "Profile was modified, save changes to current profile?", "Yes", "No", new Runnable() { @Override public void run() { apply(); copyProfile(); } }, new Runnable() { @Override public void run() { importFrom(displayedSettings); copyProfile(); } }, 0); confirmation.showInFocusCenter(); } else { copyProfile(); } } private void copyProfile() { Settings settings = GlobalSettings.getInstance().copySettings(displayedSettings); refreshProfilesModel(); profiles.setSelectedItem(settings); } }); setJavaFormatterProfileModel(); setJavaScriptFormatterProfileModel(); setCppFormatterProfileModel(); profilesModel = createProfilesModel(); profiles.setModel(profilesModel); profiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // && isSameId() if (displayedSettings != null && getSelectedItem() != null && isModified(displayedSettings)) { showConfirmationDialogOnProfileChange(); } else if (displayedSettings != null && getSelectedItem() != null) { importFromInternal(getSelectedItem()); } } }); profiles.setRenderer(new ListCellRendererWrapper() { @Override public void customize(JList jList, Object value, int i, boolean b, boolean b1) { if (value != null) { setText(((Settings) value).getName()); } } }); rename.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JTextField content = new JTextField(); content.setText(displayedSettings.getName()); JBPopup balloon = PopupFactoryImpl.getInstance().createComponentPopupBuilder(content, content) .createPopup(); balloon.setMinimumSize(new Dimension(200, 20)); balloon.addListener(new JBPopupListener() { @Override public void beforeShown(LightweightWindowEvent event) { } @Override public void onClosed(LightweightWindowEvent event) { displayedSettings.setName(content.getText()); } }); balloon.showUnderneathOf(rename); } }); delete.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int selectedIndex = profiles.getSelectedIndex(); GlobalSettings.getInstance().delete(getSelectedItem(), getProject()); profiles.setModel(profilesModel = createProfilesModel()); int itemCount = profiles.getItemCount(); if (selectedIndex < itemCount && selectedIndex >= 0) { Object itemAt = profiles.getItemAt(selectedIndex); importFromInternal((Settings) itemAt); profiles.setSelectedIndex(selectedIndex); } if (selectedIndex == itemCount && selectedIndex - 1 >= 0) { Object itemAt = profiles.getItemAt(selectedIndex - 1); importFromInternal((Settings) itemAt); profiles.setSelectedIndex(selectedIndex - 1); } else { Settings defaultSettings = GlobalSettings.getInstance().getDefaultSettings(); importFromInternal(defaultSettings); profiles.setSelectedItem(defaultSettings); } } }); DONATEButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { BareBonesBrowserLaunch.openURL( "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=75YN7U7H7D7XU&lc=CZ&item_name=Eclipse%20code%20formatter%20%2d%20IntelliJ%20plugin%20%2d%20Donation¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest"); } }); helpButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { BareBonesBrowserLaunch .openURL("http://code.google.com/p/eclipse-code-formatter-intellij-plugin/wiki/HowTo"); } }); ; homepage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { BareBonesBrowserLaunch.openURL("http://plugins.intellij.net/plugin/?idea&id=6546"); } }); }
From source file:org.nbheaven.sqe.codedefects.history.controlcenter.panels.SQEHistoryPanel.java
/** Creates new form SQEHistoryPanel */ public SQEHistoryPanel() { historyChart = org.jfree.chart.ChartFactory.createStackedXYAreaChart(null, "Snapshot", "CodeDefects", perProjectDataSet, PlotOrientation.VERTICAL, false, true, false); historyChart.setBackgroundPaint(Color.WHITE); historyChart.getXYPlot().setRangeGridlinePaint(Color.BLACK); historyChart.getXYPlot().setDomainGridlinePaint(Color.BLACK); historyChart.getXYPlot().setBackgroundPaint(Color.WHITE); XYPlot plot = historyChart.getXYPlot(); plot.setForegroundAlpha(0.7f);/*from w w w . ja v a2s .c o m*/ // plot.getRenderer(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LogarithmicAxis rangeAxis = new LogarithmicAxis("CodeDefects"); rangeAxis.setStrictValuesFlag(false); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.setRangeAxis(rangeAxis); StackedXYAreaRenderer2 categoryItemRenderer = new StackedXYAreaRenderer2(); //3D(); categoryItemRenderer.setSeriesPaint(0, Color.RED); categoryItemRenderer.setSeriesPaint(1, Color.ORANGE); categoryItemRenderer.setSeriesPaint(2, Color.YELLOW); plot.setRenderer(categoryItemRenderer); ChartPanel historyChartPanel = new ChartPanel(historyChart); historyChartPanel.setBorder(null); historyChartPanel.setPreferredSize(new Dimension(150, 200)); historyChartPanel.setBackground(Color.WHITE); initComponents(); historyView.setLayout(new BorderLayout()); historyView.add(historyChartPanel, BorderLayout.CENTER); JPanel selectorPanel = new JPanel(); selectorPanel.setOpaque(false); GroupLayout layout = new GroupLayout(selectorPanel); selectorPanel.setLayout(layout); // Turn on automatically adding gaps between components layout.setAutocreateGaps(true); // Turn on automatically creating gaps between components that touch // the edge of the container and the container. layout.setAutocreateContainerGaps(true); ParallelGroup horizontalParallelGroup = layout.createParallelGroup(GroupLayout.LEADING); SequentialGroup verticalSequentialGroup = layout.createSequentialGroup(); layout.setHorizontalGroup(layout.createSequentialGroup().add(horizontalParallelGroup)); layout.setVerticalGroup(verticalSequentialGroup); clearHistoryButton = new JButton(); clearHistoryButton.setEnabled(false); clearHistoryButton.setIcon(ImageUtilities .image2Icon(ImageUtilities.loadImage("org/nbheaven/sqe/codedefects/history/resources/trash.png"))); clearHistoryButton.setOpaque(false); clearHistoryButton.setFocusPainted(false); clearHistoryButton.setToolTipText( NbBundle.getBundle("org/nbheaven/sqe/codedefects/history/controlcenter/panels/Bundle") .getString("HINT_clear_button")); horizontalParallelGroup.add(clearHistoryButton); verticalSequentialGroup.add(clearHistoryButton); clearHistoryButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (null != activeHistory) { activeHistory.clear(); } } }); Component createVerticalStrut = Box.createVerticalStrut(10); horizontalParallelGroup.add(createVerticalStrut); verticalSequentialGroup.add(createVerticalStrut); for (final QualityProvider provider : SQEUtilities.getProviders()) { final JToggleButton providerButton = new JToggleButton(); providerButton.setIcon(provider.getIcon()); providerButton.setOpaque(false); providerButton.setFocusPainted(false); horizontalParallelGroup.add(providerButton); verticalSequentialGroup.add(providerButton); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { if (providerButton.isSelected()) { addSelectedProvider(provider); } else { removeSelectedProvider(provider); } updateView(); } }; providerButton.addActionListener(listener); addSelectedProvider(provider); providerButton.setSelected(true); } historyView.add(selectorPanel, BorderLayout.EAST); }
From source file:io.gameover.utilities.pixeleditor.Pixelizer.java
private void addSelectFrameButtonToPanel(int index) { JToggleButton button = new JToggleButton("" + index); button.setPreferredSize(new Dimension(20, 20)); button.setMargin(new Insets(0, 0, 0, 0)); button.setFont(button.getFont().deriveFont(9f)); button.setActionCommand("" + (index - 1)); button.addActionListener(getSelectFrameActionListener()); button.addMouseListener(new SelectFramePopClickListener(this, index - 1)); this.selectFrameButtons.add(button); this.selectFramePanel.add(button, LayoutUtils.xyi((index - 1) % 4 + 1, (index - 1) / 4 + 1, 0d, 0d, new Insets(1, 1, 1, 1))); }
From source file:net.itransformers.topologyviewer.gui.GraphViewerPanel.java
private JToggleButton createMouseModeButton(final AbstractModalGraphMouse graphMouse) { final String selectText = "Move graph"; final JToggleButton button = new JToggleButton(selectText); button.setToolTipText("If toggled then you can move the entire graph."); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (button.isSelected()) { graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); } else { graphMouse.setMode(ModalGraphMouse.Mode.PICKING); }/* ww w . j a v a2 s . com*/ } }); return button; }
From source file:ca.sqlpower.wabit.swingui.chart.ChartPanel.java
/** * Subroutine of {@link #buildUI()}. Makes a chart type toggle button and * adds it to the button group./*from ww w . j ava 2 s.co m*/ * * @param caption * The text to appear under the button * @param type * The type of chart the buttons should select * @param icon * The icon for the button * @param fontSize * the font size for the toggle buttons. The default font size of * the toggle buttons are different than the default font size of * JButtons on some platforms. This value should be equal to the * JButton font size. This is a float as deriving fonts with a size * takes a float. * @return A button properly configured for the new-look Wabit toolbar. */ private JToggleButton makeChartTypeButton(String caption, ChartType type, Icon icon, float fontSize) { JToggleButton b = new JToggleButton(caption, icon); b.putClientProperty(CHART_TYPE_PROP_KEY, type); chartTypeButtonGroup.add(b); b.setVerticalTextPosition(SwingConstants.BOTTOM); b.setHorizontalTextPosition(SwingConstants.CENTER); // Removes button borders on OS X 10.5 b.putClientProperty("JButton.buttonType", "toolbar"); b.addActionListener(genericActionListener); b.setFont(b.getFont().deriveFont(fontSize)); return b; }
From source file:net.schweerelos.parrot.CombinedParrotApp.java
@SuppressWarnings("serial") private JToggleButton setupNavigatorButton(final String name, final String accelerator, final NavigatorComponent navigator) { final Component component = navigator.asJComponent(); AbstractAction showNavigatorAction = new AbstractAction(name) { @Override//w w w .j a v a 2 s. c om public void actionPerformed(ActionEvent e) { if (!(e.getSource() instanceof JToggleButton)) { return; } final Window window; if (component instanceof Window) { window = (Window) component; } else { window = SwingUtilities.getWindowAncestor(component); } JToggleButton button = (JToggleButton) e.getSource(); boolean show = button.isSelected(); if (show) { if (window != CombinedParrotApp.this && preferredFrameLocations.containsKey(window)) { window.setLocation(preferredFrameLocations.get(window)); } } if (navigator.tellSelectionWhenShown()) { Collection<NodeWrapper> selectedNodes = activeMainView.getSelectedNodes(); navigator.setSelectedNodes(selectedNodes); } component.setVisible(show); if (show) { window.setVisible(true); } else if (window != CombinedParrotApp.this) { window.setVisible(false); } } }; showNavigatorAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control " + accelerator)); final JToggleButton button = new JToggleButton(showNavigatorAction); button.setToolTipText("Show " + name.toLowerCase()); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { button.setToolTipText((button.isSelected() ? "Hide " : "Show ") + name.toLowerCase()); } }); final Window window; if (component instanceof Window) { window = (Window) component; } else { window = SwingUtilities.getWindowAncestor(component); } if (window != null) { window.addComponentListener(new ComponentAdapter() { @Override public void componentHidden(ComponentEvent e) { button.setSelected(false); if (window != CombinedParrotApp.this) { preferredFrameLocations.put(window, window.getLocation()); } } @Override public void componentShown(ComponentEvent e) { button.setSelected(true); } }); } return button; }
From source file:net.sf.firemox.DeckBuilder.java
/** * Creates new form DeckBuilder// ww w . j a v a2 s . c o m */ private DeckBuilder() { super("DeckBuilder"); form = this; timerPanel = new TimerGlassPane(); cardLoader = new CardLoader(timerPanel); timer = new Timer(200, cardLoader); setGlassPane(timerPanel); try { setIconImage(Picture.loadImage(IdConst.IMAGES_DIR + "deckbuilder.gif")); } catch (Exception e) { // IGNORING } // Load settings loadSettings(); // Initialize components final JMenuItem newItem = UIHelper.buildMenu("menu_db_new", 'n', this); newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK)); final JMenuItem loadItem = UIHelper.buildMenu("menu_db_load", 'o', this); loadItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); final JMenuItem saveAsItem = UIHelper.buildMenu("menu_db_saveas", 'a', this); saveAsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0)); final JMenuItem saveItem = UIHelper.buildMenu("menu_db_save", 's', this); saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); final JMenuItem quitItem = UIHelper.buildMenu("menu_db_exit", this); quitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK)); final JMenuItem deckConstraintsItem = UIHelper.buildMenu("menu_db_constraints", 'c', this); deckConstraintsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); final JMenuItem aboutItem = UIHelper.buildMenu("menu_help_about", 'a', this); aboutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.SHIFT_MASK)); final JMenuItem convertDCK = UIHelper.buildMenu("menu_convert_DCK_MP", this); final JMenu mainMenu = UIHelper.buildMenu("menu_file"); mainMenu.add(newItem); mainMenu.add(loadItem); mainMenu.add(saveAsItem); mainMenu.add(saveItem); mainMenu.add(new JSeparator()); mainMenu.add(quitItem); super.optionMenu = new JMenu("Options"); final JMenu convertMenu = UIHelper.buildMenu("menu_convert"); convertMenu.add(convertDCK); final JMenuItem helpItem = UIHelper.buildMenu("menu_help_help", 'h', this); helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); final JMenu helpMenu = new JMenu("?"); helpMenu.add(helpItem); helpMenu.add(deckConstraintsItem); helpMenu.add(aboutItem); final JMenuBar menuBar = new JMenuBar(); menuBar.add(mainMenu); initAbstractMenu(); menuBar.add(optionMenu); menuBar.add(convertMenu); menuBar.add(helpMenu); setJMenuBar(menuBar); addWindowListener(this); // Build the panel containing amount of available cards final JLabel amountLeft = new JLabel("<html>0/?", SwingConstants.RIGHT); // Build the left list allListModel = new MListModel<MCardCompare>(amountLeft, false); leftList = new ThreadSafeJList(allListModel); leftList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); leftList.setLayoutOrientation(JList.VERTICAL); leftList.getSelectionModel().addListSelectionListener(this); leftList.addMouseListener(this); leftList.setVisibleRowCount(10); // Initialize the text field containing the amount to add addQtyTxt = new JTextField("1"); // Build the "Add" button addButton = new JButton(LanguageManager.getString("db_add")); addButton.setMnemonic('a'); addButton.setEnabled(false); // Build the panel containing : "Add" amount and "Add" button final Box addPanel = Box.createHorizontalBox(); addPanel.add(addButton); addPanel.add(addQtyTxt); addPanel.setMaximumSize(new Dimension(32010, 26)); // Build the panel containing the selected card name cardNameTxt = new JTextField(); new HireListener(cardNameTxt, addButton, this, leftList); final JLabel searchLabel = new JLabel(LanguageManager.getString("db_search") + " : "); searchLabel.setLabelFor(cardNameTxt); // Build the panel containing search label and card name text field final Box searchPanel = Box.createHorizontalBox(); searchPanel.add(searchLabel); searchPanel.add(cardNameTxt); searchPanel.setMaximumSize(new Dimension(32010, 26)); listScrollerLeft = new JScrollPane(leftList); MToolKit.addOverlay(listScrollerLeft); // Build the left panel containing : list, available amount, "Add" panel final JPanel srcPanel = new JPanel(null); srcPanel.add(searchPanel); srcPanel.add(listScrollerLeft); srcPanel.add(amountLeft); srcPanel.add(addPanel); srcPanel.setMinimumSize(new Dimension(220, 200)); srcPanel.setLayout(new BoxLayout(srcPanel, BoxLayout.Y_AXIS)); // Initialize constraints constraintsChecker = new ConstraintsChecker(); constraintsChecker.setBorder(new EtchedBorder()); final JScrollPane constraintsCheckerScroll = new JScrollPane(constraintsChecker); MToolKit.addOverlay(constraintsCheckerScroll); // create a pane with the oracle text for the present card oracleText = new JLabel(); oracleText.setPreferredSize(new Dimension(180, 200)); oracleText.setVerticalAlignment(SwingConstants.TOP); final JScrollPane oracle = new JScrollPane(oracleText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); MToolKit.addOverlay(oracle); // build some Pie Charts and a panel to display it initSets(); datasets = new ChartSets(); final JTabbedPane tabbedPane = new JTabbedPane(); for (ChartFilter filter : ChartFilter.values()) { final Dataset dataSet = filter.createDataSet(this); final JFreeChart chart = new JFreeChart(null, null, filter.createPlot(dataSet, painterMapper.get(filter)), false); datasets.addDataSet(filter, dataSet); ChartPanel pieChartPanel = new ChartPanel(chart, true); tabbedPane.add(pieChartPanel, filter.getTitle()); } // add the Constraints scroll panel and Oracle text Pane to the tabbedPane tabbedPane.add(constraintsCheckerScroll, LanguageManager.getString("db_constraints")); tabbedPane.add(oracle, LanguageManager.getString("db_text")); tabbedPane.setSelectedComponent(oracle); // The toollBar for color filtering toolBar = new JToolBar(); toolBar.setFloatable(false); final JButton clearButton = UIHelper.buildButton("clear"); clearButton.addActionListener(this); toolBar.add(clearButton); final JToggleButton toggleColorlessButton = new JToggleButton( UIHelper.getTbsIcon("mana/colorless/small/" + MdbLoader.unknownSmlMana), true); toggleColorlessButton.setActionCommand("0"); toggleColorlessButton.addActionListener(this); toolBar.add(toggleColorlessButton); for (int index = 1; index < IdCardColors.CARD_COLOR_NAMES.length; index++) { final JToggleButton toggleButton = new JToggleButton( UIHelper.getTbsIcon("mana/colored/small/" + MdbLoader.coloredSmlManas[index]), true); toggleButton.setActionCommand(String.valueOf(index)); toggleButton.addActionListener(this); toolBar.add(toggleButton); } // sorted card type combobox creation final List<String> idCards = new ArrayList<String>(Arrays.asList(CardFactory.exportedIdCardNames)); Collections.sort(idCards); final Object[] cardTypes = ArrayUtils.addAll(new String[] { LanguageManager.getString("db_types.any") }, idCards.toArray()); idCardComboBox = new JComboBox(cardTypes); idCardComboBox.setSelectedIndex(0); idCardComboBox.addActionListener(this); idCardComboBox.setActionCommand("cardTypeFilter"); // sorted card properties combobox creation final List<String> properties = new ArrayList<String>( CardFactory.getPropertiesName(DeckConstraints.getMinProperty(), DeckConstraints.getMaxProperty())); Collections.sort(properties); final Object[] cardProperties = ArrayUtils .addAll(new String[] { LanguageManager.getString("db_properties.any") }, properties.toArray()); propertiesComboBox = new JComboBox(cardProperties); propertiesComboBox.setSelectedIndex(0); propertiesComboBox.addActionListener(this); propertiesComboBox.setActionCommand("propertyFilter"); final JLabel colors = new JLabel(" " + LanguageManager.getString("colors") + " : "); final JLabel types = new JLabel(" " + LanguageManager.getString("types") + " : "); final JLabel property = new JLabel(" " + LanguageManager.getString("properties") + " : "); // filter Panel with colors toolBar and card type combobox final Box filterPanel = Box.createHorizontalBox(); filterPanel.add(colors); filterPanel.add(toolBar); filterPanel.add(types); filterPanel.add(idCardComboBox); filterPanel.add(property); filterPanel.add(propertiesComboBox); getContentPane().add(filterPanel, BorderLayout.NORTH); // Destination section : // Build the panel containing amount of available cards final JLabel rightAmount = new JLabel("0/?", SwingConstants.RIGHT); rightAmount.setMaximumSize(new Dimension(220, 26)); // Build the right list rightListModel = new MCardTableModel(new MListModel<MCardCompare>(rightAmount, true)); rightListModel.addTableModelListener(this); rightList = new JTable(rightListModel); rightList.setShowGrid(false); rightList.setTableHeader(null); rightList.getSelectionModel().addListSelectionListener(this); rightList.getColumnModel().getColumn(0).setMaxWidth(25); rightList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); // Build the panel containing the selected deck deckNameTxt = new JTextField("loading..."); deckNameTxt.setEditable(false); deckNameTxt.setBorder(null); final JLabel deckLabel = new JLabel(LanguageManager.getString("db_deck") + " : "); deckLabel.setLabelFor(deckNameTxt); final Box deckNamePanel = Box.createHorizontalBox(); deckNamePanel.add(deckLabel); deckNamePanel.add(deckNameTxt); deckNamePanel.setMaximumSize(new Dimension(220, 26)); // Initialize the text field containing the amount to remove removeQtyTxt = new JTextField("1"); // Build the "Remove" button removeButton = new JButton(LanguageManager.getString("db_remove")); removeButton.setMnemonic('r'); removeButton.addMouseListener(this); removeButton.setEnabled(false); // Build the panel containing : "Remove" amount and "Remove" button final Box removePanel = Box.createHorizontalBox(); removePanel.add(removeButton); removePanel.add(removeQtyTxt); removePanel.setMaximumSize(new Dimension(220, 26)); // Build the right panel containing : list, available amount, constraints final JScrollPane deskListScroller = new JScrollPane(rightList); MToolKit.addOverlay(deskListScroller); deskListScroller.setBorder(BorderFactory.createLineBorder(Color.GRAY)); deskListScroller.setMinimumSize(new Dimension(220, 200)); deskListScroller.setMaximumSize(new Dimension(220, 32000)); final Box destPanel = Box.createVerticalBox(); destPanel.add(deckNamePanel); destPanel.add(deskListScroller); destPanel.add(rightAmount); destPanel.add(removePanel); destPanel.setMinimumSize(new Dimension(220, 200)); destPanel.setMaximumSize(new Dimension(220, 32000)); // Build the panel containing the name of card in picture cardPictureNameTxt = new JLabel("<html><i>no selected card</i>"); final Box cardPictureNamePanel = Box.createHorizontalBox(); cardPictureNamePanel.add(cardPictureNameTxt); cardPictureNamePanel.setMaximumSize(new Dimension(32010, 26)); // Group the detail panels final JPanel viewCard = new JPanel(null); viewCard.add(cardPictureNamePanel); viewCard.add(CardView.getInstance()); viewCard.add(tabbedPane); viewCard.setLayout(new BoxLayout(viewCard, BoxLayout.Y_AXIS)); final Box mainPanel = Box.createHorizontalBox(); mainPanel.add(destPanel); mainPanel.add(viewCard); // Add the main panel getContentPane().add(srcPanel, BorderLayout.WEST); getContentPane().add(mainPanel, BorderLayout.CENTER); // Size this frame getRootPane().setPreferredSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT)); getRootPane().setMinimumSize(getRootPane().getPreferredSize()); pack(); }
From source file:es.emergya.ui.gis.CustomMapView.java
@Override public void addLayer(Layer layer, boolean showOnButtonList, String icon) { if (layer instanceof MapViewerLayer) { minZoom = Math.max(((MapViewerLayer) layer).getMinZoomLevel(), getMinZoom()); maxZoom = Math.min(((MapViewerLayer) layer).getMaxZoomLevel(), getMaxZoom()); if (zoomFactor > maxZoom || zoomFactor < minZoom) { zoomFactor = (maxZoom + minZoom) / 2; }/*w w w . j av a2 s . co m*/ zoomTo(center, zoom2Scale(zoomFactor)); } if (showOnButtonList) { JToggleButton b = new JToggleButton(layer.name, LogicConstants.getIcon(icon), layer.visible); // b.setVerticalTextPosition(SwingConstants.BOTTOM); // b.setHorizontalTextPosition(SwingConstants.CENTER); b.setActionCommand(layer.name); b.addActionListener(layerControlListener); layerControls.add(b); layerControlPanel.removeAll(); layerControlPanel.add(Box.createHorizontalStrut(10)); for (JToggleButton bt : layerControls) { layerControlPanel.add(bt); layerControlPanel.add(Box.createHorizontalGlue()); } layerControlPanel.updateUI(); } super.addLayer(layer); }
From source file:es.emergya.ui.gis.CustomMapView.java
@Override public void addLayer(Layer layer, boolean showOnButtonList, int pos) { if (layer instanceof MapViewerLayer) { minZoom = Math.max(((MapViewerLayer) layer).getMinZoomLevel(), getMinZoom()); maxZoom = Math.min(((MapViewerLayer) layer).getMaxZoomLevel(), getMaxZoom()); if (zoomFactor > maxZoom || zoomFactor < minZoom) { zoomFactor = (maxZoom + minZoom) / 2; }/*from w w w . jav a2 s. co m*/ zoomTo(center, zoom2Scale(zoomFactor)); } if (showOnButtonList) { JToggleButton b = new JToggleButton(layer.name, LogicConstants.getIcon("capas_button_" + layer.name.toLowerCase()), layer.visible); // b.setVerticalTextPosition(SwingConstants.BOTTOM); // b.setHorizontalTextPosition(SwingConstants.CENTER); b.setActionCommand(layer.name); b.addActionListener(layerControlListener); layerControls.add(b); layerControlPanel.removeAll(); layerControlPanel.add(Box.createHorizontalStrut(10)); for (JToggleButton bt : layerControls) { layerControlPanel.add(bt); layerControlPanel.add(Box.createHorizontalGlue()); } layerControlPanel.updateUI(); } super.addLayer(layer, pos); }
From source file:es.emergya.ui.gis.CustomMapView.java
public CustomMapView() { super();//from w ww. j av a2 s . co m menu = new MainMenu(); contentPane.add(panel, BorderLayout.CENTER); // iniciar los controles mostrar/ocultar capas layerControls = new LinkedList<JToggleButton>(); JToggleButton botonMostrarOcultarBotones = new JToggleButton(getI18n().getString("map.layers.hideButtons"), LogicConstants.getIcon("capas_button_mostrar"), false); botonMostrarOcultarBotones.setSelected(true); botonMostrarOcultarBotones.setActionCommand("#hide"); // b.setVerticalTextPosition(SwingConstants.BOTTOM); // b.setHorizontalTextPosition(SwingConstants.CENTER); botonMostrarOcultarBotones.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JToggleButton b = (JToggleButton) e.getSource(); if (e.getActionCommand().equals("#hide")) { layerControlPanel.removeAll(); layerControlPanel.add(Box.createHorizontalStrut(10)); layerControlPanel.add(b); b.setActionCommand("#show"); b.setText(getI18n().getString("map.layers.showButtons")); } else { layerControlPanel.removeAll(); layerControlPanel.add(Box.createHorizontalStrut(10)); for (JToggleButton bt : layerControls) { layerControlPanel.add(bt); layerControlPanel.add(Box.createHorizontalGlue()); } b.setActionCommand("#hide"); b.setText(getI18n().getString("map.layers.hideButtons")); } layerControlPanel.updateUI(); } }); layerControls.add(botonMostrarOcultarBotones); final JToggleButton botonTodoasLasCapas = new JToggleButton(getI18n().getString("map.layers.allLayers"), LogicConstants.getIcon("capas_button_mostrar"), false); layerDialog = new LayerSelectionDialog(this); layerDialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { botonTodoasLasCapas.setSelected(false); } }); botonTodoasLasCapas.setSelected(false); botonTodoasLasCapas.setActionCommand("#all"); // all.setVerticalTextPosition(SwingConstants.BOTTOM); // all.setHorizontalTextPosition(SwingConstants.CENTER); botonTodoasLasCapas.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { layerDialog.setLocationRelativeTo((Component) e.getSource()); layerDialog.setVisible(!layerDialog.isShowing()); } }); layerControls.add(botonTodoasLasCapas); layerControlPanel = new JPanel(); layerControlPanel.setLayout(new BoxLayout(layerControlPanel, BoxLayout.X_AXIS)); Main.main.menu = this.menu; toolbar = new ToolbarPreferences(); toolbar.refreshToolbarControl(); // toolbar.control.updateUI(); // contentPane.add(toolbar.control, BorderLayout.NORTH); contentPane.updateUI(); panel.updateUI(); }