List of usage examples for javax.swing.event HyperlinkEvent getEventType
public EventType getEventType()
From source file:ca.canuckcoding.wosqi.FeedViewer.java
private void jTextPane9HyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) {//GEN-FIRST:event_jTextPane9HyperlinkUpdate if (evt.getEventType() == javax.swing.event.HyperlinkEvent.EventType.ACTIVATED) { openUrl(evt.getURL());//from w w w . jav a2 s .c o m } }
From source file:com.nikonhacker.gui.EmulatorUI.java
private void showAboutDialog() { // for copying style JLabel label = new JLabel(); Font font = label.getFont();//from www.j a v a 2s . c om // 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:edu.ku.brc.specify.Specify.java
/** * Shows the About dialog./*w w w .ja v a 2 s .c om*/ */ 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:base.BasePlayer.Main.java
void setMenuBar() { //filemenu.addMouseListener(this); //toolmenu.addMouseListener(this); filemenu = new JMenu("File"); toolmenu = new JMenu("Tools"); help = new JMenu("Help"); about = new JMenu("About"); menubar = new JMenuBar(); //help.addMouseListener(this); exit = new JMenuItem("Exit"); manual = new JButton("Online manual"); manual.addActionListener(new ActionListener() { @Override//from w w w. j a v a2 s .co m public void actionPerformed(ActionEvent arg0) { Main.gotoURL("https://baseplayer.fi/BPmanual"); } }); // opensamples = new JMenuItem("Add samples"); zoomout = new JButton("Zoom out"); back = new JButton("<<"); forward = new JButton(">>"); manage = new JButton("Variant Manager"); openvcfs = new JMenuItem("Add VCFs", open); openbams = new JMenuItem("Add BAMs", open); average = new JMenuItem("Coverage calculator"); update = new JMenuItem("Update"); update.setVisible(false); errorlog = new JMenuItem("View log"); //helpLabel = new JLabel("This is pre-release version of BasePlayer\nContact: help@baseplayer.fi\n\nUniversity of Helsinki"); addURL = new JMenu("Add from URL"); urlField = new JTextField("Enter URL"); addtracks = new JMenuItem("Add tracks"); fromURL = new JMenuItem("Add track from URL"); addcontrols = new JMenuItem("Add controls"); pleiadesButton = new JMenuItem("PLEIADES"); saveProject = new JMenuItem("Save project"); saveProjectAs = new JMenuItem("Save project as..."); openProject = new JMenuItem("Open project"); clear = new JMenuItem("Clear data"); clearMemory = new JMenuItem("Clean memory"); // welcome = new JMenuItem("Welcome screen"); filemenu.add(openvcfs); filemenu.add(openbams); variantCaller = new JMenuItem("Variant Caller"); tbrowser = new JMenuItem("Table Browser"); bconvert = new JMenuItem("BED converter"); peakCaller = new JMenuItem("Peak Caller"); addtracks = new JMenuItem("Add tracks", open); filemenu.add(addtracks); addcontrols = new JMenuItem("Add controls", open); filemenu.add(addcontrols); filemenu.add(fromURL); if (pleiades) { pleiadesButton.setPreferredSize(buttonDimension); pleiadesButton.addActionListener(this); filemenu.add(pleiadesButton); } filemenu.add(new JSeparator()); openProject = new JMenuItem("Open project", open); filemenu.add(openProject); saveProject = new JMenuItem("Save project", save); filemenu.add(saveProject); saveProjectAs = new JMenuItem("Save project as...", save); filemenu.add(saveProjectAs); filemenu.add(new JSeparator()); filemenu.add(genome); filemenu.add(update); filemenu.add(clear); filemenu.add(new JSeparator()); filemenu.add(exit); exit.addActionListener(this); menubar.add(filemenu); manage.addActionListener(this); manage.addMouseListener(this); update.addActionListener(this); average.addActionListener(this); average.setEnabled(false); average.setToolTipText("No bam/cram files opened"); tbrowser.addActionListener(this); bconvert.addActionListener(this); toolmenu.add(tbrowser); toolmenu.add(average); toolmenu.add(variantCaller); toolmenu.add(bconvert); fromURL.addMouseListener(this); fromURL.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { final JPopupMenu menu = new JPopupMenu(); final JTextField area = new JTextField(); JButton add = new JButton("Fetch"); JLabel label = new JLabel("Paste track URL below"); JScrollPane menuscroll = new JScrollPane(); add.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { String urltext = area.getText().trim(); Boolean size = true; if (urltext.contains("pleiades")) { openPleiades(urltext); return; } if (!FileRead.isTrackFile(urltext)) { showError("The file format is not supported.\n" + "Supported formats: bed, bigwig, bigbed, gff, bedgraph", "Error"); return; } if (!urltext.toLowerCase().endsWith(".bw") && !urltext.toLowerCase().endsWith(".bigwig") && !urltext.toLowerCase().endsWith(".bb") && !urltext.toLowerCase().endsWith(".bigbed")) { URL url = null; try { url = new URL(urltext); } catch (Exception ex) { menu.setVisible(false); Main.showError("Please paste whole url (protocol included)", "Error"); return; } URL testurl = url; HttpURLConnection huc = (HttpURLConnection) testurl.openConnection(); huc.setRequestMethod("HEAD"); int responseCode = huc.getResponseCode(); if (responseCode != 404) { SeekableStream stream = SeekableStreamFactory.getInstance().getStreamFor(url); TabixReader tabixReader = null; String index = null; try { if (stream.length() / (double) 1048576 >= Settings.settings .get("bigFile")) { size = false; } tabixReader = new TabixReader(urltext, urltext + ".tbi", stream); index = urltext + ".tbi"; testurl = new URL(index); huc = (HttpURLConnection) testurl.openConnection(); huc.setRequestMethod("HEAD"); responseCode = huc.getResponseCode(); if (responseCode == 404) { menu.setVisible(false); Main.showError("Index file (.tbi) not found in the URL.", "Error"); return; } } catch (Exception ex) { try { tabixReader = new TabixReader(urltext, urltext.substring(0, urltext.indexOf(".gz")) + ".tbi", stream); index = urltext.substring(0, urltext.indexOf(".gz")) + ".tbi"; } catch (Exception exc) { menu.setVisible(false); Main.showError("Could not read tabix file.", "Error"); } } if (tabixReader != null && index != null) { stream.close(); tabixReader.close(); menu.setVisible(false); FileRead filereader = new FileRead(); filereader.readBED(urltext, index, size); } } else { menu.setVisible(false); Main.showError("Not a valid URL", "Error"); } } else { URL url = null; try { url = new URL(urltext); } catch (Exception ex) { Main.showError("Please paste whole url (protocol included)", "Error"); return; } final URL testurl = url; HttpURLConnection huc = (HttpURLConnection) testurl.openConnection(); huc.setRequestMethod("HEAD"); int responseCode = huc.getResponseCode(); if (responseCode != 404) { menu.setVisible(false); FileRead filereader = new FileRead(); filereader.readBED(urltext, "nan", true); } else { menu.setVisible(false); Main.showError("Not a valid URL", "Error"); } } } catch (Exception ex) { ex.printStackTrace(); } } }); area.setFont(Main.menuFont); //area.setText("https://baseplayer.fi/tracks/Mappability_1000Genomes_pilot_mask.bed.gz"); menu.add(label); menu.add(menuscroll); menu.add(add); area.setPreferredSize(new Dimension(300, Main.defaultFontSize + 8)); area.setCaretPosition(0); area.revalidate(); menuscroll.getViewport().add(area); area.requestFocus(); menu.pack(); menu.show(frame, mouseX + 20, fromURL.getY()); } }); //toolmenu.add(peakCaller); variantCaller.setToolTipText("No bam/cram files opened"); variantCaller.addActionListener(this); variantCaller.setEnabled(false); peakCaller.setEnabled(true); peakCaller.addActionListener(this); settings.addActionListener(this); clearMemory.addActionListener(this); errorlog.addActionListener(this); toolmenu.add(clearMemory); toolmenu.add(errorlog); toolmenu.add(new JSeparator()); toolmenu.add(settings); menubar.add(toolmenu); menubar.add(manage); area = new JEditorPane(); String infotext = "<html><h2>BasePlayer</h2>This is a version " + version + " of BasePlayer (<a href=https://baseplayer.fi>https://baseplayer.fi</a>)<br/> Author: Riku Katainen <br/> University of Helsinki<br/>" + "Tumor Genomics Group (<a href=http://research.med.helsinki.fi/gsb/aaltonen/>http://research.med.helsinki.fi/gsb/aaltonen/</a>) <br/> " + "Contact: help@baseplayer.fi <br/> <br/>" + "Supported filetype for variants is VCF and VCF.gz (index file will be created if missing)<br/> " + "Supported filetypes for reads are BAM and CRAM. Index files required (.bai or .crai). <br/> " + "Supported filetypes for additional tracks are BED(.gz), GFF.gz, BedGraph, BigWig, BigBed.<br/> (tabix index required for bgzipped files). <br/><br/> " + "For optimal usage, you should have vcf.gz and bam -files for each sample. <br/> " + "e.g. in case you have a sample named as sample1, name all files similarly and <br/>" + "place in the same folder:<br/>" + "sample1.vcf.gz<br/>" + "sample1.vcf.gz.tbi<br/>" + "sample1.bam<br/>" + "sample1.bam.bai<br/><br/>" + "When you open sample1.vcf.gz, sample1.bam is recognized and opened<br/>" + "on the same track.<br/><br/>" + "Instructional videos can be viewed at our <a href=https://www.youtube.com/channel/UCywq-T7W0YPzACyB4LT7Q3g> Youtube channel</a>"; area = new JEditorPane(); area.setEditable(false); area.setEditorKit(JEditorPane.createEditorKitForContentType("text/html")); area.setText(infotext); area.setFont(Main.menuFont); area.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { HyperlinkEvent.EventType type = hyperlinkEvent.getEventType(); final URL url = hyperlinkEvent.getURL(); if (type == HyperlinkEvent.EventType.ACTIVATED) { Main.gotoURL(url.toString()); } } }); about.add(area); about.addMouseListener(this); help.add(about); help.add(manual); menubar.add(help); JLabel emptylab = new JLabel(" "); emptylab.setEnabled(false); emptylab.setOpaque(false); menubar.add(emptylab); chromosomeDropdown.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 1, Color.lightGray)); chromosomeDropdown.setBorder(BorderFactory.createCompoundBorder(chromosomeDropdown.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); chromlabel.setToolTipText("Current chromosome"); chromlabel.setFocusable(false); chromlabel.addMouseListener(this); chromlabel.setBackground(Color.white); chromlabel.setEditable(false); chromlabel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 0, Color.lightGray)); chromlabel.setBorder(BorderFactory.createCompoundBorder(chromlabel.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); menubar.add(chromlabel); chromosomeDropdown.setBackground(Color.white); chromosomeDropdown.setToolTipText("Current chromosome"); menubar.add(chromosomeDropdown); JLabel empty3 = new JLabel(" "); empty3.setEnabled(false); empty3.setOpaque(false); menubar.add(empty3); menubar.add(back); menubar.add(searchField); searchField.setForeground(Color.gray); searchField.setBorder(BorderFactory.createCompoundBorder(searchField.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); searchField.addMouseListener(this); menubar.add(back); menubar.add(searchField); searchField.setForeground(Color.gray); back.addMouseListener(this); back.setToolTipText("Back"); forward.addMouseListener(this); forward.setToolTipText("Forward"); back.setEnabled(false); forward.setEnabled(false); searchField.addMouseListener(this); menubar.add(back); menubar.add(searchField); searchField.setForeground(Color.gray); back.addMouseListener(this); forward.addMouseListener(this); back.setEnabled(false); forward.setEnabled(false); forward.setMargin(new Insets(0, 2, 0, 2)); back.setMargin(new Insets(0, 2, 0, 2)); menubar.add(forward); JLabel empty4 = new JLabel(" "); empty4.setOpaque(false); empty4.setEnabled(false); menubar.add(empty4); menubar.add(zoomout); JLabel empty5 = new JLabel(" "); empty5.setEnabled(false); empty5.setOpaque(false); menubar.add(empty5); positionField.setEditable(false); positionField.setBackground(new Color(250, 250, 250)); positionField.setMargin(new Insets(0, 2, 0, 0)); positionField.setBorder(BorderFactory.createCompoundBorder(widthLabel.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); menubar.add(positionField); widthLabel.setEditable(false); widthLabel.setBackground(new Color(250, 250, 250)); widthLabel.setMargin(new Insets(0, 2, 0, 0)); widthLabel.setBorder(BorderFactory.createCompoundBorder(widthLabel.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); JLabel empty6 = new JLabel(" "); empty6.setEnabled(false); empty6.setOpaque(false); menubar.add(empty6); menubar.add(widthLabel); JLabel empty7 = new JLabel(" "); empty7.setOpaque(false); empty7.setEnabled(false); menubar.add(empty7); }
From source file:nz.govt.natlib.ndha.manualdeposit.HelpWindow.java
/** Creates new form HelpWindow */ public HelpWindow(final String title, final URL hlpURL, final String settingsPath) { super(title); try {/*from ww w .java2 s .c om*/ frmControl = new FormControl(this, settingsPath); } catch (Exception ex) { LOG.error("Error loading form parameters", ex); } helpURL = hlpURL; editorpane = new JEditorPane(); editorpane.setEditable(false); try { editorpane.setPage(helpURL); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); } // anonymous inner listener editorpane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(final HyperlinkEvent ev) { try { if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { editorpane.setPage(ev.getURL()); } } catch (IOException ex) { // put message in window LOG.error(ex.getMessage(), ex); } } }); getContentPane().add(new JScrollPane(editorpane)); addButtons(); // no need for listener just dispose setDefaultCloseOperation(DISPOSE_ON_CLOSE); 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); }/* w ww . jav a 2s.c o m*/ } } }); 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.tika.gui.TikaGUI.java
public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == EventType.ACTIVATED) { try {// w ww . ja va2 s . c om 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.echocat.velma.dialogs.AboutDialog.java
protected void createIntroduction(@Nonnull Resources resources) { final URL iconUrl = resources.getIconUrl(48); final StringBuilder body = new StringBuilder(); body.append("<html>"); body.append("<head><style>" + "td { margin-right: 10px; }" + "</style></head>"); body.append("<body style='font-family: sans; font-size: 1em'><table><tr>"); body.append("<td valign='top'><img src='").append(iconUrl).append("' /></td>"); body.append("<td valign='top'>"); body.append("<h2>").append(escapeHtml4(resources.getApplicationName())); final String version = resources.getVersion(); if (!isEmpty(version)) { body.append("<br/><span style='font-size: 0.6em'>") .append(resources.formatEscaped("versionText", version)).append("</span>"); }/*from w w w. ja v a2 s .c o m*/ body.append("</h2>"); body.append("<p>Copyright 2011-2012 <a href='https://echocat.org'>echocat</a></p>"); body.append("<p><a href='http://mozilla.org/MPL/2.0/'>") .append(resources.formatEscaped("licensedUnder", "MPL 2.0")).append("</a></p>"); body.append("<p><table cellpadding='0' cellspacing='0'>"); body.append("<tr><td>").append(resources.formatEscaped("xHomepage", "echocat")) .append(":</td><td><a href='https://echocat.org'>echocat.org</a></td></tr>"); body.append("<tr><td>").append(resources.formatEscaped("xHomepage", "Velma")) .append(":</td><td><a href='https://velma.echocat.org'>velma.echocat.org</a></td></tr>"); body.append("</table></p>"); body.append("<h4>").append(resources.formatEscaped("developers")) .append("</h4><table cellpadding='0' cellspacing='0'>"); body.append( "<tr><td>Gregor Noczinski</td><td><a href='mailto:gregor@noczinski.eu'>gregor@noczinski.eu</a></td><td><a href='https://github.com/blaubaer'>github.com/blaubaer</a></td></tr>"); body.append("</table>"); body.append("</td>"); body.append("</tr></table></body></html>"); final JTextPane text = new JTextPane(); text.setMargin(new Insets(0, 0, 0, 0)); text.setContentType("text/html"); text.setText(body.toString()); text.setFont(new Font(DIALOG, PLAIN, 12)); text.setBackground(new Color(255, 255, 255, 0)); text.setEditable(false); text.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == ACTIVATED && isDesktopSupported()) { final Desktop desktop = getDesktop(); if (desktop.isSupported(BROWSE)) { try { desktop.browse(e.getURL().toURI()); } catch (IOException | URISyntaxException exception) { LOG.error("Could not open " + e.getURL() + " because of an exception.", exception); } } else { LOG.error("Could not open " + e.getURL() + " because browse is not supported by desktop."); } } repaint(); } }); text.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { repaint(); } @Override public void mousePressed(MouseEvent e) { repaint(); } @Override public void mouseReleased(MouseEvent e) { repaint(); } @Override public void mouseEntered(MouseEvent e) { repaint(); } @Override public void mouseExited(MouseEvent e) { repaint(); } }); add(text, new CC().spanX(2).growX().minWidth("10px")); }
From source file:org.languagetool.gui.ResultAreaHelper.java
@Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { URL url = e.getURL();/*from w w w .jav a 2 s . c o m*/ try { String uri = url.toURI().toString(); if (uri.startsWith(DEACTIVATE_URL) || uri.startsWith(REACTIVATE_URL)) { handleRuleLinkClick(uri); } else { Tools.openURL(url); } } catch (Exception ex) { throw new RuntimeException("Could not handle URL click: " + url, ex); } } }
From source file:org.languagetool.gui.Tools.java
static void addHyperlinkListener(JTextPane pane) { pane.addHyperlinkListener(new HyperlinkListener() { @Override/* w w w . j a v a 2 s. c o m*/ public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { Tools.openURL(e.getURL()); } } }); }