List of usage examples for javax.swing JEditorPane setBackground
@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.") public void setBackground(Color bg)
From source file:edu.ku.brc.specify.Specify.java
/** * Shows the About dialog./*from ww w .jav a 2 s. c o m*/ */ 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();//from w w w .j av a 2 s .c o 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.cayenne.modeler.dialog.ErrorDebugDialog.java
protected void init() { setResizable(false);/*from w ww .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 .ja v a 2s.co 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
private void addWelcomeCard(JPanel panel, String name) { try {/*w ww. j a v a 2s .c om*/ JEditorPane editor = new JEditorPane(TikaGUI.class.getResource("welcome.html")); editor.setContentType("text/html"); editor.setEditable(false); editor.setBackground(Color.WHITE); editor.setTransferHandler(new ParsingTransferHandler(editor.getTransferHandler(), this)); panel.add(new JScrollPane(editor), name); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.apache.tika.gui.TikaGUI.java
private JEditorPane addCard(JPanel panel, String type, String name) { JEditorPane editor = new JTextPane(); editor.setBackground(Color.WHITE); editor.setContentType(type);/* w w w .ja v a 2s. com*/ editor.setTransferHandler(new ParsingTransferHandler(editor.getTransferHandler(), this)); panel.add(new JScrollPane(editor), name); return editor; }
From source file:org.apache.tika.gui.TikaGUI.java
private void textDialog(String title, URL resource) { try {/*from ww w . j ava2 s . co m*/ JDialog dialog = new JDialog(this, title); JEditorPane editor = new JEditorPane(resource); editor.setContentType("text/html"); editor.setEditable(false); editor.setBackground(Color.WHITE); editor.setPreferredSize(new Dimension(400, 250)); editor.addHyperlinkListener(this); dialog.add(editor); dialog.pack(); dialog.setVisible(true); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.apache.tika.gui.TikaGUI.java
public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == EventType.ACTIVATED) { try {/* w w w . j a v 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.isatools.isacreator.ontologyselectiontool.ViewTermDefinitionUI.java
private JEditorPane createOntologyInformationDisplay(OntologyBranch term) { JEditorPane ontologyInfo = new JEditorPane(); ontologyInfo.setContentType("text/html"); ontologyInfo.setEditable(false);/*from w ww . ja v a 2 s . c o m*/ ontologyInfo.setBackground(UIHelper.BG_COLOR); String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {" + " font-family: Verdana;" + " font-size: 8.5px;" + " color: #006838;" + "}" + "-->" + "</style>" + "</head>" + "<body class=\"bodyFont\">"; labelContent += "<b>Term name: </b>" + term.getBranchName() + "</p>"; // special handling for ChEBI to get the structural image System.out.println("Showing CHEBI image for " + term.getBranchIdentifier()); if (term.getBranchIdentifier().toLowerCase().contains("chebi")) { String chebiTermId = term.getBranchIdentifier() .substring(term.getBranchIdentifier().lastIndexOf("_") + 1); System.out.println("Showing CHEBI image for " + chebiTermId); String chebiImageURL = "http://www.ebi.ac.uk/chebi/displayImage.do?defaultImage=true&imageIndex=0&chebiId=" + chebiTermId; labelContent += "<p><b>Chemical structure:</b>" + "<p/>" + "<img src=\"" + chebiImageURL + "\" alt=\"chemical structure for " + term.getBranchName() + "\" width=\"150\" height=\"150\"/>"; } properties = sortMap(properties); if (properties != null && properties.size() > 0) { for (String propertyType : properties.keySet()) { if (propertyType != null) { labelContent += ("<p><b>" + propertyType + ": </b>"); labelContent += (properties.get(propertyType) == null ? "no definition available" : properties.get(propertyType) + "</font></p>"); } } } else { labelContent += "<p>No definition found for this term! This can be due to 2 reasons: " + "1) Unfortunately, not all terms have their definitions supplied; and 2) the " + "ability to view the definitions for a term in this tool is not yet fully supported.</p>"; } labelContent += "</body></html>"; ontologyInfo.setText(labelContent); return ontologyInfo; }
From source file:org.isatools.isacreator.visualization.AssayInfoPanel.java
private JPanel prepareAssayInformation() { assayInformation.removeAll();//from w ww . jav a 2 s. c om JEditorPane currentlyShowingInfo = new JEditorPane(); currentlyShowingInfo.setContentType("text/html"); currentlyShowingInfo.setEditable(false); currentlyShowingInfo.setBackground(UIHelper.BG_COLOR); currentlyShowingInfo.setPreferredSize(new Dimension(width - 10, height - 30)); Map<String, String> data = getAssayDetails(); String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {" + " font-family: Verdana;" + " font-size: 9px;" + " color: #006838;" + "}" + "-->" + "</style>" + "</head>" + "<body class=\"bodyFont\">"; for (Object key : data.keySet()) { labelContent += ("<p><b>" + ((String) key).trim() + ": </b>"); labelContent += (data.get(key) + "</font></p>"); } labelContent += "</body></html>"; currentlyShowingInfo.setText(labelContent); assayInformation.add(currentlyShowingInfo); return assayInformation; }