javax.swing.event.HyperlinkEvent.EventType Java Examples

The following examples show how to use javax.swing.event.HyperlinkEvent.EventType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UIFacadeImpl.java    From ganttproject with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void showNotificationDialog(NotificationChannel channel, String message) {
  String i18nPrefix = channel.name().toLowerCase() + ".channel.";
  getNotificationManager().addNotifications(
      channel,
      Collections.singletonList(new NotificationItem(i18n(i18nPrefix + "itemTitle"),
          GanttLanguage.getInstance().formatText(i18nPrefix + "itemBody", message), new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
          if (e.getEventType() != EventType.ACTIVATED) {
            return;
          }
          if ("localhost".equals(e.getURL().getHost()) && "/log".equals(e.getURL().getPath())) {
            onViewLog();
          } else {
            NotificationManager.DEFAULT_HYPERLINK_LISTENER.hyperlinkUpdate(e);
          }
        }
      })));
}
 
Example #2
Source File: SimpleBrowser.java    From WorldPainter with GNU General Public License v3.0 6 votes vote down vote up
private void jEditorPane1HyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) {//GEN-FIRST:event_jEditorPane1HyperlinkUpdate
    if (evt.getEventType() == EventType.ACTIVATED) {
        URL url = evt.getURL();
        try {
            jEditorPane1.setPage(url);
            if (historyPointer == (historySize - 1)) {
                // At the end of the history
                history.add(url.toExternalForm());
                historyPointer++;
                historySize++;
            } else {
                // Not at the end of the history; erase the tail end
                historyPointer++;
                history.set(historyPointer, url.toExternalForm());
                historySize = historyPointer + 1;
            }
            backAction.setEnabled(true);
            forwardAction.setEnabled(false);
        } catch (IOException e) {
            JOptionPane.showMessageDialog(this, "I/O error loading page " + url, "Error Loading Page", JOptionPane.ERROR_MESSAGE);
        }
    }
}
 
Example #3
Source File: BrowsableHtmlPanel.java    From chipster with MIT License 6 votes vote down vote up
public static JTextPane createHtmlPanel() {
	JTextPane htmlPanel = new JTextPane(); 
	htmlPanel.setEditable(false);
	htmlPanel.setContentType("text/html");
	htmlPanel.addHyperlinkListener(new HyperlinkListener() {
		public void hyperlinkUpdate(HyperlinkEvent e) {
			if (e.getEventType() == EventType.ACTIVATED) {
				try {
					BrowserLauncher.openURL(e.getURL().toString());            
				} catch (Exception ioe) {
					ioe.printStackTrace();
				}
			}
		}
	});
	
	return htmlPanel;
}
 
Example #4
Source File: OverviewBuilder.java    From raccoon4 with Apache License 2.0 6 votes vote down vote up
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
	if (INSTALL.equals(e.getDescription())) {
		if (e.getEventType() == EventType.ACTIVATED) {
			TransferWorker w = new FetchToolsWorker(globals);
			globals.get(TransferManager.class).schedule(globals, w,
					TransferManager.WAN);
		}
	}
	else {
		if (e.getEventType() == EventType.ACTIVATED) {
			try {
				BrowseAction.open(e.getURL().toURI());
			}
			catch (Exception e1) {
				e1.printStackTrace();
			}
		}
	}
}
 
Example #5
Source File: ControlWindow.java    From ChatGameFontificator with The Unlicense 6 votes vote down vote up
/**
 * Construct the popup dialog containing the About message
 */
private void constructAboutPopup()
{
    aboutPane = new JEditorPane("text/html", ABOUT_CONTENTS);
    aboutPane.addHyperlinkListener(new HyperlinkListener()
    {
        public void hyperlinkUpdate(HyperlinkEvent e)
        {
            if (EventType.ACTIVATED.equals(e.getEventType()))
            {
                if (Desktop.isDesktopSupported())
                {
                    try
                    {
                        Desktop.getDesktop().browse(URI.create("https://" + e.getDescription()));
                    }
                    catch (IOException e1)
                    {
                        e1.printStackTrace();
                    }
                }
            }
        }
    });
    aboutPane.setEditable(false);
}
 
Example #6
Source File: WebViewHyperlinkListenerDemo.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Visualizes the specified event's type and URL on the specified label.
 *
 * @param event
 *            the {@link HyperlinkEvent} to visualize
 * @param urlLabel
 *            the {@link Label} which will visualize the event
 */
private static void showEventOnLabel(HyperlinkEvent event, Label urlLabel) {
	if (event.getEventType() == EventType.ENTERED) {
		urlLabel.setTextFill(Color.BLACK);
		urlLabel.setText("ENTERED: " + event.getURL().toExternalForm());
		System.out.println("EVENT: " + WebViews.hyperlinkEventToString(event));
	} else if (event.getEventType() == EventType.EXITED) {
		urlLabel.setTextFill(Color.BLACK);
		urlLabel.setText("EXITED: " + event.getURL().toExternalForm());
		System.out.println("EVENT: " + WebViews.hyperlinkEventToString(event));
	} else if (event.getEventType() == EventType.ACTIVATED) {
		urlLabel.setText("ACTIVATED: " + event.getURL().toExternalForm());
		urlLabel.setTextFill(Color.RED);
		System.out.println("EVENT: " + WebViews.hyperlinkEventToString(event));
	}
}
 
Example #7
Source File: Navigator.java    From ramus with GNU General Public License v3.0 6 votes vote down vote up
@Override
public JComponent createComponent() {
    pane.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == EventType.ACTIVATED) {
                location = e.getURL().toExternalForm();
                openLocation();
            }
        }
    });

    pane.setEditable(false);

    scrollPane = new JScrollPane();
    scrollPane.setViewportView(this.pane);
    return scrollPane;
}
 
Example #8
Source File: GithubPanel.java    From MakeLobbiesGreatAgain with MIT License 5 votes vote down vote up
/**
 * Creates the new Panel and parses the supplied HTML.  <br>
 * <b> Supported Github Markdown: </b><i> Lists (unordered), Links, Images, Bold ('**' and '__'), Strikethrough, & Italics.  </i>
 *
 * @param currentVersion The version of the Jar currently running.
 */
public GithubPanel(double currentVersion) {
	this.version = currentVersion;

	setTitle("MLGA Update");
	try {
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		parseReleases();
	} catch (Exception e1) {
		e1.printStackTrace();
	}
	if (updates <= 0) {
		return;
	}
	ed = new JEditorPane("text/html", html);
	ed.setEditable(false);
	ed.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
	ed.setFont(new Font("Helvetica", 0, 12));

	ed.addHyperlinkListener(he -> {
		// Listen to link clicks and open them in the browser.
		if (he.getEventType() == EventType.ACTIVATED && Desktop.isDesktopSupported()) {
			try {
				Desktop.getDesktop().browse(he.getURL().toURI());
				System.exit(0);
			} catch (IOException | URISyntaxException e) {
				e.printStackTrace();
			}
		}
	});
	final JScrollPane scrollPane = new JScrollPane(ed);
	scrollPane.setPreferredSize(new Dimension(1100, 300));
	add(scrollPane);
	setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	pack();
	setLocationRelativeTo(null);
}
 
Example #9
Source File: DataTypesProvider.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void buildPreviewPane() {
	previewPane = new GHtmlTextPane();
	previewPane.setEditable(false);
	previewPane.setBorder(BorderFactory.createLoweredBevelBorder());

	// This listener responds to the user hovering/clicking the preview's hyperlinks
	previewPane.addHyperlinkListener(event -> {

		EventType type = event.getEventType();
		DataType dt = locateDataType(event);
		if (dt == null) {
			// shouldn't happen
			Msg.debug(this, "Could not find data type for " + event.getDescription());
			plugin.setStatus("Could not find data type for " + event.getDescription());
			return;
		}

		if (type == EventType.ACTIVATED) {
			setDataTypeSelected(dt);
		}
		else if (type == EventType.ENTERED) {
			//
			// The user hovered over the link--show something useful, like the path
			//
			JToolTip toolTip = new JToolTip();
			CategoryPath path = dt.getCategoryPath();
			toolTip.setTipText(path.toString());
			PopupWindow popup = new PopupWindow(toolTip);
			popup.setCloseWindowDelay(10000);
			popup.showPopup((MouseEvent) event.getInputEvent());
		}

	});

	previewScrollPane = new JScrollPane(previewPane);

	DockingWindowManager.getHelpService()
			.registerHelp(previewScrollPane,
				new HelpLocation("DataTypeManagerPlugin", "Preview_Window"));
}
 
Example #10
Source File: SimpleBrowser.java    From WorldPainter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
    if ((e.getEventType() == EventType.ACTIVATED) && (e.getURL().getProtocol().equals("action")) && (actionListener != null)) {
        ActionEvent event = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, e.getURL().getFile());
        actionListener.actionPerformed(event);
    }
}
 
Example #11
Source File: AboutDialog.java    From WorldPainter with GNU General Public License v3.0 5 votes vote down vote up
private void jTextPane1HyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) {//GEN-FIRST:event_jTextPane1HyperlinkUpdate
    if (evt.getEventType() == EventType.ACTIVATED) {
        URL url = evt.getURL();
        if (url.getProtocol().equals("action")) { // NOI18N
            String action = url.getPath().toLowerCase().trim();
            if (action.equals("/donate")) { // NOI18N
                donate();
            }
        } else {
            DesktopUtils.open(url);
        }
    }
}
 
Example #12
Source File: MouseController.java    From SwingBox with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void mouseClicked(MouseEvent e)
{
    JEditorPane editor = (JEditorPane) e.getSource();

    if (!editor.isEditable() && SwingUtilities.isLeftMouseButton(e))
    {
        Bias[] bias = new Bias[1];
        Point pt = new Point(e.getX(), e.getY());
        int pos = editor.getUI().viewToModel(editor, pt, bias);

        if (bias[0] == Position.Bias.Backward && pos > 0) pos--;

        //Point pt = new Point(e.getX(), e.getY());
        //int pos = editor.viewToModel(pt);
        // System.err.println("found position : " + pos);
        if (pos >= 0)
        {
            Element el = ((SwingBoxDocument) editor.getDocument()).getCharacterElement(pos);
            AttributeSet attr = el.getAttributes();
            Anchor anchor = (Anchor) attr.getAttribute(Constants.ATTRIBUTE_ANCHOR_REFERENCE);

            if (anchor != null && anchor.isActive())
                createHyperLinkEvent(editor, el, anchor, EventType.ACTIVATED);
        }
    }

}
 
Example #13
Source File: FullAppDescriptionBuilder.java    From raccoon4 with Apache License 2.0 5 votes vote down vote up
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
	if (e.getEventType() == EventType.ACTIVATED) {
		if (ALLAPPS.equals(e.getDescription())) {
			globals.get(PlayManager.class).searchApps(current.getCreator());
		}
	}
}
 
Example #14
Source File: PluginManagerComponent.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private HyperlinkComponent createConfigureHyperlink() {
	final HyperlinkComponent configureHyperlink =
			new HyperlinkComponent("<html> <a href=\"Configure\">Configure</a>");
		configureHyperlink.addHyperlinkListener("Configure", e -> {
			if (e.getEventType() == EventType.ACTIVATED) {
				managePlugins(PluginPackageComponent.this.pluginPackage);
			}
		});
		configureHyperlink.setBackground(BG);
		return configureHyperlink;
}
 
Example #15
Source File: AbstractLinkButton.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Creates the hyperlink listener for the given action.
 *
 * @param action
 */
private void makeHyperLinkListener(final Action action) {

	actionLinkListener = new HyperlinkListener() {

		@Override
		public void hyperlinkUpdate(HyperlinkEvent e) {
			if (e.getEventType() == EventType.ACTIVATED) {
				action.actionPerformed(
						new ActionEvent(AbstractLinkButton.this, ActionEvent.ACTION_PERFORMED, e.getDescription()));
			}
		}
	};
	addHyperlinkListener(actionLinkListener);
}
 
Example #16
Source File: LinkButton.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
private void makeHyperLinkListener(final Action action) {
	actionLinkListener = new HyperlinkListener() {

		@Override
		public void hyperlinkUpdate(HyperlinkEvent e) {
			if (e.getEventType() == EventType.ACTIVATED) {
				action.actionPerformed(
						new ActionEvent(LinkButton.this, ActionEvent.ACTION_PERFORMED, e.getDescription()));
			}
		}
	};
	addHyperlinkListener(actionLinkListener);
}
 
Example #17
Source File: HelpPanel.java    From code-generator with Apache License 2.0 4 votes vote down vote up
public HelpPanel() {
    infoPanel.setText(""
        + "**********************************************************************\n"
        + "** You can use the following predefined variables in templates\n"
        + "**********************************************************************\n"
        + "**\n"
        + "**  - ${clazz} the selected class\n"
        + "**      - ${name} the class name\n"
        + "**      - ${packageName} the package name\n"
        + "**      - ${fields} the class fields\n"
        + "**          - ${name} the field name\n"
        + "**          - ${type} the field type\n"
        + "**  - ${fn} String tools\n"
        + "**      - ${fn.pluralize()}    ----- ${fn.pluralize(\"Category\")} = Categories\n"
        + "**      - ${fn.singularize()}  ----- ${fn.singularize(\"Categories\")} = Category\n"
        + "**      - ${fn.decapitalize()} ----- ${fn.decapitalize(\"Category\")} = category\n"
        + "**      - ${fn.capitalize()}   ----- ${fn.capitalize(\"category\")} = Category\n"
        + "**      - ${fn.dcp()} decapitalize and pluralize ------- ${fn.dcp(\"Category\")} = categories\n"
        + "**  - ${BASE_PACKAGE} user selected base package\n"
        + "**  - ${USER} current user login name\n"
        + "**  - ${YEAR} current year\n"
        + "**  - ${MONTH} current month\n"
        + "**  - ${DAY} current day\n"
        + "**  - ${DATE} current system date\n"
        + "**  - ${TIME} current system time\n"
        + "**  - ${DATE_TIME} current system dateTime\n"
        + "**\n"
        + "**********************************************************************");

    supportPanel.addHyperlinkListener(e -> {
        if(e.getEventType() == EventType.ACTIVATED) {
            try {
                BrowserUtil.browse(e.getURL().toURI());
            } catch (URISyntaxException e1) {
                e1.printStackTrace();
            }
        }
    });
    supportPanel.setText(""
        + "1. <a href=\"http://velocity.apache.org/engine/1.7/user-guide.html\">Apache Velocity</a> is used<br/>"
        + "2. Source Code: <a href=\"https://github.com/heyuxian/code-generator\">github</a><br/>"
        + "3. Issues: <a href=\"https://github.com/heyuxian/code-generator/issues/new\">new issue</a>");
}
 
Example #18
Source File: TemplatesPanelGUI.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public @Override void hyperlinkUpdate(HyperlinkEvent evt) {
    if (EventType.ACTIVATED == evt.getEventType() && evt.getURL() != null) {
        HtmlBrowser.URLDisplayer.getDefault().showURL(evt.getURL());
    }
}
 
Example #19
Source File: MainFrame.java    From procamcalib with GNU General Public License v2.0 4 votes vote down vote up
private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
    String version = MainFrame.class.getPackage().getImplementationVersion();
    if (version == null) {
        version = "unknown";
    }
    JTextPane textPane = new JTextPane();
    textPane.setEditable(false);
    textPane.setContentType("text/html");
    textPane.setText(
            "<font face=sans-serif><strong><font size=+2>ProCamCalib</font></strong> version " + version + "<br>" +
            "Copyright (C) 2009-2014 Samuel Audet &lt;<a href=\"mailto:[email protected]%28Samuel%20Audet%29\">[email protected]</a>&gt;<br>" +
            "Web site: <a href=\"http://www.ok.ctrl.titech.ac.jp/~saudet/procamcalib/\">http://www.ok.ctrl.titech.ac.jp/~saudet/procamcalib/</a><br>" +
            "<br>" +
            "Licensed under the GNU General Public License version 2 (GPLv2).<br>" +
            "Please refer to LICENSE.txt or <a href=\"http://www.gnu.org/licenses/\">http://www.gnu.org/licenses/</a> for details."
            );
    textPane.setCaretPosition(0);
    Dimension dim = textPane.getPreferredSize();
    dim.height = dim.width*3/4;
    textPane.setPreferredSize(dim);

    textPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if(e.getEventType() == EventType.ACTIVATED) {
                try {
                    Desktop.getDesktop().browse(e.getURL().toURI());
                } catch(Exception ex) {
                    Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE,
                            "Could not launch browser to \"" + e.getURL()+ "\"", ex);
                }
            }
        }
    });

    // pass the scrollpane to the joptionpane.
    JDialog dialog = new JOptionPane(textPane, JOptionPane.PLAIN_MESSAGE).
            createDialog(this, "About");

    if ("com.sun.java.swing.plaf.gtk.GTKLookAndFeel".equals(UIManager.getLookAndFeel().getClass().getName())) {
        // under GTK, frameBackground is white, but rootPane color is OK...
        // but under Windows, the rootPane's color is funny...
        Color c = dialog.getRootPane().getBackground();
        textPane.setBackground(new Color(c.getRGB()));
    } else {
        Color frameBackground = this.getBackground();
        textPane.setBackground(frameBackground);
    }
    dialog.setVisible(true);
}
 
Example #20
Source File: MainFrame.java    From procamtracker with GNU General Public License v2.0 4 votes vote down vote up
private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
    String version = MainFrame.class.getPackage().getImplementationVersion();
    if (version == null) {
        version = "unknown";
    }
    JTextPane textPane = new JTextPane();
    textPane.setEditable(false);
    textPane.setContentType("text/html");
    textPane.setText(
            "<font face=sans-serif><strong><font size=+2>ProCamTracker</font></strong> version " + version + "<br>" +
            "Copyright (C) 2009-2014 Samuel Audet &lt;<a href=\"mailto:[email protected]%28Samuel%20Audet%29\">[email protected]</a>&gt;<br>" +
            "Web site: <a href=\"http://www.ok.ctrl.titech.ac.jp/~saudet/procamtracker/\">http://www.ok.ctrl.titech.ac.jp/~saudet/procamtracker/</a><br>" +
            "<br>" +
            "Licensed under the GNU General Public License version 2 (GPLv2).<br>" +
            "Please refer to LICENSE.txt or <a href=\"http://www.gnu.org/licenses/\">http://www.gnu.org/licenses/</a> for details."
            );
    textPane.setCaretPosition(0);
    Dimension dim = textPane.getPreferredSize();
    dim.height = dim.width*3/4;
    textPane.setPreferredSize(dim);

    textPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if(e.getEventType() == EventType.ACTIVATED) {
                try {
                    Desktop.getDesktop().browse(e.getURL().toURI());
                } catch(Exception ex) {
                    Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE,
                            "Could not launch browser to \"" + e.getURL()+ "\"", ex);
                }
            }
        }
    });

    // pass the scrollpane to the joptionpane.
    JDialog dialog = new JOptionPane(textPane, JOptionPane.PLAIN_MESSAGE).
            createDialog(this, "About");

    if ("com.sun.java.swing.plaf.gtk.GTKLookAndFeel".equals(UIManager.getLookAndFeel().getClass().getName())) {
        // under GTK, frameBackground is white, but rootPane color is OK...
        // but under Windows, the rootPane's color is funny...
        Color c = dialog.getRootPane().getBackground();
        textPane.setBackground(new Color(c.getRGB()));
    } else {
        Color frameBackground = this.getBackground();
        textPane.setBackground(frameBackground);
    }
    dialog.setVisible(true);
}
 
Example #21
Source File: MouseController.java    From SwingBox with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void mouseMoved(MouseEvent e)
{
    JEditorPane editor = (JEditorPane) e.getSource();

    if (!editor.isEditable())
    {
        Bias[] bias = new Bias[1];
        Point pt = new Point(e.getX(), e.getY());
        int pos = editor.getUI().viewToModel(editor, pt, bias);

        if (bias[0] == Position.Bias.Backward && pos > 0) pos--;

        if (pos >= 0 && (editor.getDocument() instanceof StyledDocument))
        {
            Element elem = ((StyledDocument) editor.getDocument()).getCharacterElement(pos);
            Object bb = elem.getAttributes().getAttribute(Constants.ATTRIBUTE_BOX_REFERENCE);
            Anchor anchor = (Anchor) elem.getAttributes().getAttribute(Constants.ATTRIBUTE_ANCHOR_REFERENCE);
            //System.out.println("Pos: " + pos);
            //System.out.println("Elem: " + elem.getAttributes().getAttribute(Constants.ATTRIBUTE_BOX_REFERENCE));
            //System.out.println("Anchor: " + anchor);

            if (elem != prevElem)
            {
                prevElem = elem;
                if (!anchor.isActive())
                {
                    if (bb != null && bb instanceof TextBox)
                        setCursor(editor, textCursor);
                    else
                        setCursor(editor, defaultCursor);
                }
            }
            
            if (anchor != prevAnchor)
            {
                if (prevAnchor == null)
                {
                    if (anchor.isActive())
                    {
                        createHyperLinkEvent(editor, elem, anchor, EventType.ENTERED);
                    }
                    prevAnchor = anchor;
                }
                else if (!prevAnchor.equalProperties(anchor.getProperties()))
                {
                    if (prevAnchor.isActive())
                    {
                        createHyperLinkEvent(editor, prevElem, prevAnchor, EventType.EXITED);
                    }

                    if (anchor.isActive())
                    {
                        createHyperLinkEvent(editor, elem, anchor, EventType.ENTERED);
                    }
                    prevAnchor = anchor;
                }

            }
        }
        else //nothing found
        {
            prevElem = null;
            if (prevAnchor != null && prevAnchor.isActive())
            {
                createHyperLinkEvent(editor, prevElem, prevAnchor, EventType.EXITED);
                prevAnchor = null;
            }   
            setCursor(editor, defaultCursor);
        }
    }
}
 
Example #22
Source File: DetailsPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public DetailsPanel() {
    initComponents2();
    HTMLEditorKit htmlkit = new HTMLEditorKitEx();
    // override the Swing default CSS to make the HTMLEditorKit use the
    // same font as the rest of the UI.
    
    // XXX the style sheet is shared by all HTMLEditorKits.  We must
    // detect if it has been tweaked by ourselves or someone else
    // (code completion javadoc popup for example) and avoid doing the
    // same thing again
    
    StyleSheet css = htmlkit.getStyleSheet();
    
    if (css.getStyleSheets() == null) {
        StyleSheet css2 = new StyleSheet();
        Font f = new JList().getFont();
        int size = f.getSize();
        css2.addRule(new StringBuffer("body { font-size: ").append(size) // NOI18N
                .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
        css2.addStyleSheet(css);
        htmlkit.setStyleSheet(css2);
    }
    
    setEditorKit(htmlkit);
    addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent hlevt) {
            if (EventType.ACTIVATED == hlevt.getEventType()) {
                if (hlevt.getURL () != null) {
                    Utilities.showURL(hlevt.getURL());
                }
            }
        }
    });
    setEditable(false);
    setPreferredSize(new Dimension(300, 80));
    RP.post(new Runnable() {

        @Override
        public void run() {
            getAccessibleContext ().setAccessibleName (
                    NbBundle.getMessage (DetailsPanel.class, "ACN_DetailsPanel")); // NOI18N
        }
    });

    putClientProperty( JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE );
}
 
Example #23
Source File: SimpleGUI.java    From org.alloytools.alloy with Apache License 2.0 4 votes vote down vote up
/**
 * This method displays the about box.
 */
public Runner doAbout() {
    if (wrap)
        return wrapMe();

    // Old about message
    // OurDialog.showmsg("About Alloy Analyzer " + Version.version(), OurUtil.loadIcon("images/logo.gif"), "Alloy Analyzer " + Version.version(), "Build date: " + " git: " + Version.commit, " ", "Lead developer: Felix Chang", "Engine developer: Emina Torlak", "Graphic design: Julie Pelaez", "Project lead: Daniel Jackson", " ", "Please post comments and questions to the Alloy Community Forum at http://alloy.mit.edu/", " ", "Thanks to: Ilya Shlyakhter, Manu Sridharan, Derek Rayside, Jonathan Edwards, Gregory Dennis,", "Robert Seater, Edmond Lau, Vincent Yeung, Sam Daitch, Andrew Yip, Jongmin Baek, Ning Song,", "Arturo Arizpe, Li-kuo (Brian) Lin, Joseph Cohen, Jesse Pavel, Ian Schechter, and Uriel Schafer.");

    HTMLEditorKit kit = new HTMLEditorKit();
    StyleSheet styleSheet = kit.getStyleSheet();
    styleSheet.addRule("body {color:#000; font-family:Verdana, Trebuchet MS,Geneva, sans-serif; font-size: 10px; margin: 4px; }");
    styleSheet.addRule("h1 {color: blue;}");
    styleSheet.addRule("h2 {color: #ff0000;}");
    styleSheet.addRule("pre {font : 10px monaco; color : black; background-color: #C0C0C0; padding: 4px; margin: 4px; }");
    styleSheet.addRule("th {text-align:left;}");

    JTextPane ta = new JTextPane();
    ta.setEditorKit(kit);
    ta.setContentType("text/html");
    ta.setBackground(null);
    ta.setBorder(null);
    ta.setFont(new JLabel().getFont());
    // @formatter:off
    ta.setText("<html><h1>Alloy Analyzer " + Version.getShortversion() + "</h1>"
    + "<br/>"
    + "<html>"
    + "<tr><th>Project Lead</th><td>Daniel Jackson</td></tr>"
    + "<tr><th>Chief Developer</th><td>Aleksandar Milicevic</td></tr>"
    + "<tr><th>Kodkod Engine</th><td>Emina Torlak</td></tr>"
    + "<tr><th>Open Source</th><td>Peter Kriens</td></tr>"
    + "</table><br/>"
    + "<p>For more information about Alloy, <a href='http://alloytools.org'>http://alloytools.org</a></p>"
    + "<p>Questions and comments about Alloy are welcome at the community forum:</p>"
    + "<p>Alloy Community Forum: <a href='https://groups.google.com/forum/#!forum/alloytools'>https://groups.google.com/forum/#!forum/alloytools</a></p>"
    + "<p>Alloy experts also respond to <a href='https://stackoverflow.com/questions/tagged/alloy'>https://stackoverflow.com</a> questions tagged <code>alloy</code>.</p>"
    + "<p>Major contributions to earlier versions of Alloy were made by: Felix Chang (v4);<br/>"
    + "Jonathan Edwards, Eunsuk Kang, Joe Near, Robert Seater, Derek Rayside, Greg Dennis,<br/>"
    + "Ilya Shlyakhter, Mana Taghdiri, Mandana Vaziri, Sarfraz Khurshid (v3); Manu Sridharan<br/>"
    + "(v2); Edmond Lau, Vincent Yeung, Sam Daitch, Andrew Yip, Jongmin Baek, Ning Song,<br/>"
    + "Arturo Arizpe, Li-kuo (Brian) Lin, Joseph Cohen, Jesse Pavel, Ian Schechter, Uriel<br/>"
    + "Schafer (v1).</p>"
    + "<p>The development of Alloy was funded by part by the National Science Foundation under<br/>"
    + "Grant Nos. 0325283, 0541183, 0438897 and 0707612; by the Air Force Research Laboratory<br/>"
    + "(AFRL/IF) and the Disruptive Technology Office (DTO) in the National Intelligence<br/>"
    + "Community Information Assurance Research (NICIAR) Program; and by the Nokia<br/>"
    + "Corporation as part of a collaboration between Nokia Research and MIT CSAIL.</p>"
    + "<br/><pre>"
    + "Build Date: " + Version.buildDate() + "<br/>"
    + "Git Commit: " + Version.commit
    + "</pre>");
    // @formatter:on
    ta.setEditable(false);
    ta.addHyperlinkListener((e) -> {
        if (e.getEventType() == EventType.ACTIVATED) {
            if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
                try {
                    Desktop.getDesktop().browse(e.getURL().toURI());
                } catch (IOException | URISyntaxException e1) {
                    // ignore
                }
            }
        }
    });
    OurDialog.showmsg("About Alloy Analyzer " + Version.version(), ta);

    return null;
}