List of usage examples for javax.swing JEditorPane JEditorPane
public JEditorPane(String type, String text)
JEditorPane
that has been initialized to the given text. From source file:org.formic.wizard.step.gui.TemplateStep.java
/** * {@inheritDoc}/*from w ww. j a v a2 s . c om*/ * @see org.formic.wizard.step.GuiStep#init() */ public Component init() { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); if (html != null) { JEditorPane editor = new JEditorPane("text/html", StringUtils.EMPTY); editor.setEditable(false); editor.setOpaque(false); editor.addHyperlinkListener(new HyperlinkListener()); editor.setBorder(null); editor.setFocusable(false); content = editor; } else { JTextArea area = new JTextArea(); area.setEditable(false); content = area; } JScrollPane scroll = new JScrollPane(content); scroll.setBorder(null); panel.add(scroll, BorderLayout.CENTER); return panel; }
From source file:org.geworkbench.components.lincs.LincsInterface.java
private void viewLicense_actionPerformed(String FileName) { getLicenseFromFile(FileName);/*from w w w.ja v a 2s . c o m*/ JDialog licenseDialog = new JDialog(); final JEditorPane jEditorPane = new JEditorPane("text/html", ""); jEditorPane.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE); jEditorPane.setText(licenseContent); if (jEditorPane.getCaretPosition() > 1) { jEditorPane.setCaretPosition(1); } JScrollPane scrollPane = new JScrollPane(jEditorPane); licenseDialog.setTitle("Lincs Interface License"); licenseDialog.setContentPane(scrollPane); licenseDialog.setSize(400, 300); licenseDialog.setLocationRelativeTo(this); licenseDialog.setVisible(true); }
From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow.java
/** * Display a dialog box with a components license in it. * /*from w ww . j a v a 2s . c o m*/ * @param ActionEvent * @return void */ private void viewLicense_actionPerformed(ActionEvent e) { int[] selectedRow = table.getSelectedRows(); String license = "Select a component in order to view its license."; String componentName = null; if (selectedRow != null && selectedRow.length > 0 && selectedRow[0] >= 0) { int modelRow = table.convertRowIndexToModel(selectedRow[0]); license = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel.LICENSE_INDEX); componentName = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel.NAME_INDEX); } JDialog licenseDialog = new JDialog(); final JEditorPane jEditorPane = new JEditorPane("text/html", ""); jEditorPane.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE); jEditorPane.setText(license); if (jEditorPane.getCaretPosition() > 1) { jEditorPane.setCaretPosition(1); } JScrollPane scrollPane = new JScrollPane(jEditorPane); licenseDialog.setTitle(componentName + " License"); licenseDialog.setContentPane(scrollPane); licenseDialog.setSize(400, 300); licenseDialog.setLocationRelativeTo(frame); licenseDialog.setVisible(true); }
From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow2.java
/** * Display a dialog box with a components license in it. * //from ww w. ja v a 2 s. co m * @param ActionEvent * @return void */ private void viewLicense_actionPerformed(ActionEvent e) { int[] selectedRow = table.getSelectedRows(); String license = "Select a component in order to view its license."; String componentName = null; if (selectedRow != null && selectedRow.length > 0 && selectedRow[0] >= 0) { int modelRow = table.convertRowIndexToModel(selectedRow[0]); license = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel2.LICENSE_INDEX); componentName = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel2.NAME_INDEX); } JDialog licenseDialog = new JDialog(); final JEditorPane jEditorPane = new JEditorPane("text/html", ""); jEditorPane.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE); jEditorPane.setText(license); if (jEditorPane.getCaretPosition() > 1) { jEditorPane.setCaretPosition(1); } JScrollPane scrollPane = new JScrollPane(jEditorPane); licenseDialog.setTitle(componentName + " License"); licenseDialog.setContentPane(scrollPane); licenseDialog.setSize(400, 300); licenseDialog.setLocationRelativeTo(frame); licenseDialog.setVisible(true); }
From source file:org.jab.docsearch.DocSearch.java
/** * Constructor//from ww w . j av a2 s .c o m */ public DocSearch() { super(I18n.getString("ds.windowtitle")); // get logger logger = Logger.getLogger(getClass().getName()); // File testCDFi = new File(cdRomDefaultHome); Properties sys = new Properties(System.getProperties()); if (testCDFi.exists()) { sys.setProperty("disableLuceneLocks", "true"); logger.info("DocSearch() Disabling Lucene Locks for CDROM indexes"); } else { sys.setProperty("disableLuceneLocks", "false"); } // checkCDROMDir(); defaultHndlr = getBrowserFile(); loadSettings(); // pPanel = new ProgressPanel("", 100L); pPanel.init(); phrase = new JRadioButton(I18n.getString("label.phrase")); searchField = new JComboBox(); searchIn = new JComboBox(searchOptsLabels); JLabel searchTypeLabel = new JLabel(I18n.getString("label.search_type")); JLabel searchInLabel = new JLabel(I18n.getString("label.search_in")); keywords = new JRadioButton(I18n.getString("label.keyword")); // searchLabel = new JLabel(I18n.getString("label.search_for")); searchButton = new JButton(I18n.getString("button.search")); searchButton.setActionCommand("ac_search"); searchButton.setMnemonic(KeyEvent.VK_A); // TODO alt text to resource htmlTag = "<img src=\"" + fEnv.getIconURL(FileType.HTML.getIcon()) + "\" border=\"0\" alt=\"Web Page Document\">"; wordTag = "<img src=\"" + fEnv.getIconURL(FileType.MS_WORD.getIcon()) + "\" border=\"0\" alt=\"MS Word Document\">"; excelTag = "<img src=\"" + fEnv.getIconURL(FileType.MS_EXCEL.getIcon()) + "\" border=\"0\" alt=\"MS Excel Document\">"; pdfTag = "<img src=\"" + fEnv.getIconURL(FileType.PDF.getIcon()) + "\" border=\"0\" alt=\"PDF Document\">"; textTag = "<img src=\"" + fEnv.getIconURL(FileType.TEXT.getIcon()) + "\" border=\"0\" alt=\"Text Document\">"; rtfTag = "<img src=\"" + fEnv.getIconURL(FileType.RTF.getIcon()) + "\" border=\"0\" alt=\"RTF Document\">"; ooImpressTag = "<img src=\"" + fEnv.getIconURL(FileType.OO_IMPRESS.getIcon()) + "\" border=\"0\" alt=\"OpenOffice Impress Document\">"; ooWriterTag = "<img src=\"" + fEnv.getIconURL(FileType.OO_WRITER.getIcon()) + "\" border=\"0\" alt=\"OpenOffice Writer Document\">"; ooCalcTag = "<img src=\"" + fEnv.getIconURL(FileType.OO_CALC.getIcon()) + "\" border=\"0\" alt=\"OpenOffice Calc Document\">"; ooDrawTag = "<img src=\"" + fEnv.getIconURL(FileType.OO_DRAW.getIcon()) + "\" border=\"0\" alt=\"OpenOffice Draw Document\">"; openDocumentTextTag = "<img src=\"" + fEnv.getIconURL(FileType.OPENDOCUMENT_TEXT.getIcon()) + "\" border=\"0\" alt=\"OpenDocument Text Document\">"; // idx = new Index(this); colors = new String[2]; colors[0] = "ffeffa"; colors[1] = "fdffda"; if (env.isWebStart()) { startPageString = getClass().getResource("/" + FileEnvironment.FILENAME_START_PAGE_WS).toString(); helpPageString = getClass().getResource("/" + FileEnvironment.FILENAME_HELP_PAGE_WS).toString(); if (startPageString != null) { logger.debug("DocSearch() Start Page is: " + startPageString); hasStartPage = true; } else { logger.error("DocSearch() Start Page NOT FOUND where expected: " + startPageString); } } else { startPageString = FileUtils.addFolder(fEnv.getStartDirectory(), FileEnvironment.FILENAME_START_PAGE); helpPageString = FileUtils.addFolder(fEnv.getStartDirectory(), FileEnvironment.FILENAME_HELP_PAGE); File startPageFile = new File(startPageString); if (startPageFile.exists()) { logger.debug("DocSearch() Start Page is: " + startPageString); hasStartPage = true; } else { logger.error("DocSearch() Start Page NOT FOUND where expected: " + startPageString); } } defaultSaveFolder = FileUtils.addFolder(fEnv.getWorkingDirectory(), "saved_searches"); searchField.setEditable(true); searchField.addItem(""); bg = new ButtonGroup(); bg.add(phrase); bg.add(keywords); keywords.setSelected(true); keywords.setToolTipText(I18n.getString("tooltip.keyword")); phrase.setToolTipText(I18n.getString("tooltip.phrase")); int iconInt = 2; searchField.setPreferredSize(new Dimension(370, 22)); // application icon Image iconImage = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/ds.gif")); this.setIconImage(iconImage); // menu bar JMenuBar menuBar = createMenuBar(); // add menu to frame setJMenuBar(menuBar); // tool bar JToolBar toolbar = createToolBar(); editorPane = new JEditorPane("text/html", lastSearch); editorPane.setEditable(false); editorPane.addHyperlinkListener(new Hyperactive()); if (hasStartPage) { try { editorPane.setContentType("text/html"); if (setPage("home")) { logger.info("DocSearch() loaded start page: " + startPageString); } } catch (Exception e) { editorPane.setText(lastSearch); } } else { logger.warn("DocSearch() no start page loaded"); } scrollPane = new JScrollPane(editorPane); scrollPane.setPreferredSize(new Dimension(1024, 720)); scrollPane.setMinimumSize(new Dimension(900, 670)); scrollPane.setMaximumSize(new Dimension(1980, 1980)); // create panels // add printing stuff vista = new JComponentVista(editorPane, new PageFormat()); JPanel topPanel = new JPanel(); topPanel.add(searchLabel); topPanel.add(searchField); topPanel.add(searchButton); JPanel bottomPanel = new JPanel(); bottomPanel.add(searchTypeLabel); bottomPanel.add(keywords); bottomPanel.add(phrase); bottomPanel.add(searchInLabel); bottomPanel.add(searchIn); // GUI items for advanced searching useDate = new JCheckBox(I18n.getString("label.use_date_property")); fromField = new JTextField(11); JLabel fromLabel = new JLabel(I18n.getString("label.from")); JLabel toLabel = new JLabel(I18n.getString("label.to")); toField = new JTextField(11); cbl = new CheckBoxListener(); authorPanel = new JPanel(); useAuthor = new JCheckBox(I18n.getString("label.use_auth_property")); authorField = new JTextField(31); JLabel authorLabel = new JLabel(I18n.getString("label.author")); authorPanel.add(useAuthor); authorPanel.add(authorLabel); authorPanel.add(authorField); // combine stuff JPanel datePanel = new JPanel(); datePanel.add(useDate); datePanel.add(fromLabel); datePanel.add(fromField); datePanel.add(toLabel); datePanel.add(toField); JPanel metaPanel = new JPanel(); metaPanel.setLayout(new BorderLayout()); metaPanel.setBorder(new TitledBorder(I18n.getString("label.date_and_author"))); metaPanel.add(datePanel, BorderLayout.NORTH); metaPanel.add(authorPanel, BorderLayout.SOUTH); useDate.addActionListener(cbl); useAuthor.addActionListener(cbl); fromField.setText(DateTimeUtils.getLastYear()); toField.setText(DateTimeUtils.getToday()); authorField.setText(System.getProperty("user.name")); JPanel[] panels = new JPanel[numPanels]; for (int i = 0; i < numPanels; i++) { panels[i] = new JPanel(); } // add giu to panels panels[0].setLayout(new BorderLayout()); panels[0].add(topPanel, BorderLayout.NORTH); panels[0].add(bottomPanel, BorderLayout.SOUTH); panels[0].setBorder(new TitledBorder(I18n.getString("label.search_critera"))); searchButton.addActionListener(this); JPanel fileTypePanel = new JPanel(); useType = new JCheckBox(I18n.getString("label.use_filetype_property")); useType.addActionListener(cbl); fileType = new JComboBox(fileTypesToFindLabel); JLabel fileTypeLabel = new JLabel(I18n.getString("label.find_only_these_filetypes")); fileTypePanel.add(useType); fileTypePanel.add(fileTypeLabel); fileTypePanel.add(fileType); JPanel sizePanel = new JPanel(); useSize = new JCheckBox(I18n.getString("label.use_filesize_property")); useSize.addActionListener(cbl); // TODO l18n kbytes JLabel sizeFromLabel = new JLabel(I18n.getString("label.from") + " KByte"); JLabel sizeToLabel = new JLabel(I18n.getString("label.to") + " KByte"); sizeFromField = new JTextField(10); sizeFromField.setText("0"); sizeToField = new JTextField(10); sizeToField.setText("100"); sizePanel.add(useSize); sizePanel.add(sizeFromLabel); sizePanel.add(sizeFromField); sizePanel.add(sizeToLabel); sizePanel.add(sizeToField); JPanel sizeAndTypePanel = new JPanel(); sizeAndTypePanel.setLayout(new BorderLayout()); sizeAndTypePanel.setBorder(new TitledBorder(I18n.getString("label.filetype_and_size"))); sizeAndTypePanel.add(fileTypePanel, BorderLayout.NORTH); sizeAndTypePanel.add(sizePanel, BorderLayout.SOUTH); // set up the tabbed pane JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab(I18n.getString("label.general"), null, panels[0], I18n.getString("tooltip.general_search_criteria")); tabbedPane.addTab(I18n.getString("label.date_and_author"), null, metaPanel, I18n.getString("tooltip.date_auth_options")); tabbedPane.addTab(I18n.getString("label.filetype_and_size"), null, sizeAndTypePanel, I18n.getString("tooltip.filetype_and_size_options")); // gridbag getContentPane().setLayout(new GridLayout(1, numPanels + iconInt + 1)); GridBagLayout gridbaglayout = new GridBagLayout(); GridBagConstraints gridbagconstraints = new GridBagConstraints(); getContentPane().setLayout(gridbaglayout); gridbagconstraints.fill = GridBagConstraints.HORIZONTAL; gridbagconstraints.insets = new Insets(1, 1, 1, 1); gridbagconstraints.gridx = 0; gridbagconstraints.gridy = 0; gridbagconstraints.gridwidth = 1; gridbagconstraints.gridheight = 1; gridbagconstraints.weightx = 1.0D; gridbagconstraints.weighty = 0.0D; gridbaglayout.setConstraints(toolbar, gridbagconstraints); getContentPane().add(toolbar); int start = 1; for (int i = 0; i < numPanels; i++) { if (i == 0) { gridbagconstraints.fill = GridBagConstraints.HORIZONTAL; gridbagconstraints.insets = new Insets(1, 1, 1, 1); gridbagconstraints.gridx = 0; gridbagconstraints.gridy = i + start; gridbagconstraints.gridwidth = 1; gridbagconstraints.gridheight = 1; gridbagconstraints.weightx = 1.0D; gridbagconstraints.weighty = 0.0D; gridbaglayout.setConstraints(tabbedPane, gridbagconstraints); getContentPane().add(tabbedPane); } else { gridbagconstraints.fill = GridBagConstraints.HORIZONTAL; gridbagconstraints.insets = new Insets(1, 1, 1, 1); gridbagconstraints.gridx = 0; gridbagconstraints.gridy = i + start; gridbagconstraints.gridwidth = 1; gridbagconstraints.gridheight = 1; gridbagconstraints.weightx = 1.0D; gridbagconstraints.weighty = 0.0D; gridbaglayout.setConstraints(panels[i], gridbagconstraints); getContentPane().add(panels[i]); } } // now add the results area gridbagconstraints.fill = GridBagConstraints.HORIZONTAL; gridbagconstraints.insets = new Insets(1, 1, 1, 1); gridbagconstraints.gridx = 0; gridbagconstraints.gridy = iconInt; gridbagconstraints.gridwidth = 1; gridbagconstraints.gridheight = 1; gridbagconstraints.weightx = 1.0D; gridbagconstraints.weighty = 1.0D; gridbaglayout.setConstraints(scrollPane, gridbagconstraints); getContentPane().add(scrollPane); JPanel statusP = new JPanel(); statusP.setLayout(new BorderLayout()); statusP.add(dirLabel, BorderLayout.WEST); statusP.add(pPanel, BorderLayout.EAST); // now add the status label gridbagconstraints.fill = GridBagConstraints.HORIZONTAL; gridbagconstraints.insets = new Insets(1, 1, 1, 1); gridbagconstraints.gridx = 0; gridbagconstraints.gridy = numPanels + iconInt; gridbagconstraints.gridwidth = 1; gridbagconstraints.gridheight = 1; gridbagconstraints.weightx = 1.0D; gridbagconstraints.weighty = 0.0D; gridbaglayout.setConstraints(statusP, gridbagconstraints); getContentPane().add(statusP); // File testArchDir = new File(fEnv.getArchiveDirectory()); if (!testArchDir.exists()) { boolean madeDir = testArchDir.mkdir(); if (!madeDir) { logger.warn("DocSearch() Error creating directory: " + fEnv.getArchiveDirectory()); } else { logger.info("DocSearch() Directory created: " + fEnv.getArchiveDirectory()); } } loadIndexes(); // DocTypeHandler String handlersFiName; if (!isCDSearchTool) { handlersFiName = FileUtils.addFolder(fEnv.getWorkingDirectory(), DocTypeHandlerUtils.HANDLER_FILE); } else { handlersFiName = FileUtils.addFolder(cdRomDefaultHome, DocTypeHandlerUtils.HANDLER_FILE); } DocTypeHandlerUtils dthUtils = new DocTypeHandlerUtils(); if (!FileUtils.fileExists(handlersFiName)) { logger.warn("DocSearch() Handlers file not found at: " + handlersFiName); handlerList = dthUtils.getInitialHandler(env); } else { handlerList = dthUtils.loadHandler(handlersFiName); } }
From source file:org.jajuk.ui.views.SuggestionView.java
/** * Gets the nothing found panel.//w w w.j a va 2 s. com * * @return a panel with text explaining why no item has been found */ JPanel getNothingFoundPanel() { JPanel out = new JPanel(new MigLayout("ins 5", "grow")); JEditorPane jteNothing = new JEditorPane("text/html", Messages.getString("SuggestionView.7")); jteNothing.setBorder(null); jteNothing.setEditable(false); jteNothing.setOpaque(false); jteNothing.setToolTipText(Messages.getString("SuggestionView.7")); out.add(jteNothing, "center,grow"); return out; }
From source file:org.opendatakit.briefcase.ui.ScrollingStatusListDialog.java
private ScrollingStatusListDialog(Frame frame, String title, IFormDefinition form, String statusHtml) { super(frame, title + form.getFormName(), true); this.form = form; AnnotationProcessor.process(this); // Create and initialize the buttons. JButton cancelButton = new JButton("Close"); cancelButton.addActionListener(this); getRootPane().setDefaultButton(cancelButton); editorArea = new JEditorPane("text/plain", statusHtml); editorArea.setEditable(false);//from ww w .j a v a 2s .c o m //Put the editor pane in a scroll pane. JScrollPane editorScrollPane = new JScrollPane(editorArea); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(400, 300)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); // Create a container so that we can add a title around // the scroll pane. Can't add a title directly to the // scroll pane because its background would be white. // Lay out the label and scroll pane from top to bottom. JPanel listPane = new JPanel(); listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS)); listPane.add(Box.createRigidArea(new Dimension(0, 5))); listPane.add(editorScrollPane); listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // Lay out the buttons from left to right. JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(cancelButton); // Put everything together, using the content pane's BorderLayout. Container contentPane = getContentPane(); contentPane.add(listPane, BorderLayout.CENTER); contentPane.add(buttonPane, BorderLayout.PAGE_END); // Initialize values. pack(); setLocationRelativeTo(null); }
From source file:util.ui.UiUtilities.java
/** * Creates a Html EditorPane that holds a HTML-Help Text. * * Add a Listener if you want to have clickable Links * * @param html/*w w w. j a va2s . c om*/ * HTML-Text to display * @param listener * Link-Listener for this HelpText * @param background The color for the background. * @return EditorPane that holds a Help Text * @since 2.7.2 */ public static JEditorPane createHtmlHelpTextArea(String html, HyperlinkListener listener, Color background) { // Quick "hack". Remove HTML-Code and replace it with Code that includes the // correct Font if (html.indexOf("<html>") >= 0) { html = StringUtils.substringBetween(html, "<html>", "</html>"); } JLabel label = new JLabel(); Font font = label.getFont(); html = "<html><div style=\"color:" + UiUtilities.getHTMLColorCode(label.getForeground()) + ";font-family:" + font.getName() + "; font-size:" + font.getSize() + ";background-color:rgb(" + background.getRed() + "," + background.getGreen() + "," + background.getBlue() + ");\">" + html + "</div></html>"; final JEditorPane pane = new JEditorPane("text/html", html); pane.setBorder(BorderFactory.createEmptyBorder()); pane.setEditable(false); pane.setFont(font); pane.setOpaque(false); pane.setFocusable(false); if (listener != null) { pane.addHyperlinkListener(listener); } return pane; }
From source file:VASSAL.launch.ModuleManagerWindow.java
public ModuleManagerWindow() { setTitle("VASSAL"); setLayout(new BoxLayout(getContentPane(), BoxLayout.X_AXIS)); ApplicationIcons.setFor(this); final AbstractAction shutDownAction = new AbstractAction() { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { if (!AbstractLaunchAction.shutDown()) return; final Prefs gl = Prefs.getGlobalPrefs(); try { gl.write();//from ww w . jav a 2 s. co m gl.close(); } catch (IOException ex) { WriteErrorDialog.error(ex, gl.getFile()); } finally { IOUtils.closeQuietly(gl); } logger.info("Exiting"); System.exit(0); } }; shutDownAction.putValue(Action.NAME, Resources.getString(Resources.QUIT)); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { shutDownAction.actionPerformed(null); } }); // setup menubar and actions final MenuManager mm = MenuManager.getInstance(); final MenuBarProxy mb = mm.getMenuBarProxyFor(this); // file menu final MenuProxy fileMenu = new MenuProxy(Resources.getString("General.file")); fileMenu.setMnemonic(Resources.getString("General.file.shortcut").charAt(0)); fileMenu.add(mm.addKey("Main.play_module")); fileMenu.add(mm.addKey("Main.edit_module")); fileMenu.add(mm.addKey("Main.new_module")); fileMenu.add(mm.addKey("Main.import_module")); fileMenu.addSeparator(); if (!SystemUtils.IS_OS_MAC_OSX) { fileMenu.add(mm.addKey("Prefs.edit_preferences")); fileMenu.addSeparator(); fileMenu.add(mm.addKey("General.quit")); } // tools menu final MenuProxy toolsMenu = new MenuProxy(Resources.getString("General.tools")); // Initialize Global Preferences Prefs.getGlobalPrefs().getEditor().initDialog(this); Prefs.initSharedGlobalPrefs(); final BooleanConfigurer serverStatusConfig = new BooleanConfigurer(SHOW_STATUS_KEY, null, Boolean.FALSE); Prefs.getGlobalPrefs().addOption(null, serverStatusConfig); dividerLocationConfig = new IntConfigurer(DIVIDER_LOCATION_KEY, null, -10); Prefs.getGlobalPrefs().addOption(null, dividerLocationConfig); toolsMenu.add(new CheckBoxMenuItemProxy(new AbstractAction(Resources.getString("Chat.server_status")) { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { serverStatusView.toggleVisibility(); serverStatusConfig.setValue(serverStatusConfig.booleanValue() ? Boolean.FALSE : Boolean.TRUE); if (serverStatusView.isVisible()) { setDividerLocation(getPreferredDividerLocation()); } } }, serverStatusConfig.booleanValue())); // help menu final MenuProxy helpMenu = new MenuProxy(Resources.getString("General.help")); helpMenu.setMnemonic(Resources.getString("General.help.shortcut").charAt(0)); helpMenu.add(mm.addKey("General.help")); helpMenu.add(mm.addKey("Main.tour")); helpMenu.addSeparator(); helpMenu.add(mm.addKey("UpdateCheckAction.update_check")); helpMenu.add(mm.addKey("Help.error_log")); if (!SystemUtils.IS_OS_MAC_OSX) { helpMenu.addSeparator(); helpMenu.add(mm.addKey("AboutScreen.about_vassal")); } mb.add(fileMenu); mb.add(toolsMenu); mb.add(helpMenu); // add actions mm.addAction("Main.play_module", new Player.PromptLaunchAction(this)); mm.addAction("Main.edit_module", new Editor.PromptLaunchAction(this)); mm.addAction("Main.new_module", new Editor.NewModuleLaunchAction(this)); mm.addAction("Main.import_module", new Editor.PromptImportLaunchAction(this)); mm.addAction("Prefs.edit_preferences", Prefs.getGlobalPrefs().getEditor().getEditAction()); mm.addAction("General.quit", shutDownAction); URL url = null; try { url = new File(Documentation.getDocumentationBaseDir(), "README.html").toURI().toURL(); } catch (MalformedURLException e) { ErrorDialog.bug(e); } mm.addAction("General.help", new ShowHelpAction(url, null)); mm.addAction("Main.tour", new LaunchTourAction(this)); mm.addAction("AboutScreen.about_vassal", new AboutVASSALAction(this)); mm.addAction("UpdateCheckAction.update_check", new UpdateCheckAction(this)); mm.addAction("Help.error_log", new ShowErrorLogAction(this)); setJMenuBar(mm.getMenuBarFor(this)); // Load Icons moduleIcon = new ImageIcon(getClass().getResource("/images/mm-module.png")); activeExtensionIcon = new ImageIcon(getClass().getResource("/images/mm-extension-active.png")); inactiveExtensionIcon = new ImageIcon(getClass().getResource("/images/mm-extension-inactive.png")); openGameFolderIcon = new ImageIcon(getClass().getResource("/images/mm-gamefolder-open.png")); closedGameFolderIcon = new ImageIcon(getClass().getResource("/images/mm-gamefolder-closed.png")); fileIcon = new ImageIcon(getClass().getResource("/images/mm-file.png")); // build module controls final JPanel moduleControls = new JPanel(new BorderLayout()); modulePanelLayout = new CardLayout(); moduleView = new JPanel(modulePanelLayout); buildTree(); final JScrollPane scroll = new JScrollPane(tree); moduleView.add(scroll, "modules"); final JEditorPane l = new JEditorPane("text/html", Resources.getString("ModuleManager.quickstart")); l.setEditable(false); // Try to get background color and font from LookAndFeel; // otherwise, use dummy JLabel to get color and font. Color bg = UIManager.getColor("control"); Font font = UIManager.getFont("Label.font"); if (bg == null || font == null) { final JLabel dummy = new JLabel(); if (bg == null) bg = dummy.getBackground(); if (font == null) font = dummy.getFont(); } l.setBackground(bg); ((HTMLEditorKit) l.getEditorKit()).getStyleSheet() .addRule("body { font: " + font.getFamily() + " " + font.getSize() + "pt }"); l.addHyperlinkListener(BrowserSupport.getListener()); // FIXME: use MigLayout for this! // this is necessary to get proper vertical alignment final JPanel p = new JPanel(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.CENTER; p.add(l, c); moduleView.add(p, "quickStart"); modulePanelLayout.show(moduleView, getModuleCount() == 0 ? "quickStart" : "modules"); moduleControls.add(moduleView, BorderLayout.CENTER); moduleControls.setBorder(new TitledBorder(Resources.getString("ModuleManager.recent_modules"))); add(moduleControls); // build server status controls final ServerStatusView serverStatusControls = new ServerStatusView(new CgiServerStatus()); serverStatusControls.setBorder(new TitledBorder(Resources.getString("Chat.server_status"))); serverStatusView = new ComponentSplitter().splitRight(moduleControls, serverStatusControls, false); serverStatusView.revalidate(); // show the server status controls according to the prefs if (serverStatusConfig.booleanValue()) { serverStatusView.showComponent(); } setDividerLocation(getPreferredDividerLocation()); serverStatusView.addPropertyChangeListener("dividerLocation", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { setPreferredDividerLocation((Integer) e.getNewValue()); } }); final Rectangle r = Info.getScreenBounds(this); serverStatusControls.setPreferredSize(new Dimension((int) (r.width / 3.5), 0)); setSize(3 * r.width / 4, 3 * r.height / 4); // Save/load the window position and size in prefs final PositionOption option = new PositionOption(PositionOption.key + "ModuleManager", this); Prefs.getGlobalPrefs().addOption(option); }