Java 类javax.swing.event.HyperlinkEvent.EventType 实例源码
项目: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;
}
项目: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));
}
}
项目:zenjcl
文件:ScheduleEditor.java
public void hyperlinkUpdate(HyperlinkEvent e) {
if (!(e.getSource() instanceof JComponent)) {
return;
}
if (e.getEventType() != EventType.ACTIVATED) {
return;
}
String[] action = e.getDescription().split(":");
if (action.length != 2) {
return;
}
if (action[0].equals("add")) {
this.muiRepeatingRule.setVisible(true);
this.muiSimpleRule.setVisible(true);
openPopup(popAddRule, (JComponent) e.getSource(), action[1]);
}
if (action[0].equals("remove")) {
openPopup(popRemoveRule, (JComponent) e.getSource(), action[1]);
}
if (action[0].equals("edit")) {
buildEditMenu((JComponent) e.getSource(), action[1]);
}
}
项目:swingbox-javahelp-viewer
文件:MouseController.java
@Override
public void mouseClicked(MouseEvent e)
{
JEditorPane editor = (JEditorPane) e.getSource();
if (!editor.isEditable() && SwingUtilities.isLeftMouseButton(e))
{
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);
}
}
}
项目:google-cloud-intellij
文件:AppEngineApplicationInfoPanel.java
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == EventType.ACTIVATED) {
// construct and show the application creation dialog
AppEngineApplicationCreateDialog applicationDialog =
new AppEngineApplicationCreateDialog(
AppEngineApplicationInfoPanel.this, projectId, credential);
DialogManager.show(applicationDialog);
applicationDialog.getDisposable().dispose();
// if an application was created, update the region field display
if (applicationDialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
refresh(projectId, credential);
}
}
}
项目: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);
}
项目: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();
}
}
}
}
项目:Java-Checker
文件:JavaCheckerReporter.java
private static void displayErrorPopup(String title, String contents){
JEditorPane pane = new JEditorPane("text/html", "<html><body style='font-family:Dialog;font-size:12;font-weight:bold'>"+contents+"</body></html>");
pane.setBackground(new JLabel().getBackground());
pane.setEditable(false);
pane.addHyperlinkListener(new HyperlinkListener(){
@Override
public void hyperlinkUpdate(HyperlinkEvent e){
if (e.getEventType() == EventType.ACTIVATED){
try{
if (Desktop.isDesktopSupported())Desktop.getDesktop().browse(e.getURL().toURI());
}catch(Exception ex){
ex.printStackTrace();
}
}
}
});
JOptionPane.showMessageDialog(null, pane, title, JOptionPane.ERROR_MESSAGE);
}
项目:svarog
文件:HelpDialog.java
/**
* Initializes this panel:
* <ul>
* <li>sets the icon and the title,</li>
* <li>adds the {@code HyperlinkListener} to the {@link #getHelpPane()
* help panel} (the listener {@link #setPage(URL) changes} the page when
* the link is clicked.</li>
* </ul>
*/
@Override
protected void initialize() {
setTitle(_("Help for signalml"));
setIconImage(IconUtils.loadClassPathImage("org/signalml/app/icon/help.png"));
super.initialize();
getHelpPane().addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == EventType.ACTIVATED) {
logger.debug("link activated: [" + e.getURL() + "]");
try {
setPage(e.getURL());
} catch (SignalMLException ex) {
logger.error("Failed to display URL [" + e.getURL().toString() + "]");
}
}
}
});
}
项目:rapidminer-5
文件:LinkButton.java
public LinkButton(final Action action, boolean addLinkTag) {
super("text/html", makeHTML(action, addLinkTag));
setToolTipText((String) action.getValue(Action.SHORT_DESCRIPTION));
installDefaultStylesheet();
setEditable(false);
setOpaque(false);
addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == EventType.ACTIVATED) {
action.actionPerformed(new ActionEvent(LinkButton.this, ActionEvent.ACTION_PERFORMED,
e.getDescription()));
//(String)action.getValue(Action.ACTION_COMMAND_KEY)));
}
}
});
}
项目:morenaments-euc
文件:Documentation.java
public void hyperlinkUpdate(HyperlinkEvent evnt) {
/* 64 */ if (evnt.getEventType() != HyperlinkEvent.EventType.ACTIVATED)
/* 65 */ return;
/* */ try
/* */ {
/* 68 */ Object o = evnt.getSource();
/* 69 */ if (o instanceof JEditorPane) {
/* 70 */ ((JEditorPane)o).setPage(evnt.getURL());
/* */ }
/* */ else
/* 73 */ System.err.println("Not an JEditorPane: " + o);
/* */ }
/* */ catch (IOException e) {
/* 76 */ System.err.println("Could not load " + evnt.getURL() + ": " + e);
/* */ }
/* */ }
项目: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;
}
项目: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);
}
}
}
项目:rapidminer
文件: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);
}
项目:rapidminer
文件: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);
}
项目:rapidminer
文件:LicenseDialog.java
public LicenseDialog(Object... arguments) {
super(ApplicationFrame.getApplicationFrame(), "license_dialog", ModalityType.APPLICATION_MODAL, arguments);
this.addWindowListener(this.windowListener);
ProductConstraintManager.INSTANCE.registerLicenseManagerListener(this.licenseManagerListener);
this.activeLicenses = LicenseManagerRegistry.INSTANCE.get().getAllActiveLicenses();
this.setResizable(false);
this.setLayout(new BorderLayout());
this.contentPanel = new LicenseContentPanel(this.activeLicenses);
this.contentPanel.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent event) {
if(event.getEventType() == EventType.ACTIVATED && event.getURL() != null) {
try {
RMUrlHandler.browse(event.getURL().toURI());
} catch (IOException | URISyntaxException var3) {
LicenseDialog.LOGGER.log(Level.SEVERE, "Failed to parse URL for My Account page.", var3);
}
}
}
});
final JScrollPane scrollPane = new JScrollPane();
scrollPane.setPreferredSize(this.contentPanel.getPreferredSize());
scrollPane.getViewport().add(this.contentPanel);
this.add(scrollPane, "Center");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
scrollPane.getVerticalScrollBar().setValue(0);
}
});
JPanel buttonPanel = this.makeButtonPanel();
buttonPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.DARK_GRAY));
this.add(buttonPanel, "South");
this.pack();
this.setLocationRelativeTo(RapidMinerGUI.getMainFrame());
}
项目: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);
}
项目: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);
}
项目: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);
}
项目:RealmSpeak
文件:ScrollingText.java
private void fireHyperlinkUpdate(String link) {
if (listeners==null) return;
try {
URL url = new URL(link);
HyperlinkEvent ev = new HyperlinkEvent(this,EventType.ACTIVATED,url);
for (HyperlinkListener listener:listeners) {
listener.hyperlinkUpdate(ev);
}
}
catch(MalformedURLException ex) {
System.err.println("Malformed URL: "+link);
}
}
项目:google-cloud-intellij
文件:ProjectSelector.java
private void createUIComponents() {
projectNameLabel = new HyperlinkLabelWithStateAccess();
projectNameLabel.setHyperlinkText(
GctBundle.getString("cloud.project.selector.no.selected.project"));
projectNameLabel.addHyperlinkListener(
(event) -> {
if (event.getEventType() == EventType.ACTIVATED) {
handleOpenProjectSelectionDialog();
}
});
projectAccountSeparatorLabel = new JBLabel("/");
projectAccountSeparatorLabel.setVisible(false /* only visible when project is selected. */);
accountInfoLabel = new HyperlinkLabelWithStateAccess();
accountInfoLabel.addHyperlinkListener(
(event) -> {
if (event.getEventType() == EventType.ACTIVATED) {
handleOpenProjectSelectionDialog();
}
});
hyperlinksPanel = new JPanel();
hyperlinksPanel.setBorder(UIManager.getBorder("TextField.border"));
hyperlinksPanel.setLayout(new BoxLayout(hyperlinksPanel, BoxLayout.X_AXIS));
browseButton = new FixedSizeButton(hyperlinksPanel);
browseButton.addActionListener((actionEvent) -> handleOpenProjectSelectionDialog());
browseButton.setFocusable(true);
browseButton.setToolTipText(GctBundle.getString("cloud.project.selector.open.dialog.tooltip"));
}
项目: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());
}
}
}
项目:ireport-fork
文件:LogTextArea.java
/** Creates new form LogTextArea */
public LogTextArea(String title) {
initComponents();
outputBuffer = new StringBuffer();
this.setTitle(title);
this.jEditorPaneOutput.setContentType("text/html");
try {
maxlines = Integer.parseInt( System.getProperty("ireport.maxoutputlines", "5000"));
} catch (Exception ex)
{
maxlines = 5000;
}
clearConsole();
jEditorPaneOutput.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == EventType.ACTIVATED)
{
if (e.getURL().getFile().endsWith(".jrxml"))
{
String fileName = e.getURL().getFile();
File f = new File(fileName);
if (f.exists())
{
Misc.openFile(f);
}
}
}
}
});
}
项目:hexeditor
文件:jEP.java
public void hyperlinkUpdate(HyperlinkEvent var1) {
if(var1.getEventType() == EventType.ACTIVATED) {
UI.browse = var1.getURL().toString();
this.Browser2(var1.getURL());
}
}
项目:demo-decorator-java-8
文件:Demo.java
@Override
public void hyperlinkUpdate(HyperlinkEvent event) {
if (event.getEventType() == EventType.ENTERED)
logUrl(event.getURL());
super.hyperlinkUpdate(event);
}
项目:demo-decorator-java-8
文件:Demo.java
@Override
public void hyperlinkUpdate(HyperlinkEvent event) {
if (event.getEventType() == EventType.ACTIVATED)
highlightBackground();
super.hyperlinkUpdate(event);
}
项目:demo-decorator-java-8
文件:AbstractOnHoverHyperlinkListenerDecorator.java
@Override
public final void hyperlinkUpdate(HyperlinkEvent event) {
if (event.getEventType() == EventType.ENTERED)
onEnter(event);
super.hyperlinkUpdate(event);
if (event.getEventType() == EventType.EXITED)
onExit(event);
}
项目:cn1
文件:HTMLFrameHyperlinkEventTest.java
public void testHTMLFrameHyperlinkEventObjectEventTypeURLElementString() throws Exception {
final Object source = new Object();
final EventType type = EventType.ENTERED;
final URL url = new URL("file:///");
final Element element = new HTMLDocument().getDefaultRootElement();
final String targetFrame = "targetFrame";
HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(source, type, url, element, targetFrame);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertSame(url, event.getURL());
assertSame(element, event.getSourceElement());
assertNull(event.getDescription());
assertSame(targetFrame, event.getTarget());
event = new HTMLFrameHyperlinkEvent(source, type, null, (Element)null, null);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertNull(event.getURL());
assertNull(event.getSourceElement());
assertNull(event.getDescription());
assertNull(event.getTarget());
new NullPointerCase() {
public void exceptionalAction() throws Exception {
new HTMLFrameHyperlinkEvent(null, type, null, (Element)null, null);
}
};
}
项目:cn1
文件:HTMLFrameHyperlinkEventTest.java
public void testHTMLFrameHyperlinkEventObjectEventTypeURLString() throws Exception {
final Object source = new Object();
final EventType type = EventType.ENTERED;
final URL url = new URL("file:///");
final String targetFrame = "targetFrame";
HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(source, type, url, targetFrame);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertSame(url, event.getURL());
assertNull(event.getSourceElement());
assertNull(event.getDescription());
assertSame(targetFrame, event.getTarget());
event = new HTMLFrameHyperlinkEvent(source, type, null, null);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertNull(event.getURL());
assertNull(event.getSourceElement());
assertNull(event.getDescription());
assertNull(event.getTarget());
new NullPointerCase() {
public void exceptionalAction() throws Exception {
new HTMLFrameHyperlinkEvent(null, type, null, null);
}
};
}
项目:cn1
文件:HTMLFrameHyperlinkEventTest.java
public void testHTMLFrameHyperlinkEventObjectEventTypeURLStringString() throws Exception {
final Object source = new Object();
final EventType type = EventType.ENTERED;
final URL url = new URL("file:///");
final String targetFrame = "targetFrame";
final String descr = "description";
HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(source, type, url, descr, targetFrame);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertSame(url, event.getURL());
assertNull(event.getSourceElement());
assertSame(targetFrame, event.getTarget());
assertSame(descr, event.getDescription());
event = new HTMLFrameHyperlinkEvent(source, type, null, (String)null, (String)null);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertNull(event.getURL());
assertNull(event.getSourceElement());
assertNull(event.getDescription());
assertNull(event.getTarget());
new NullPointerCase() {
public void exceptionalAction() throws Exception {
new HTMLFrameHyperlinkEvent(null, type, null, (String)null, (String)null);
}
};
}
项目:cn1
文件:HTMLFrameHyperlinkEventTest.java
public void testHTMLFrameHyperlinkEventObjectEventTypeURLStringElementString() throws Exception {
final Object source = new Object();
final EventType type = EventType.ENTERED;
final URL url = new URL("file:///");
final Element element = new HTMLDocument().getDefaultRootElement();
final String targetFrame = "targetFrame";
final String descr = "description";
HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(source, type, url, descr, element, targetFrame);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertSame(url, event.getURL());
assertSame(element, event.getSourceElement());
assertSame(descr, event.getDescription());
assertSame(targetFrame, event.getTarget());
event = new HTMLFrameHyperlinkEvent(source, type, null, null, (Element)null, null);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertNull(event.getURL());
assertNull(event.getSourceElement());
assertNull(event.getDescription());
assertNull(event.getTarget());
new NullPointerCase() {
public void exceptionalAction() throws Exception {
new HTMLFrameHyperlinkEvent(null, type, null, null, (Element)null, null);
}
};
}
项目:VCHILL
文件:DialogUtil.java
/**
* Does the actual construction work
*/
private void init(final Component parent, final URL source, final String title, final int type) throws IOException {
this.text.setContentType("text/html");
this.text.setEditable(false);
this.root.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
this.pane = new JOptionPane(this.root, type, JOptionPane.DEFAULT_OPTION);
pane.setWantsInput(false);
this.dialog = pane.createDialog(parent, title);
this.text.setPage(source); //throws IOException
this.text.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(final HyperlinkEvent he) {
if (he.getEventType() == EventType.ACTIVATED) {
HTMLDialog d = new HTMLDialog(parent, he.getURL(), title, type);
d.setModal(modal);
d.setAlwaysOnTop(alwaysOnTop);
d.setVisible(true);
}
}
});
this.root.add(new JScrollPane(text));
this.root.setLayout(new BoxLayout(root, BoxLayout.Y_AXIS));
this.setPreferredSize(new Dimension(600, 450));
this.setModal(true);
this.setAlwaysOnTop(true);
this.dialog.setResizable(true);
this.dialog.setLocationRelativeTo(parent); //centered
}
项目:K-scope
文件:AboutDialog.java
/**
* 説明文のリンクタグクリックイベント
*/
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == EventType.ACTIVATED) { //クリックされた時
URL url = e.getURL();
//デフォルトのブラウザーを使ってリンク先を表示
Desktop dp = Desktop.getDesktop();
try {
dp.browse(url.toURI());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
项目: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);
}
}
}
项目:freeVM
文件:HTMLFrameHyperlinkEventTest.java
public void testHTMLFrameHyperlinkEventObjectEventTypeURLElementString() throws Exception {
final Object source = new Object();
final EventType type = EventType.ENTERED;
final URL url = new URL("file:///");
final Element element = new HTMLDocument().getDefaultRootElement();
final String targetFrame = "targetFrame";
HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(source, type, url, element, targetFrame);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertSame(url, event.getURL());
assertSame(element, event.getSourceElement());
assertNull(event.getDescription());
assertSame(targetFrame, event.getTarget());
event = new HTMLFrameHyperlinkEvent(source, type, null, (Element)null, null);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertNull(event.getURL());
assertNull(event.getSourceElement());
assertNull(event.getDescription());
assertNull(event.getTarget());
new NullPointerCase() {
public void exceptionalAction() throws Exception {
new HTMLFrameHyperlinkEvent(null, type, null, (Element)null, null);
}
};
}
项目:freeVM
文件:HTMLFrameHyperlinkEventTest.java
public void testHTMLFrameHyperlinkEventObjectEventTypeURLString() throws Exception {
final Object source = new Object();
final EventType type = EventType.ENTERED;
final URL url = new URL("file:///");
final String targetFrame = "targetFrame";
HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(source, type, url, targetFrame);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertSame(url, event.getURL());
assertNull(event.getSourceElement());
assertNull(event.getDescription());
assertSame(targetFrame, event.getTarget());
event = new HTMLFrameHyperlinkEvent(source, type, null, null);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertNull(event.getURL());
assertNull(event.getSourceElement());
assertNull(event.getDescription());
assertNull(event.getTarget());
new NullPointerCase() {
public void exceptionalAction() throws Exception {
new HTMLFrameHyperlinkEvent(null, type, null, null);
}
};
}
项目:freeVM
文件:HTMLFrameHyperlinkEventTest.java
public void testHTMLFrameHyperlinkEventObjectEventTypeURLStringString() throws Exception {
final Object source = new Object();
final EventType type = EventType.ENTERED;
final URL url = new URL("file:///");
final String targetFrame = "targetFrame";
final String descr = "description";
HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(source, type, url, descr, targetFrame);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertSame(url, event.getURL());
assertNull(event.getSourceElement());
assertSame(targetFrame, event.getTarget());
assertSame(descr, event.getDescription());
event = new HTMLFrameHyperlinkEvent(source, type, null, (String)null, (String)null);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertNull(event.getURL());
assertNull(event.getSourceElement());
assertNull(event.getDescription());
assertNull(event.getTarget());
new NullPointerCase() {
public void exceptionalAction() throws Exception {
new HTMLFrameHyperlinkEvent(null, type, null, (String)null, (String)null);
}
};
}
项目:freeVM
文件:HTMLFrameHyperlinkEventTest.java
public void testHTMLFrameHyperlinkEventObjectEventTypeURLStringElementString() throws Exception {
final Object source = new Object();
final EventType type = EventType.ENTERED;
final URL url = new URL("file:///");
final Element element = new HTMLDocument().getDefaultRootElement();
final String targetFrame = "targetFrame";
final String descr = "description";
HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(source, type, url, descr, element, targetFrame);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertSame(url, event.getURL());
assertSame(element, event.getSourceElement());
assertSame(descr, event.getDescription());
assertSame(targetFrame, event.getTarget());
event = new HTMLFrameHyperlinkEvent(source, type, null, null, (Element)null, null);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertNull(event.getURL());
assertNull(event.getSourceElement());
assertNull(event.getDescription());
assertNull(event.getTarget());
new NullPointerCase() {
public void exceptionalAction() throws Exception {
new HTMLFrameHyperlinkEvent(null, type, null, null, (Element)null, null);
}
};
}
项目:freeVM
文件:HTMLFrameHyperlinkEventTest.java
public void testHTMLFrameHyperlinkEventObjectEventTypeURLElementString() throws Exception {
final Object source = new Object();
final EventType type = EventType.ENTERED;
final URL url = new URL("file:///");
final Element element = new HTMLDocument().getDefaultRootElement();
final String targetFrame = "targetFrame";
HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(source, type, url, element, targetFrame);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertSame(url, event.getURL());
assertSame(element, event.getSourceElement());
assertNull(event.getDescription());
assertSame(targetFrame, event.getTarget());
event = new HTMLFrameHyperlinkEvent(source, type, null, (Element)null, null);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertNull(event.getURL());
assertNull(event.getSourceElement());
assertNull(event.getDescription());
assertNull(event.getTarget());
new NullPointerCase() {
public void exceptionalAction() throws Exception {
new HTMLFrameHyperlinkEvent(null, type, null, (Element)null, null);
}
};
}
项目:freeVM
文件:HTMLFrameHyperlinkEventTest.java
public void testHTMLFrameHyperlinkEventObjectEventTypeURLString() throws Exception {
final Object source = new Object();
final EventType type = EventType.ENTERED;
final URL url = new URL("file:///");
final String targetFrame = "targetFrame";
HTMLFrameHyperlinkEvent event = new HTMLFrameHyperlinkEvent(source, type, url, targetFrame);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertSame(url, event.getURL());
assertNull(event.getSourceElement());
assertNull(event.getDescription());
assertSame(targetFrame, event.getTarget());
event = new HTMLFrameHyperlinkEvent(source, type, null, null);
assertSame(source, event.getSource());
assertSame(type, event.getEventType());
assertNull(event.getURL());
assertNull(event.getSourceElement());
assertNull(event.getDescription());
assertNull(event.getTarget());
new NullPointerCase() {
public void exceptionalAction() throws Exception {
new HTMLFrameHyperlinkEvent(null, type, null, null);
}
};
}