类javax.swing.event.HyperlinkEvent.EventType源码实例Demo

下面列出了怎么用javax.swing.event.HyperlinkEvent.EventType的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ramus   文件: Navigator.java
@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;
}
 
源代码2 项目: mars-sim   文件: WebViewHyperlinkListenerDemo.java
/**
 * 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));
	}
}
 
源代码3 项目: ganttproject   文件: UIFacadeImpl.java
@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);
          }
        }
      })));
}
 
源代码4 项目: ChatGameFontificator   文件: ControlWindow.java
/**
 * 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);
}
 
源代码5 项目: raccoon4   文件: OverviewBuilder.java
@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();
			}
		}
	}
}
 
源代码6 项目: chipster   文件: BrowsableHtmlPanel.java
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;
}
 
源代码7 项目: WorldPainter   文件: SimpleBrowser.java
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);
        }
    }
}
 
源代码8 项目: ghidra   文件: PluginManagerComponent.java
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;
}
 
源代码9 项目: ghidra   文件: DataTypesProvider.java
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"));
}
 
源代码10 项目: MakeLobbiesGreatAgain   文件: GithubPanel.java
/**
 * 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);
}
 
源代码11 项目: rapidminer-studio   文件: LinkButton.java
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);
}
 
源代码12 项目: rapidminer-studio   文件: AbstractLinkButton.java
/**
 * 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);
}
 
源代码13 项目: raccoon4   文件: FullAppDescriptionBuilder.java
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
	if (e.getEventType() == EventType.ACTIVATED) {
		if (ALLAPPS.equals(e.getDescription())) {
			globals.get(PlayManager.class).searchApps(current.getCreator());
		}
	}
}
 
源代码14 项目: SwingBox   文件: MouseController.java
@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);
        }
    }

}
 
源代码15 项目: WorldPainter   文件: AboutDialog.java
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);
        }
    }
}
 
源代码16 项目: WorldPainter   文件: SimpleBrowser.java
@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);
    }
}
 
源代码17 项目: netbeans   文件: DetailsPanel.java
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 );
}
 
源代码18 项目: netbeans   文件: TemplatesPanelGUI.java
public @Override void hyperlinkUpdate(HyperlinkEvent evt) {
    if (EventType.ACTIVATED == evt.getEventType() && evt.getURL() != null) {
        HtmlBrowser.URLDisplayer.getDefault().showURL(evt.getURL());
    }
}
 
源代码19 项目: code-generator   文件: HelpPanel.java
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>");
}
 
源代码20 项目: org.alloytools.alloy   文件: SimpleGUI.java
/**
 * 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;
}
 
源代码21 项目: procamcalib   文件: MainFrame.java
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);
}
 
源代码22 项目: procamtracker   文件: MainFrame.java
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);
}
 
源代码23 项目: SwingBox   文件: MouseController.java
@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);
        }
    }
}
 
 类所在包
 类方法
 同包方法