List of usage examples for javax.swing JToolBar add
public JButton add(Action a)
JButton
which dispatches the action. From source file:org.drugis.mtc.gui.GeneratedCodeWindow.java
private JToolBar createToolBar() { JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false);/* w ww . j a v a2 s . co m*/ toolbar.add(createSaveButton()); return toolbar; }
From source file:org.eobjects.datacleaner.panels.DatabaseDriversPanel.java
private void updateComponents() { this.removeAll(); final JToolBar toolBar = WidgetFactory.createToolBar(); toolBar.add(WidgetFactory.createToolBarSeparator()); final JButton addDriverButton = new JButton("Add database driver", imageManager.getImageIcon(IconUtils.ACTION_ADD)); addDriverButton.addActionListener(new ActionListener() { @Override//from www .j av a 2 s . c om public void actionPerformed(ActionEvent e) { final JMenu menu = new JMenu("Automatic download and install"); menu.setIcon(imageManager.getImageIcon("images/actions/download.png")); final List<DatabaseDriverDescriptor> drivers = _databaseDriverCatalog.getDatabaseDrivers(); for (DatabaseDriverDescriptor dd : drivers) { final String[] urls = dd.getDownloadUrls(); if (urls != null && _databaseDriverCatalog.getState(dd) == DatabaseDriverState.NOT_INSTALLED) { final JMenuItem downloadAndInstallMenuItem = WidgetFactory .createMenuItem(dd.getDisplayName(), dd.getIconImagePath()); downloadAndInstallMenuItem.addActionListener(createDownloadActionListener(dd)); menu.add(downloadAndInstallMenuItem); } } if (menu.getMenuComponentCount() == 0) { menu.setEnabled(false); } final JMenuItem localJarFilesMenuItem = WidgetFactory.createMenuItem("Local JAR file(s)...", "images/filetypes/archive.png"); localJarFilesMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { AddDatabaseDriverDialog dialog = new AddDatabaseDriverDialog(_databaseDriverCatalog, DatabaseDriversPanel.this, _windowContext, _userPreferences); dialog.setVisible(true); } }); final JPopupMenu popup = new JPopupMenu(); popup.add(menu); popup.add(localJarFilesMenuItem); popup.show(addDriverButton, 0, addDriverButton.getHeight()); } }); toolBar.add(addDriverButton); final DCTable table = getDatabaseDriverTable(); this.add(toolBar, BorderLayout.NORTH); this.add(table.toPanel(), BorderLayout.CENTER); }
From source file:org.eobjects.datacleaner.windows.AnalysisJobBuilderWindowImpl.java
@Override protected JComponent getWindowContent() { if (_datastore != null) { setDatastore(_datastore);//from ww w . j av a2 s. c o m } setJMenuBar(_windowMenuBar); _sourceTabOuterPanel.add(_datastoreListPanelRef.get()); _sourceTabOuterPanel.add(_sourceColumnsPanel); // add source tab _tabbedPane.addTab("Source", imageManager.getImageIcon("images/model/source.png", TAB_ICON_SIZE), WidgetUtils.scrolleable(_sourceTabOuterPanel)); _tabbedPane.setRightClickActionListener(SOURCE_TAB, new HideTabTextActionListener(_tabbedPane, SOURCE_TAB)); _tabbedPane.setUnclosableTab(SOURCE_TAB); // add metadata tab _tabbedPane.addTab("Metadata", imageManager.getImageIcon("images/model/metadata.png", TAB_ICON_SIZE), _metadataPanel); _tabbedPane.setRightClickActionListener(METADATA_TAB, new HideTabTextActionListener(_tabbedPane, METADATA_TAB)); _tabbedPane.setUnclosableTab(METADATA_TAB); // add separator for fixed vs dynamic tabs _tabbedPane.addSeparator(); final SaveAnalysisJobActionListener saveAnalysisJobActionListener = _saveAnalysisJobActionListenerProvider .get(); _saveButton.addActionListener(saveAnalysisJobActionListener); _saveAsButton.addActionListener(saveAnalysisJobActionListener); _saveAsButton.setActionCommand(SaveAnalysisJobActionListener.ACTION_COMMAND_SAVE_AS); _visualizeButton.setToolTipText("Visualize execution flow"); _visualizeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { VisualizeJobWindow window = new VisualizeJobWindow(_analysisJobBuilder, getWindowContext()); window.setVisible(true); } }); // Transform button _transformButton.addActionListener(_addTransformerActionListenerProvider.get()); // Analyze button _analyzeButton.addActionListener(_addAnalyzerActionListenerProvider.get()); // Run analysis final RunAnalysisActionListener runAnalysisActionListener = _runAnalysisActionProvider.get(); _executeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { applyPropertyValues(); if (_analysisJobBuilder.getAnalyzerJobBuilders().isEmpty()) { // Present choices to user to write file somewhere, // and then run a copy of the job based on that. ExecuteJobWithoutAnalyzersDialog executeJobWithoutAnalyzersPanel = new ExecuteJobWithoutAnalyzersDialog( _injectorBuilder, getWindowContext(), _analysisJobBuilder, _userPreferences); executeJobWithoutAnalyzersPanel.open(); return; } runAnalysisActionListener.actionPerformed(e); } }); final JToolBar toolBar = WidgetFactory.createToolBar(); toolBar.add(_saveButton); toolBar.add(_saveAsButton); toolBar.add(_visualizeButton); toolBar.add(WidgetFactory.createToolBarSeparator()); toolBar.add(_transformButton); toolBar.add(_analyzeButton); toolBar.add(WidgetFactory.createToolBarSeparator()); toolBar.add(_executeButton); final JXStatusBar statusBar = WidgetFactory.createStatusBar(_statusLabel); final LicenceAndEditionStatusLabel statusLabel = new LicenceAndEditionStatusLabel(_glassPane); statusBar.add(statusLabel); final DCPanel toolBarPanel = new DCPanel(WidgetUtils.BG_COLOR_LESS_DARK, WidgetUtils.BG_COLOR_DARK); toolBarPanel.setLayout(new BorderLayout()); toolBarPanel.add(toolBar, BorderLayout.CENTER); final DCPanel panel = new DCPersistentSizedPanel(_userPreferences, getClass().getName(), DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT); panel.setLayout(new BorderLayout()); panel.add(toolBarPanel, BorderLayout.NORTH); panel.add(_leftPanel, BorderLayout.WEST); panel.add(_tabbedPane, BorderLayout.CENTER); panel.add(statusBar, BorderLayout.SOUTH); WidgetUtils.centerOnScreen(this); initializeExistingComponents(); return panel; }
From source file:org.geopublishing.atlasStyler.swing.AtlasStylerGUI.java
/** * This method initializes jToolBar/*w w w .j a v a 2 s . c om*/ * * @return javax.swing.JToolBar */ private JToolBar getJToolBar() { JToolBar jToolBar = new JToolBar(); jToolBar.setFloatable(false); AbstractAction importWiazrdAction = new AbstractAction( AtlasStylerVector.R("MenuBar.FileMenu.ImportWizard")) { @Override public void actionPerformed(ActionEvent e) { ImportWizard.showWizard(AtlasStylerGUI.this, AtlasStylerGUI.this); } }; importWiazrdAction.putValue(Action.LONG_DESCRIPTION, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.CTRL_MASK, true)); jToolBar.add(importWiazrdAction); jToolBar.add(getJTButtonShowXML()); jToolBar.add(getJTButtonExportAsSLD()); return jToolBar; }
From source file:org.graphwalker.GUI.App.java
@SuppressWarnings("serial") private void addButtons(JToolBar toolBar) { loadButton = makeNavigationButton("open", LOAD, "Load a model (graphml file)", "Load", true); toolBar.add(loadButton); reloadButton = makeNavigationButton("reload", RELOAD, "Reload/Restart already loaded Model", "Reload", false);//w w w . ja va 2 s . c o m toolBar.add(reloadButton); firstButton = makeNavigationButton("first", FIRST, "Start at the beginning", "First", false); toolBar.add(firstButton); backButton = makeNavigationButton("back", BACK, "Backs a step", "Back", false); toolBar.add(backButton); runButton = makeNavigationButton("run", RUN, "Starts the execution/Take a step forward in the log", "Run", false); toolBar.add(runButton); pauseButton = makeNavigationButton("pause", PAUSE, "Pauses the execution", "Pause", false); toolBar.add(pauseButton); nextButton = makeNavigationButton("next", NEXT, "Walk a step in the model/Go to the end of log", "Next", false); toolBar.add(nextButton); soapButton = makeNavigationCheckBoxButton("soap", SOAP, "Run MBT in SOAP(Web Services) mode", "Soap"); soapButton.setSelected(Util.readSoapGuiStartupState()); toolBar.add(soapButton); centerOnVertexButton = makeNavigationCheckBoxButton("centerOnVertex", CENTERONVERTEX, "Center the layout on the current vertex", "Center on current vertex"); toolBar.add(centerOnVertexButton); @SuppressWarnings("rawtypes") Class[] combos = getCombos(); final JComboBox jcb = new JComboBox(combos); // use a renderer to shorten the layout name presentation jcb.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String valueString = value.toString(); valueString = valueString.substring(valueString.lastIndexOf('.') + 1); return super.getListCellRendererComponent(list, valueString, index, isSelected, cellHasFocus); } }); jcb.addActionListener(new LayoutChooser(jcb, getVv())); jcb.setSelectedItem(StaticLayout.class); toolBar.add(jcb); }
From source file:org.jab.docsearch.DocSearch.java
private JToolBar createToolBar() { // tool bar/* w ww . jav a2s. c om*/ JToolBar toolBar = new JToolBar(); // file open JButton buttonOpen = new JButton(new ImageIcon(getClass().getResource("/icons/fileopen.png"))); buttonOpen.setToolTipText(I18n.getString("tooltip.open")); buttonOpen.setActionCommand("ac_open"); buttonOpen.addActionListener(this); buttonOpen.setMnemonic(KeyEvent.VK_O); buttonOpen.setEnabled(!env.isWebStart()); // disable in WebStart toolBar.add(buttonOpen); // file save JButton buttonSave = new JButton(new ImageIcon(getClass().getResource("/icons/filesave.png"))); buttonSave.setToolTipText(I18n.getString("tooltip.save")); buttonSave.setActionCommand("ac_save"); buttonSave.addActionListener(this); buttonSave.setMnemonic(KeyEvent.VK_S); buttonSave.setEnabled(!env.isWebStart()); // disable in WebStart toolBar.add(buttonSave); toolBar.addSeparator(); // open browser JButton buttonBrowser = new JButton(new ImageIcon(getClass().getResource("/icons/html.png"))); buttonBrowser.setToolTipText(I18n.getString("tooltip.open_in_browser")); buttonBrowser.setActionCommand("ac_openinbrowser"); buttonBrowser.addActionListener(this); buttonBrowser.setMnemonic(KeyEvent.VK_E); buttonBrowser.setEnabled(!env.isWebStart()); // disable in WebStart toolBar.add(buttonBrowser); toolBar.addSeparator(); // home JButton buttonHome = new JButton(new ImageIcon(getClass().getResource("/icons/home.png"))); buttonHome.setToolTipText(I18n.getString("tooltip.home")); buttonHome.setActionCommand("ac_home"); buttonHome.addActionListener(this); buttonHome.setMnemonic(KeyEvent.VK_H); toolBar.add(buttonHome); // refresh JButton buttonRefresh = new JButton(new ImageIcon(getClass().getResource("/icons/refresh.png"))); buttonRefresh.setToolTipText(I18n.getString("tooltip.refresh")); buttonRefresh.setActionCommand("ac_refresh"); buttonRefresh.addActionListener(this); buttonRefresh.setMnemonic(KeyEvent.VK_L); toolBar.add(buttonRefresh); toolBar.addSeparator(); // result JButton buttonResult = new JButton(new ImageIcon(getClass().getResource("/icons/search_results.png"))); buttonResult.setToolTipText(I18n.getString("tooltip.results")); buttonResult.setActionCommand("ac_result"); buttonResult.addActionListener(this); buttonResult.setMnemonic(KeyEvent.VK_R); toolBar.add(buttonResult); toolBar.addSeparator(); // bookmark JButton buttonBookMark = new JButton(new ImageIcon(getClass().getResource("/icons/bookmark.png"))); buttonBookMark.setToolTipText(I18n.getString("tooltip.add_bookmark")); buttonBookMark.setActionCommand("ac_addbookmark"); buttonBookMark.addActionListener(this); buttonBookMark.setMnemonic(KeyEvent.VK_M); toolBar.add(buttonBookMark); toolBar.addSeparator(); // print JButton buttonPrint = new JButton(new ImageIcon(getClass().getResource("/icons/fileprint.png"))); buttonPrint.setToolTipText(I18n.getString("tooltip.print")); buttonPrint.setActionCommand("ac_print"); buttonPrint.addActionListener(this); buttonPrint.setMnemonic(KeyEvent.VK_P); toolBar.add(buttonPrint); toolBar.addSeparator(); // setting JButton buttonSetting = new JButton(new ImageIcon(getClass().getResource("/icons/configure.png"))); buttonSetting.setToolTipText(I18n.getString("tooltip.settings")); buttonSetting.setActionCommand("ac_settings"); buttonSetting.addActionListener(this); buttonSetting.setMnemonic(KeyEvent.VK_HOME); toolBar.add(buttonSetting); toolBar.addSeparator(); // stop buttonStop = new JButton(new ImageIcon(getClass().getResource("/icons/stop.png"))); buttonStop.setToolTipText(I18n.getString("tooltip.stop")); buttonStop.setActionCommand("ac_stop"); buttonStop.addActionListener(this); buttonStop.setMnemonic(KeyEvent.VK_X); toolBar.add(buttonStop); toolBar.addSeparator(); // toolBar.setFloatable(false); // finished return toolBar; }
From source file:org.jajuk.ui.views.CoverView.java
/** * Inits the ui./*w w w .ja v a 2s . c om*/ * * @param includeControls */ @SuppressWarnings({ "unchecked", "rawtypes" }) public void initUI(boolean includeControls) { this.includeControls = includeControls; // Control panel jpControl = new JPanel(); if (includeControls) { jpControl.setBorder(BorderFactory.createEtchedBorder()); } final JToolBar jtb = new JajukJToolbar(); jbPrevious = new JajukButton(IconLoader.getIcon(JajukIcons.PLAYER_PREVIOUS_SMALL)); jbPrevious.addActionListener(this); jbPrevious.setToolTipText(Messages.getString("CoverView.4")); jbNext = new JajukButton(IconLoader.getIcon(JajukIcons.PLAYER_NEXT_SMALL)); jbNext.addActionListener(this); jbNext.setToolTipText(Messages.getString("CoverView.5")); jbDelete = new JajukButton(IconLoader.getIcon(JajukIcons.DELETE)); jbDelete.addActionListener(this); jbDelete.setToolTipText(Messages.getString("CoverView.2")); jbSave = new JajukButton(IconLoader.getIcon(JajukIcons.SAVE)); jbSave.addActionListener(this); jbSave.setToolTipText(Messages.getString("CoverView.6")); jbDefault = new JajukButton(IconLoader.getIcon(JajukIcons.DEFAULT_COVER)); jbDefault.addActionListener(this); jbDefault.setToolTipText(Messages.getString("CoverView.8")); jlSize = new JLabel(""); jlFound = new JLabel(""); jcbAccuracy = new JComboBox(); // Add tooltips on combo items jcbAccuracy.setRenderer(new BasicComboBoxRenderer() { private static final long serialVersionUID = -6943363556191659895L; @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); switch (index) { case 0: setToolTipText(Messages.getString("ParameterView.156")); break; case 1: setToolTipText(Messages.getString("ParameterView.157")); break; case 2: setToolTipText(Messages.getString("ParameterView.158")); break; case 3: setToolTipText(Messages.getString("ParameterView.216")); break; case 4: setToolTipText(Messages.getString("ParameterView.217")); break; case 5: setToolTipText(Messages.getString("ParameterView.218")); break; } setBorder(new EmptyBorder(0, 3, 0, 3)); return this; } }); jcbAccuracy.setToolTipText(Messages.getString("ParameterView.155")); jcbAccuracy.addItem(IconLoader.getIcon(JajukIcons.ACCURACY_LOW)); jcbAccuracy.addItem(IconLoader.getIcon(JajukIcons.ACCURACY_MEDIUM)); jcbAccuracy.addItem(IconLoader.getIcon(JajukIcons.ACCURACY_HIGH)); jcbAccuracy.addItem(IconLoader.getIcon(JajukIcons.ARTIST)); jcbAccuracy.addItem(IconLoader.getIcon(JajukIcons.ALBUM)); jcbAccuracy.addItem(IconLoader.getIcon(JajukIcons.TRACK)); int accuracy = getCurrentAccuracy(); jcbAccuracy.setSelectedIndex(accuracy); jcbAccuracy.addActionListener(this); jtb.add(jbPrevious); jtb.add(jbNext); jtb.addSeparator(); jtb.add(jbDelete); jtb.add(jbSave); jtb.add(jbDefault); if (includeControls) { jpControl.setLayout(new MigLayout("insets 5 2 5 2", "[][grow][grow][]")); jpControl.add(jtb); jpControl.add(jlSize, "center,gapright 5::"); jpControl.add(jlFound, "center,gapright 5::"); jpControl.add(jcbAccuracy, "grow,width 47!,gapright 5"); } // Cover view used in catalog view should not listen events if (fileReference == null) { ObservationManager.register(this); } // global layout MigLayout globalLayout = null; if (includeControls) { globalLayout = new MigLayout("ins 0,gapy 10", "[grow]", "[30!][grow]"); } else { globalLayout = new MigLayout("ins 0,gapy 10", "[grow]", "[grow]"); } setLayout(globalLayout); add(jpControl, "grow,wrap"); //Force initial resizing (required after a perspective reset as the component event is not thrown in this case) componentResized(null); // Attach the listener for initial cover display and further manual actions against the view when resizing. addComponentListener(CoverView.this); }
From source file:org.jcurl.demo.tactics.JCurlShotPlanner.java
private JComponent createToolBar() { final String[] toolbarActionNames = { "cut", "copy", "paste" }; final JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false);/*from www. j av a 2 s . c o m*/ for (final String actionName : toolbarActionNames) { final JButton button = new JButton(); button.setAction(gui.findAction(actionName)); button.setFocusable(false); toolBar.add(button); } return toolBar; }
From source file:org.kuali.test.creator.TestCreator.java
private JPanel createToolBar() { JPanel retval = new JPanel(new BorderLayout(2, 2)); JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false);/* ww w .ja v a 2s .c o m*/ toolbar.setMargin(new Insets(1, 5, 2, 0)); ToolbarButton b; toolbar.add(b = new ToolbarButton(Constants.PLATFORM_TOOLBAR_ICON, "add platform")); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleAddPlatform(e); } }); toolbar.add(b = new ToolbarButton(Constants.DATABASE_TOOLBAR_ICON, "add database connection")); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleAddDatabaseConnection(e); } }); toolbar.add(b = new ToolbarButton(Constants.JMX_CONNECTION_TOOLBAR_ICON, "add JMX connection")); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleAddJmxConnection(e); } }); toolbar.add(b = new ToolbarButton(Constants.WEB_SERVICE_TOOLBAR_ICON, "add web service")); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleAddWebService(e); } }); toolbar.add(b = new ToolbarButton(Constants.SCHEDULE_TEST_TOOLBAR_ICON, "schedule test")); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleScheduleTests(e); } }); toolbar.addSeparator(); toolbar.add(saveConfigurationButton = new ToolbarButton(Constants.SAVE_CONFIGURATION_ICON, "save repository configuration") { @Override public void setEnabled(boolean enabled) { if (enabled) { getConfiguration().setModified(true); } super.setEnabled(enabled); } }); saveConfigurationButton.setEnabled(false); saveConfigurationButton.setMargin(new Insets(1, 1, 1, 1)); saveConfigurationButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleSaveConfiguration(); } }); toolbar.add(createTestButton = new ToolbarButton(Constants.TEST_ICON, "create new test")); createTestButton.setMargin(new Insets(1, 1, 1, 1)); createTestButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleCreateTest(null); } }); toolbar.addSeparator(); toolbar.add( exitApplication = new ToolbarButton(Constants.EXIT_APPLICATION_TOOLBAR_ICON, "exit application")); exitApplication.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(TestCreator.this, "Exit Test Application?", "Exit", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { startSpinner("Shutting down application..."); handleExit(0); } } }); toolbar.addSeparator(); toolbar.add(spinner = new Spinner()); toolbar.add(spinner2 = new Spinner(true)); retval.add(new JSeparator(), BorderLayout.NORTH); retval.add(toolbar, BorderLayout.CENTER); this.enableCreateTestActions(havePlatforms()); return retval; }
From source file:org.languagetool.gui.Main.java
private void createGUI() { loadRecentFiles();//w w w .j av a2 s . c o m frame = new JFrame("LanguageTool " + JLanguageTool.VERSION); setLookAndFeel(); openAction = new OpenAction(); saveAction = new SaveAction(); saveAsAction = new SaveAsAction(); checkAction = new CheckAction(); autoCheckAction = new AutoCheckAction(true); showResultAction = new ShowResultAction(true); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new CloseListener()); URL iconUrl = JLanguageTool.getDataBroker().getFromResourceDirAsUrl(TRAY_ICON); frame.setIconImage(new ImageIcon(iconUrl).getImage()); textArea = new JTextArea(); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.addKeyListener(new ControlReturnTextCheckingListener()); textLineNumber = new TextLineNumber(textArea, 2); numberedTextAreaPane = new JScrollPane(textArea); numberedTextAreaPane.setRowHeaderView(textLineNumber); resultArea = new JTextPane(); undoRedo = new UndoRedoSupport(this.textArea, messages); frame.setJMenuBar(createMenuBar()); GridBagConstraints buttonCons = new GridBagConstraints(); JPanel insidePanel = new JPanel(); insidePanel.setOpaque(false); insidePanel.setLayout(new GridBagLayout()); buttonCons.gridx = 0; buttonCons.gridy = 0; buttonCons.anchor = GridBagConstraints.LINE_START; insidePanel.add(new JLabel(messages.getString("textLanguage") + " "), buttonCons); //create a ComboBox with flags, do not include hidden languages languageBox = LanguageComboBox.create(messages, EXTERNAL_LANGUAGE_SUFFIX, true, false); buttonCons.gridx = 1; buttonCons.gridy = 0; buttonCons.anchor = GridBagConstraints.LINE_START; insidePanel.add(languageBox, buttonCons); JCheckBox autoDetectBox = new JCheckBox(messages.getString("atd")); buttonCons.gridx = 2; buttonCons.gridy = 0; buttonCons.gridwidth = GridBagConstraints.REMAINDER; buttonCons.anchor = GridBagConstraints.LINE_START; insidePanel.add(autoDetectBox, buttonCons); buttonCons.gridx = 0; buttonCons.gridy = 1; buttonCons.gridwidth = GridBagConstraints.REMAINDER; buttonCons.fill = GridBagConstraints.HORIZONTAL; buttonCons.anchor = GridBagConstraints.LINE_END; buttonCons.weightx = 1.0; insidePanel.add(statusLabel, buttonCons); Container contentPane = frame.getContentPane(); GridBagLayout gridLayout = new GridBagLayout(); contentPane.setLayout(gridLayout); GridBagConstraints cons = new GridBagConstraints(); cons.gridx = 0; cons.gridy = 1; cons.fill = GridBagConstraints.HORIZONTAL; cons.anchor = GridBagConstraints.FIRST_LINE_START; JToolBar toolbar = new JToolBar("Toolbar", JToolBar.HORIZONTAL); toolbar.setFloatable(false); contentPane.add(toolbar, cons); JButton openButton = new JButton(openAction); openButton.setHideActionText(true); openButton.setFocusable(false); toolbar.add(openButton); JButton saveButton = new JButton(saveAction); saveButton.setHideActionText(true); saveButton.setFocusable(false); toolbar.add(saveButton); JButton saveAsButton = new JButton(saveAsAction); saveAsButton.setHideActionText(true); saveAsButton.setFocusable(false); toolbar.add(saveAsButton); JButton spellButton = new JButton(this.checkAction); spellButton.setHideActionText(true); spellButton.setFocusable(false); toolbar.add(spellButton); JToggleButton autoSpellButton = new JToggleButton(autoCheckAction); autoSpellButton.setHideActionText(true); autoSpellButton.setFocusable(false); toolbar.add(autoSpellButton); JButton clearTextButton = new JButton(new ClearTextAction()); clearTextButton.setHideActionText(true); clearTextButton.setFocusable(false); toolbar.add(clearTextButton); cons.insets = new Insets(5, 5, 5, 5); cons.fill = GridBagConstraints.BOTH; cons.weightx = 10.0f; cons.weighty = 10.0f; cons.gridx = 0; cons.gridy = 2; cons.weighty = 5.0f; splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, numberedTextAreaPane, new JScrollPane(resultArea)); mainPanel.setLayout(new GridLayout(0, 1)); contentPane.add(mainPanel, cons); mainPanel.add(splitPane); cons.fill = GridBagConstraints.HORIZONTAL; cons.gridx = 0; cons.gridy = 3; cons.weightx = 1.0f; cons.weighty = 0.0f; cons.insets = new Insets(4, 12, 4, 12); contentPane.add(insidePanel, cons); ltSupport = new LanguageToolSupport(this.frame, this.textArea, this.undoRedo); ResultAreaHelper.install(messages, ltSupport, resultArea); languageBox.selectLanguage(ltSupport.getLanguage()); languageBox.setEnabled(!ltSupport.getConfig().getAutoDetect()); autoDetectBox.setSelected(ltSupport.getConfig().getAutoDetect()); taggerShowsDisambigLog = ltSupport.getConfig().getTaggerShowsDisambigLog(); languageBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { // we cannot re-use the existing LT object anymore frame.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault())); Language lang = languageBox.getSelectedLanguage(); ComponentOrientation componentOrientation = ComponentOrientation .getOrientation(lang.getLocale()); textArea.applyComponentOrientation(componentOrientation); resultArea.applyComponentOrientation(componentOrientation); ltSupport.setLanguage(lang); } } }); autoDetectBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { boolean selected = e.getStateChange() == ItemEvent.SELECTED; languageBox.setEnabled(!selected); ltSupport.getConfig().setAutoDetect(selected); if (selected) { Language detected = ltSupport.autoDetectLanguage(textArea.getText()); languageBox.selectLanguage(detected); } } }); ltSupport.addLanguageToolListener(new LanguageToolListener() { @Override public void languageToolEventOccurred(LanguageToolEvent event) { if (event.getType() == LanguageToolEvent.Type.CHECKING_STARTED) { String msg = org.languagetool.tools.Tools.i18n(messages, "checkStart"); statusLabel.setText(msg); if (event.getCaller() == getFrame()) { setWaitCursor(); checkAction.setEnabled(false); } } else if (event.getType() == LanguageToolEvent.Type.CHECKING_FINISHED) { if (event.getCaller() == getFrame()) { checkAction.setEnabled(true); unsetWaitCursor(); } String msg = org.languagetool.tools.Tools.i18n(messages, "checkDone", event.getSource().getMatches().size(), event.getElapsedTime()); statusLabel.setText(msg); } else if (event.getType() == LanguageToolEvent.Type.LANGUAGE_CHANGED) { languageBox.selectLanguage(ltSupport.getLanguage()); } else if (event.getType() == LanguageToolEvent.Type.RULE_ENABLED) { //this will trigger a check and the result will be updated by //the CHECKING_FINISHED event } else if (event.getType() == LanguageToolEvent.Type.RULE_DISABLED) { String msg = org.languagetool.tools.Tools.i18n(messages, "checkDoneNoTime", event.getSource().getMatches().size()); statusLabel.setText(msg); } } }); frame.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault())); Language lang = ltSupport.getLanguage(); ComponentOrientation componentOrientation = ComponentOrientation.getOrientation(lang.getLocale()); textArea.applyComponentOrientation(componentOrientation); resultArea.applyComponentOrientation(componentOrientation); ResourceBundle textLanguageMessageBundle = JLanguageTool.getMessageBundle(ltSupport.getLanguage()); textArea.setText(textLanguageMessageBundle.getString("guiDemoText")); Configuration config = ltSupport.getConfig(); if (config.getFontName() != null || config.getFontStyle() != Configuration.FONT_STYLE_INVALID || config.getFontSize() != Configuration.FONT_SIZE_INVALID) { String fontName = config.getFontName(); if (fontName == null) { fontName = textArea.getFont().getFamily(); } int fontSize = config.getFontSize(); if (fontSize == Configuration.FONT_SIZE_INVALID) { fontSize = textArea.getFont().getSize(); } Font font = new Font(fontName, config.getFontStyle(), fontSize); textArea.setFont(font); } frame.pack(); frame.setSize(WINDOW_WIDTH, WINDOW_HEIGHT); frame.setLocationByPlatform(true); splitPane.setDividerLocation(200); MainWindowStateBean state = localStorage.loadProperty("gui.state", MainWindowStateBean.class); if (state != null) { if (state.getBounds() != null) { frame.setBounds(state.getBounds()); ResizeComponentListener.setBoundsProperty(frame, state.getBounds()); } if (state.getDividerLocation() != null) { splitPane.setDividerLocation(state.getDividerLocation()); } if (state.getState() != null) { frame.setExtendedState(state.getState()); } } ResizeComponentListener.attachToWindow(frame); maybeStartServer(); }