AnchorAdapter.java
     1: //========================================================================================
     2: //  AnchorAdapter.java
     3: //    en:Anchor adapter -- It is a mouse adapter which passes the predetermined URI to a browser when it is clicked.
     4: //    ja:アンカーアダプタ -- クリックされたとき所定のURIをブラウザに渡すマウスアダプタです。
     5: //  Copyright (C) 2003-2019 Makoto Kamada
     6: //
     7: //  This file is part of the XEiJ (X68000 Emulator in Java).
     8: //  You can use, modify and redistribute the XEiJ if the conditions are met.
     9: //  Read the XEiJ License for more details.
    10: //  https://stdkmd.net/xeij/
    11: //========================================================================================
    12: 
    13: package xeij;
    14: 
    15: import java.awt.*;  //BasicStroke,BorderLayout,BoxLayout,Color,Component,Container,Cursor,Desktop,Dimension,Font,Frame,Graphics,Graphics2D,GraphicsDevice,GraphicsEnvironment,GridLayout,Image,Insets,Paint,Point,Rectangle,RenderingHints,Robot,Shape,Stroke,TexturePaint,Toolkit
    16: import java.awt.event.*;  //ActionEvent,ActionListener,ComponentAdapter,ComponentEvent,ComponentListener,FocusAdapter,FocusEvent,FocusListener,InputEvent,KeyAdapter,KeyEvent,KeyListener,MouseAdapter,MouseEvent,MouseListener,MouseMotionAdapter,MouseWheelEvent,WindowAdapter,WindowEvent,WindowListener,WindowStateListener
    17: import java.lang.*;  //Boolean,Character,Class,Comparable,Double,Exception,Float,IllegalArgumentException,Integer,Long,Math,Number,Object,Runnable,SecurityException,String,StringBuilder,System
    18: import java.net.*;  //MalformedURLException,URI,URL
    19: 
    20: public class AnchorAdapter extends MouseAdapter {
    21:   private URI uri;
    22:   public AnchorAdapter (String str) {
    23:     uri = null;
    24:     try {
    25:       uri = new URI (str);
    26:     } catch (Exception e) {
    27:     }
    28:   }
    29:   @Override public void mouseClicked (MouseEvent me) {
    30:     if (uri != null) {
    31:       try {
    32:         Desktop.getDesktop ().browse (uri);  //URIをブラウザに渡す
    33:       } catch (Exception e) {
    34:         //e.printStackTrace ();
    35:       }
    36:     }
    37:   }
    38: }  //class AnchorAdapter
    39: 
    40: 
    41: