<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>


     1 import java.awt.*;
     2 import java.awt.event.ActionEvent;
     3 import java.awt.event.ActionListener;
     4 import javax.swing.*;
     5 public class Main extends JFrame implements ActionListener
     6 {
     7     private ImagePanel imgPane = null;
     8     private JScrollPane scrollPane = null;
     9     private JButton zoomin = null ;
    10     private JButton zoomout = null;
    11     public Main ()
    12     {
    13         super ("JScrollPane Demo");
    14         imgPane = new ImagePanel ("/1.jpg");
    15         imgPane.setPreferredSize (new Dimension (600400));
    16         scrollPane = new JScrollPane (imgPane);
    17         scrollPane.setVerticalScrollBarPolicy (JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    18         scrollPane.setHorizontalScrollBarPolicy (JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    19         zoomin = new JButton ("放大");
    20         zoomout = new JButton ("縮小");
    21         zoomin.setBounds (0,10,60,30);
    22         zoomout.setBounds (80,10,60,30);
    23         zoomin.addActionListener (this);
    24         zoomout.addActionListener (this);
    25         imgPane.add (zoomout,JLayeredPane.DRAG_LAYER);
    26         imgPane.add (zoomin,JLayeredPane.DRAG_LAYER);
    27         this.add (scrollPane);
    28         setSize (600400);
    29         setDefaultCloseOperation (EXIT_ON_CLOSE);
    30         setVisible (true);
    31     }
    32     public static void main ( String[] args )
    33     {
    34         new Main ();
    35     }
    36     public void actionPerformed ( ActionEvent e )
    37     {
    38         if ((JButton) (e.getSource ()) == zoomin)
    39         {
    40             imgPane.enlarge ();
    41             imgPane.setPreferredSize (imgPane.getPreferredSize ());
    42             scrollPane.validate ();
    43         }
    44         else if ((JButton) (e.getSource ()) == zoomout)
    45         {
    46             imgPane.ensmall ();
    47             imgPane.setPreferredSize (imgPane.getPreferredSize ());
    48             scrollPane.validate ();
    49         }
    50     }
    51 }
    52 
    53 class ImagePanel extends JLayeredPane
    54 {
    55     private Dimension theSize = new Dimension (600400);
    56     private ImageIcon img = null;
    57     public ImagePanel (String imgpath )
    58     {
    59         super ();
    60         setLayout (null);
    61         this.img = new ImageIcon (getClass ().getResource (imgpath));
    62     }
    63     public void paintComponent ( Graphics g )
    64     {
    65         g.clearRect (001024768);
    66         g.drawImage (img.getImage (), 00, theSize.width, theSize.height,null);
    67     }
    68     public void enlarge ( )
    69     {
    70         theSize.width = (theSize.width * 101/ 100;
    71         theSize.height = (theSize.height * 101/ 100;
    72         setSize (theSize);
    73     }
    74     public void ensmall ( )
    75     {
    76         theSize.width = (theSize.width * 100/ 101;
    77         theSize.height = (theSize.height * 100/ 101;
    78         setSize (theSize);
    79     }
    80     public Dimension getPreferredSize ( )
    81     {
    82         return this.theSize;
    83     }
    84 }
    85 
    posted on 2007-02-13 09:29 -274°C 閱讀(1647) 評論(0)  編輯  收藏 所屬分類: JAVA

    常用鏈接

    留言簿(21)

    隨筆分類(265)

    隨筆檔案(242)

    相冊

    JAVA網站

    關注的Blog

    搜索

    •  

    積分與排名

    • 積分 - 914354
    • 排名 - 40

    最新評論

    主站蜘蛛池模板: 亚洲AV无码之日韩精品| 女人18毛片免费观看| 国产精品亚洲不卡一区二区三区| 亚洲人成人无码.www石榴| 久久久www成人免费毛片| 亚洲精品午夜国产va久久| 妞干网免费观看视频| 亚洲AV日韩AV永久无码色欲| 日韩中文字幕在线免费观看| 亚洲乱理伦片在线观看中字| 日本一道一区二区免费看| 老司机精品视频免费| 国产亚洲精久久久久久无码77777| 老司机精品免费视频| 亚洲国产国产综合一区首页| 69视频在线观看免费| 久久亚洲最大成人网4438| 女人张开腿等男人桶免费视频| 亚洲AV无码国产一区二区三区| 四虎亚洲国产成人久久精品| 国产区在线免费观看| 亚洲国产精品久久久久婷婷老年| 8x成人永久免费视频| 亚洲AV成人影视在线观看| 免费观看四虎精品国产永久| 国产精品免费大片一区二区| 亚洲精品午夜无码电影网| 19禁啪啪无遮挡免费网站| 亚洲熟妇无码av另类vr影视| 免费A级毛片无码A| 人人玩人人添人人澡免费| 亚洲av极品无码专区在线观看| 国产成人免费A在线视频| 丰满人妻一区二区三区免费视频| 亚洲国语精品自产拍在线观看| 日韩av无码成人无码免费| 一级大黄美女免费播放| 亚洲美女激情视频| 免费大黄网站在线观看| 98精品全国免费观看视频| 色综合久久精品亚洲国产|