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:Main.Interface_Main.java
private void btnAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAboutActionPerformed // for copying style JLabel label = new JLabel(); Font font = label.getFont();// w ww . j a va2 s . com // create some css from the label's font StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";"); style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";"); style.append("font-size:" + font.getSize() + "pt;"); // html content JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">" // + "This application was designed by <A HREF=http://www.friedcircuits.us>FriedCircuits</A> for the USB Tester." // + "<br><br><center>App Version: " + appVersion + "<br>FW Version: " + FW_VERSION + "</center><br><br>*Connect once to get FW version.</body></html>"); // handle link events ep.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); URI uri; try { uri = new java.net.URI("www.friedcircuits.us"); if (desktop.isSupported(Desktop.Action.BROWSE)) { try { desktop.browse(uri); } catch (IOException ex) { Logger.getLogger(Interface_Main.class.getName()).log(Level.SEVERE, null, ex); } } } catch (URISyntaxException ex) { Logger.getLogger(Interface_Main.class.getName()).log(Level.SEVERE, null, ex); } } // roll your own link launcher or use Desktop if J6+ } }); Color bgColor = label.getBackground(); UIDefaults defaults = new UIDefaults(); defaults.put("EditorPane[Enabled].backgroundPainter", bgColor); ep.putClientProperty("Nimbus.Overrides", defaults); ep.putClientProperty("Nimbus.Overrides.InheritDefaults", true); ep.setEditable(false); ep.setBackground(bgColor); // show ImageIcon myCustomIcon = new ImageIcon(getClass().getResource("/faviconbot2edit.png")); JOptionPane.showMessageDialog(plCurrent, ep, "About", JOptionPane.INFORMATION_MESSAGE, myCustomIcon); }
From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java
private void showUpdateResults(boolean updateAvailable) { String text = ""; if (updateAvailable) { text = "<html><body>jMetrik Update Available. <br>" + "Go to <a href=http://www.itemanalysis.com/jmetrik_download.php>http://www.itemanalysis.com/jmetrik-download.php</a><br>" + "and download the new version.<br>" + "</body></html>"; } else {//from w w w. j av a2 s .c o m text = "<html><body>No Update Available. <br>" + "You have the most current version of jMetrik. <br></body></html>"; } final JEditorPane p = new JEditorPane("text/html", text); p.setEditable(false); p.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { Desktop deskTop = Desktop.getDesktop(); try { URI uri = new URI("http://www.itemanalysis.com/jmetrik-download.php"); deskTop.browse(uri); } catch (URISyntaxException ex) { logger.fatal(ex.getMessage(), ex); } catch (IOException ex) { logger.fatal(ex.getMessage(), ex); } } } }); JOptionPane.showMessageDialog(Jmetrik.this, p, "jMetrik Update Status", JOptionPane.INFORMATION_MESSAGE); }
From source file:edu.ku.brc.specify.Specify.java
/** * Shows the About dialog./*www . j a va2s .com*/ */ public void doAbout() { AppContextMgr acm = AppContextMgr.getInstance(); boolean showDetailedAbout = acm.hasContext() && acm.getClassObject(Division.class) != null && acm.getClassObject(Discipline.class) != null && acm.getClassObject(Collection.class) != null; int baseNumRows = 14; String serverName = AppPreferences.getLocalPrefs().get("login.servers_selected", null); if (serverName != null) { baseNumRows++; } CellConstraints cc = new CellConstraints(); PanelBuilder infoPB = new PanelBuilder(new FormLayout("p,6px,f:p:g", "p,4px,p,4px," + UIHelper.createDuplicateJGoodiesDef("p", "2px", baseNumRows))); JLabel iconLabel = new JLabel(IconManager.getIcon("SpecifyLargeIcon"), SwingConstants.CENTER); //$NON-NLS-1$ PanelBuilder iconPB = new PanelBuilder(new FormLayout("p", "20px,t:p,f:p:g")); iconPB.add(iconLabel, cc.xy(1, 2)); if (showDetailedAbout) { final ArrayList<String> values = new ArrayList<String>(); DBTableIdMgr tableMgr = DBTableIdMgr.getInstance(); boolean hasReged = !RegisterSpecify.isAnonymous() && RegisterSpecify.hasInstitutionRegistered(); int y = 1; infoPB.addSeparator(getResourceString("Specify.SYS_INFO"), cc.xyw(1, y, 3)); y += 2; JLabel lbl = UIHelper.createLabel(databaseName); addLabel(values, infoPB, UIHelper.createI18NFormLabel("Specify.DB"), cc.xy(1, y)); addLabel(values, infoPB, lbl, cc.xy(3, y)); y += 2; lbl.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openLocalPrefs(); } } }); int instId = Institution.getClassTableId(); addLabel(values, infoPB, UIHelper.createFormLabel(tableMgr.getTitleForId(instId)), cc.xy(1, y)); addLabel(values, infoPB, lbl = UIHelper.createLabel(acm.getClassObject(Institution.class).getName()), cc.xy(3, y)); y += 2; addLabel(values, infoPB, UIHelper.createFormLabel(getGUIDTitle(instId)), cc.xy(1, y)); String noGUID = "<No GUID>"; String guidStr = acm.getClassObject(Institution.class).getGuid(); addLabel(values, infoPB, lbl = UIHelper.createLabel(guidStr != null ? guidStr : noGUID), cc.xy(3, y)); y += 2; lbl.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openRemotePrefs(); } } }); addLabel(values, infoPB, UIHelper.createFormLabel(tableMgr.getTitleForId(Division.getClassTableId())), cc.xy(1, y)); addLabel(values, infoPB, lbl = UIHelper.createLabel(acm.getClassObject(Division.class).getName()), cc.xy(3, y)); y += 2; lbl.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openGlobalPrefs(); } } }); addLabel(values, infoPB, UIHelper.createFormLabel(tableMgr.getTitleForId(Discipline.getClassTableId())), cc.xy(1, y)); addLabel(values, infoPB, UIHelper.createLabel(acm.getClassObject(Discipline.class).getName()), cc.xy(3, y)); y += 2; addLabel(values, infoPB, UIHelper.createFormLabel(tableMgr.getTitleForId(Collection.getClassTableId())), cc.xy(1, y)); addLabel(values, infoPB, UIHelper.createLabel(acm.getClassObject(Collection.class).getCollectionName()), cc.xy(3, y)); y += 2; addLabel(values, infoPB, UIHelper.createFormLabel(getGUIDTitle(Collection.getClassTableId())), cc.xy(1, y)); guidStr = acm.getClassObject(Collection.class).getGuid(); addLabel(values, infoPB, UIHelper.createLabel(guidStr != null ? guidStr : noGUID), cc.xy(3, y)); y += 2; //addLabel(values, infoPB, UIHelper.createI18NFormLabel("Specify.BLD"), cc.xy(1, y)); //addLabel(values, infoPB, UIHelper.createLabel(appBuildVersion),cc.xy(3, y)); y += 2; addLabel(values, infoPB, UIHelper.createI18NFormLabel("Specify.BLD"), cc.xy(1, y)); UIRegistry.loadAndPushResourceBundle("bld"); addLabel(values, infoPB, UIHelper.createLabel(getResourceString("build")), cc.xy(3, y)); y += 2; addLabel(values, infoPB, UIHelper.createI18NFormLabel("Specify.BLD_TM"), cc.xy(1, y)); addLabel(values, infoPB, UIHelper.createLabel(getResourceString("buildtime")), cc.xy(3, y)); y += 2; UIRegistry.popResourceBundle(); addLabel(values, infoPB, UIHelper.createI18NFormLabel("Specify.REG"), cc.xy(1, y)); addLabel(values, infoPB, UIHelper.createI18NLabel(hasReged ? "Specify.HASREG" : "Specify.NOTREG"), cc.xy(3, y)); y += 2; String isaNumber = RegisterSpecify.getISANumber(); addLabel(values, infoPB, UIHelper.createI18NFormLabel("Specify.ISANUM"), cc.xy(1, y)); addLabel(values, infoPB, UIHelper.createLabel(StringUtils.isNotEmpty(isaNumber) ? isaNumber : ""), cc.xy(3, y)); y += 2; if (serverName != null) { addLabel(values, infoPB, UIHelper.createI18NFormLabel("Specify.SERVER"), cc.xy(1, y)); addLabel(values, infoPB, UIHelper.createLabel(StringUtils.isNotEmpty(serverName) ? serverName : ""), cc.xy(3, y)); y += 2; } if (StringUtils.contains(DBConnection.getInstance().getConnectionStr(), "mysql")) { Vector<Object[]> list = BasicSQLUtils.query("select version() as ve"); if (list != null && list.size() > 0) { addLabel(values, infoPB, UIHelper.createFormLabel("MySQL Version"), cc.xy(1, y)); addLabel(values, infoPB, UIHelper.createLabel(list.get(0)[0].toString()), cc.xy(3, y)); y += 2; } } addLabel(values, infoPB, UIHelper.createFormLabel("Java Version"), cc.xy(1, y)); addLabel(values, infoPB, UIHelper.createLabel(System.getProperty("java.version")), cc.xy(3, y)); y += 2; JButton copyCBBtn = createIconBtn("ClipboardCopy", IconManager.IconSize.Std24, "Specify.CPY_ABT_TO_TT", null); //copyCBBtn.setBackground(Color.WHITE); //copyCBBtn.setOpaque(true); //copyCBBtn.setBorder(BorderFactory.createEtchedBorder()); copyCBBtn.setEnabled(true); PanelBuilder cbPB = new PanelBuilder(new FormLayout("f:p:g,p", "p")); cbPB.add(copyCBBtn, cc.xy(2, 1)); copyCBBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Copy to Clipboard StringBuilder sb = new StringBuilder(); for (int i = 0; i < values.size(); i++) { sb.append(String.format("%s = %s\n", values.get(i), values.get(i + 1))); i++; } UIHelper.setTextToClipboard(sb.toString()); UIRegistry.displayInfoMsgDlgLocalized("Specify.CPY_ABT_TO_MSG"); } }); infoPB.add(cbPB.getPanel(), cc.xy(3, y)); y += 2; } String txt = getAboutText(appName, appVersion); JLabel txtLbl = createLabel(txt); txtLbl.setFont(UIRegistry.getDefaultFont()); final JEditorPane txtPane = new JEditorPane("text/html", txt); txtPane.setEditable(false); txtPane.setBackground(new JPanel().getBackground()); PanelBuilder pb = new PanelBuilder(new FormLayout("p,20px,f:min(400px;p):g,10px,8px,10px,p:g", "f:p:g")); pb.add(iconPB.getPanel(), cc.xy(1, 1)); pb.add(txtPane, cc.xy(3, 1)); Color bg = getBackground(); if (showDetailedAbout) { pb.add(new VerticalSeparator(bg.darker(), bg.brighter()), cc.xy(5, 1)); pb.add(infoPB.getPanel(), cc.xy(7, 1)); } pb.setDefaultDialogBorder(); String title = getResourceString("Specify.ABOUT");//$NON-NLS-1$ CustomDialog aboutDlg = new CustomDialog(topFrame, title + " " + appName, true, CustomDialog.OK_BTN, //$NON-NLS-1$ pb.getPanel()); String okLabel = getResourceString("Specify.CLOSE");//$NON-NLS-1$ aboutDlg.setOkLabel(okLabel); aboutDlg.createUI(); aboutDlg.pack(); // for some strange reason I can't get the dialog to size itself correctly Dimension size = aboutDlg.getSize(); size.height += 120; aboutDlg.setSize(size); txtPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { AttachmentUtils.openURI(event.getURL().toURI()); } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); } } } }); UIHelper.centerAndShow(aboutDlg); }
From source file:com.nikonhacker.gui.EmulatorUI.java
private void showAboutDialog() { // for copying style JLabel label = new JLabel(); Font font = label.getFont();// ww w . ja v a2 s. co m // create some css from the label's font String style = "font-family:" + font.getFamily() + ";" + "font-weight:" + (font.isBold() ? "bold" : "normal") + ";" + "font-size:" + font.getSize() + "pt;"; // html content JEditorPane editorPane = new JEditorPane("text/html", "<html><body style=\"" + style + "\">" + "<font size=\"+1\">" + ApplicationInfo.getNameVersion() + "</font><br/>" + "<i>A dual (Fujitsu FR + Toshiba TX) microcontroller emulator in Java, aimed at mimicking the behaviour of Nikon DSLRs</i><br/>" + "<font size=\"-2\">Built on " + ApplicationInfo.getBuildTime() + "</font><br/><br/>" + "This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.<br/>" + "This software is provided under the GNU General Public License, version 3 - " + makeLink("http://www.gnu.org/licenses/gpl-3.0.txt") + "<br/>" + "This software is based on, or makes use of, the following works:<ul>\n" + "<li>Simeon Pilgrim's deciphering of firmware encoding and lots of information shared on his blog - " + makeLink("http://simeonpilgrim.com/blog/") + "</li>" + "<li>Dfr Fujitsu FR diassembler Copyright (c) Kevin Schoedel - " + makeLink("http://scratchpad.wikia.com/wiki/Disassemblers/DFR") + "<br/>and its port to C# by Simeon Pilgrim</li>" + "<li>\"How To Write a Computer Emulator\" article by Marat Fayzullin - " + makeLink("http://fms.komkon.org/EMUL8/HOWTO.html") + "</li>" + "<li>The PearColator x86 emulator project - " + makeLink("http://apt.cs.man.ac.uk/projects/jamaica/tools/PearColator/") + "</li>" + "<li>The Jacksum checksum library Copyright (c) Dipl.-Inf. (FH) Johann Nepomuk Lfflmann - " + makeLink("http://www.jonelo.de/java/jacksum/") + "</li>" + "<li>HexEditor & RSyntaxTextArea swing components, Copyright (c) Robert Futrell - " + makeLink("http://fifesoft.com/hexeditor/") + "</li>" + "<li>JGraphX graph drawing library, Copyright (c) JGraph Ltd - " + makeLink("http://www.jgraph.com/jgraph.html") + "</li>" + "<li>Apache commons libraries, Copyright (c) The Apache Software Foundation - " + makeLink("http://commons.apache.org/") + "</li>" + "<li>VerticalLayout, Copyright (c) Cellspark - " + makeLink("http://www.cellspark.com/vl.html") + "</li>" + "<li>MigLayout, Copyright (c) MigInfoCom - " + makeLink("http://www.miginfocom.com/") + "</li>" + "<li>Glazed Lists, Copyright (c) 2003-2006, publicobject.com, O'Dell Engineering Ltd - " + makeLink("http://www.glazedlists.com/") + "</li>" + "<li>Samples from the Java Tutorial (c) Sun Microsystems / Oracle - " + makeLink("http://docs.oracle.com/javase/tutorial") + "</li>" + "<li>MARS, MIPS Assembler and Runtime Simulator (c) 2003-2011, Pete Sanderson and Kenneth Vollmar - " + makeLink("http://courses.missouristate.edu/KenVollmar/MARS") + "</li>" + "<li>SteelSeries (and SteelCheckBox) Swing components (c) 2010, Gerrit Grunwald - " + makeLink("http://harmoniccode.blogspot.be/search/label/steelseries") + "</li>" + "</ul>" + "License terms for all included code are available in the 'licenses' folder of the distribution." + "<p>For more information, help or ideas, please join us at " + makeLink("http://nikonhacker.com") + "</p></body></html>"); // handle link events editorPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (Exception e1) { // noop } } } }); editorPane.setEditable(false); Color greyLayer = new Color(label.getBackground().getRed(), label.getBackground().getGreen(), label.getBackground().getBlue(), 192); editorPane.setBackground(greyLayer); //editorPane.setOpaque(false); // show // JOptionPane.showMessageDialog(this, editorPane, "About", JOptionPane.PLAIN_MESSAGE); final JDialog dialog = new JDialog(this, "About", true); JPanel contentPane = new BackgroundImagePanel(new BorderLayout(), Toolkit.getDefaultToolkit().getImage(EmulatorUI.class.getResource("images/nh_full.jpg"))); contentPane.add(editorPane, BorderLayout.CENTER); JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); bottomPanel.add(okButton); bottomPanel.setBackground(greyLayer); // bottomPanel.setOpaque(false); contentPane.add(bottomPanel, BorderLayout.SOUTH); dialog.setContentPane(contentPane); dialog.pack(); dialog.setLocationRelativeTo(this); dialog.setResizable(false); dialog.setVisible(true); }
From source file:org.apache.airavata.xbaya.ui.dialogs.monitor.MonitorWindow.java
private void init() { this.timeTextField = new XBayaTextField(); this.timeTextField.setEditable(false); XBayaLabel timeLabel = new XBayaLabel(EventDataRepository.Column.TIME.getName(), this.timeTextField); this.idTextField = new XBayaTextField(); this.idTextField.setEditable(false); XBayaLabel idLabel = new XBayaLabel(EventDataRepository.Column.ID.getName(), this.idTextField); this.statusTextField = new XBayaTextField(); this.statusTextField.setEditable(false); XBayaLabel statusLabel = new XBayaLabel(EventDataRepository.Column.STATUS.getName(), this.statusTextField); this.messageTextArea = new JEditorPane(XmlConstants.CONTENT_TYPE_HTML, ""); this.messageTextArea.setSize(500, 500); this.messageTextArea.setEditable(false); messageTextArea.setBackground(Color.WHITE); messageTextArea.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == EventType.ACTIVATED) { URL url = event.getURL(); try { BrowserLauncher.openURL(url.toString()); } catch (Exception e) { MonitorWindow.this.xbayaGUI.getErrorWindow().error(MonitorWindow.this.dialog.getDialog(), e.getMessage(), e); }/*from w w w. j ava 2s . c om*/ } } }); JScrollPane pane = new JScrollPane(messageTextArea); pane.setSize(500, 500); XBayaLabel messageLabel = new XBayaLabel(EventDataRepository.Column.MESSAGE.getName(), pane); GridPanel infoPanel = new GridPanel(); infoPanel.add(timeLabel); infoPanel.add(this.timeTextField); infoPanel.add(idLabel); infoPanel.add(this.idTextField); infoPanel.add(statusLabel); infoPanel.add(this.statusTextField); infoPanel.add(messageLabel); infoPanel.add(pane); infoPanel.layout(4, 2, 3, 1); JButton okButton = new JButton("OK"); okButton.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { hide(); } }); JButton copyButton = new JButton("Copy to Clipboard"); copyButton.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(messageText), null); } }); JPanel buttonPanel = new JPanel(); buttonPanel.add(okButton); buttonPanel.add(copyButton); this.dialog = new XBayaDialog(this.xbayaGUI, "Notification", infoPanel, buttonPanel); this.dialog.setDefaultButton(okButton); }
From source file:org.apache.cayenne.modeler.dialog.ErrorDebugDialog.java
protected void init() { setResizable(false);//ww w. j a v a 2 s . c o m Container pane = this.getContentPane(); pane.setLayout(new BorderLayout()); // info area JEditorPane infoText = new JEditorPane("text/html", infoHTML()); infoText.setBackground(pane.getBackground()); infoText.setEditable(false); // popup hyperlinks infoText.addHyperlinkListener(this); JPanel infoPanel = new JPanel(); infoPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); infoPanel.add(infoText); pane.add(infoPanel, BorderLayout.NORTH); // exception area if (throwable != null) { exText.setEditable(false); exText.setLineWrap(true); exText.setWrapStyleWord(true); exText.setRows(16); exText.setColumns(40); JScrollPane exScroll = new JScrollPane(exText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); exPanel = new JPanel(); exPanel.setLayout(new BorderLayout()); exPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); exPanel.add(exScroll, BorderLayout.CENTER); // buttons showHide = new JButton(""); showHide.addActionListener(this); if (isDetailed()) { showDetails(); } else { hideDetails(); } } close = new JButton("Close"); close.addActionListener(this); JButton[] buttons = (showHide != null) ? new JButton[] { showHide, close } : new JButton[] { close }; pane.add(PanelFactory.createButtonPanel(buttons), BorderLayout.SOUTH); //add a listener to clear static variables, not to produce garbage addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { instance = null; } }); // prepare to display this.pack(); this.centerWindow(); }
From source file:org.apache.tika.gui.TikaGUI.java
private void handleError(String name, Throwable t) { StringWriter writer = new StringWriter(); writer.append("Apache Tika was unable to parse the document\n"); writer.append("at " + name + ".\n\n"); writer.append("The full exception stack trace is included below:\n\n"); t.printStackTrace(new PrintWriter(writer)); JEditorPane editor = new JEditorPane("text/plain", writer.toString()); editor.setEditable(false);/* w ww . j a v a 2s. c o m*/ editor.setBackground(Color.WHITE); editor.setCaretPosition(0); editor.setPreferredSize(new Dimension(600, 400)); JDialog dialog = new JDialog(this, "Apache Tika error"); dialog.add(new JScrollPane(editor)); dialog.pack(); dialog.setVisible(true); }
From source file:org.apache.tika.gui.TikaGUI.java
public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == EventType.ACTIVATED) { try {//w w w. j av a 2 s . c o m URL url = e.getURL(); try (InputStream stream = url.openStream()) { JEditorPane editor = new JEditorPane("text/plain", IOUtils.toString(stream, UTF_8)); editor.setEditable(false); editor.setBackground(Color.WHITE); editor.setCaretPosition(0); editor.setPreferredSize(new Dimension(600, 400)); String name = url.toString(); name = name.substring(name.lastIndexOf('/') + 1); JDialog dialog = new JDialog(this, "Apache Tika: " + name); dialog.add(new JScrollPane(editor)); dialog.pack(); dialog.setVisible(true); } } catch (IOException exception) { exception.printStackTrace(); } } }
From source file:org.formic.wizard.step.gui.FeatureListStep.java
/** * {@inheritDoc}/*ww w . j av a 2 s. c o m*/ * @see org.formic.wizard.step.GuiStep#init() */ public Component init() { featureInfo = new JEditorPane("text/html", StringUtils.EMPTY); featureInfo.setEditable(false); featureInfo.addHyperlinkListener(new HyperlinkListener()); Feature[] features = provider.getFeatures(); JTable table = new JTable(features.length, 1) { private static final long serialVersionUID = 1L; public Class getColumnClass(int column) { return getValueAt(0, column).getClass(); } public boolean isCellEditable(int row, int column) { return false; } }; table.setBackground(new javax.swing.JList().getBackground()); GuiForm form = createForm(); for (int ii = 0; ii < features.length; ii++) { final Feature feature = (Feature) features[ii]; final JCheckBox box = new JCheckBox(); String name = getName() + '.' + feature.getKey(); form.bind(name, box); box.putClientProperty("feature", feature); featureMap.put(feature.getKey(), box); if (feature.getInfo() == null) { feature.setInfo(Installer.getString(getName() + "." + feature.getKey() + ".html")); } feature.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (Feature.ENABLED_PROPERTY.equals(event.getPropertyName())) { if (box.isSelected() != feature.isEnabled()) { box.setSelected(feature.isEnabled()); } } } }); box.setText(Installer.getString(name)); box.setBackground(table.getBackground()); if (!feature.isAvailable()) { box.setSelected(false); box.setEnabled(false); } table.setValueAt(box, ii, 0); } FeatureListMouseListener mouseListener = new FeatureListMouseListener(); for (int ii = 0; ii < features.length; ii++) { Feature feature = (Feature) features[ii]; if (feature.isEnabled() && feature.isAvailable()) { JCheckBox box = (JCheckBox) featureMap.get(feature.getKey()); box.setSelected(true); mouseListener.processDependencies(feature); mouseListener.processExclusives(feature); } } table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setShowHorizontalLines(false); table.setShowVerticalLines(false); table.setDefaultRenderer(JCheckBox.class, new ComponentTableCellRenderer()); table.addKeyListener(new FeatureListKeyListener()); table.addMouseListener(mouseListener); table.getSelectionModel().addListSelectionListener(new FeatureListSelectionListener(table)); table.setRowSelectionInterval(0, 0); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); JPanel container = new JPanel(new BorderLayout()); container.add(table, BorderLayout.CENTER); panel.add(new JScrollPane(container), BorderLayout.CENTER); JScrollPane infoScroll = new JScrollPane(featureInfo); infoScroll.setMinimumSize(new Dimension(0, 50)); infoScroll.setMaximumSize(new Dimension(0, 50)); infoScroll.setPreferredSize(new Dimension(0, 50)); panel.add(infoScroll, BorderLayout.SOUTH); return panel; }
From source file:org.formic.wizard.step.gui.RequirementsValidationStep.java
/** * {@inheritDoc}/* w ww . ja v a2 s .c o m*/ * @see org.formic.wizard.step.GuiStep#init() */ public Component init() { busyIcon = new ImageIcon(Installer.getImage(getName() + ".busy")); okIcon = new ImageIcon(Installer.getImage(getName() + ".ok")); warnIcon = new ImageIcon(Installer.getImage(getName() + ".warning")); failedIcon = new ImageIcon(Installer.getImage(getName() + ".failed")); requirementInfo = new JEditorPane("text/html", StringUtils.EMPTY); requirementInfo.setEditable(false); requirementInfo.addHyperlinkListener(new HyperlinkListener()); table = new JTable(1, 2) { private static final long serialVersionUID = 1L; public Class getColumnClass(int column) { Object value = getValueAt(0, column); return value != null ? value.getClass() : Object.class; } public boolean isCellEditable(int row, int column) { return false; } }; table.setBackground(new javax.swing.JList().getBackground()); table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setShowHorizontalLines(false); table.setShowVerticalLines(false); table.setDefaultRenderer(JLabel.class, new ComponentTableCellRenderer()); table.getSelectionModel().addListSelectionListener(new RequirementsSelectionListener(table)); table.setRowSelectionInterval(0, 0); retryButton = new JButton(Installer.getString("requirements.retry")); retryButton.setVisible(false); retryButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { displayed(); } }); form = createForm(); JPanel container = new JPanel(new BorderLayout()); container.add(table, BorderLayout.CENTER); JScrollPane infoScroll = new JScrollPane(requirementInfo); JPanel panel = new JPanel(new MigLayout("wrap 1", "[fill]", "[] [fill, grow] [fill] []")); panel.add(form.createMessagePanel()); panel.add(new JScrollPane(container), "grow"); panel.add(infoScroll, "height 50!"); panel.add(retryButton, "right, width 50!"); return panel; }