⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewerwindow.java

📁 java写的图片浏览器,类似acds
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package org.net9.oops.jsee;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ViewerWindow extends JFrame
{
    class ToolBarButton extends JButton
    {
        public ToolBarButton(Action a)
        {
            super((Icon)a.getValue("SmallIcon"));
            String toolTip = (String)a.getValue("ShortDescription");
            if(toolTip == null)
                toolTip = (String)a.getValue("Name");
            if(toolTip != null)
                setToolTipText(toolTip);
            addActionListener(a);
        }
    }

    public class SlideShow extends Thread
    {
        public void run()
        {
            do
                try {
                    if(!OpenNextImage(foward))
                        stop();
                    Thread.sleep(minSlide);
                } catch (InterruptedException interruptedexception) { }
            while(true);
        }

        long minSlide;
        boolean foward;

        public SlideShow(long min, boolean f)
        {
            minSlide = min;
            foward = f;
        }
    }

    public ViewerWindow(ViewerScrollPane iScrollPane, Jsee dummy)
    {
        jToolBar1 = new JToolBar();
        TitleMenuBorder = 68;
        VerticalBorders = 16;
        ScrollBarSize = 12;
        StatusBarSize = 16;

        mainFrame = dummy;
        statusBar = new StatusBarPanel();
        pane = iScrollPane;
        try {
            jbInit();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

    private void jbInit() throws Exception
    {
        getContentPane().add(jToolBar1, "North");
        getContentPane().add(pane, "Center");
        getContentPane().add(statusBar, "South");
        setTitle("JCDSee Viewer");
        screenDim = Toolkit.getDefaultToolkit().getScreenSize();

        // doing the key scroll
        vbar = pane.getVerticalScrollBar();
        hbar = pane.getHorizontalScrollBar();
        
        menu = new JPopupMenu();
        JMenuItem NextImage_item = new JMenuItem("Next Image", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/nextImage.gif")));
        JMenuItem PreviousImage_item = new JMenuItem("Previous Image", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/previousImage.gif")));
        
        final JMenuItem ZoomIn_item = new JMenuItem("Zoom in", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/ZoomIn.gif")));
        final JMenuItem ZoomOut_item = new JMenuItem("Zoom out", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/ZoomOut.gif")));
        final JMenuItem Rotate_item = new JMenuItem("Rotate", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/rotate.gif")));
        final JMenuItem hflip_item = new JMenuItem("Horizontal flip", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/hflip.gif")));
        final JMenuItem vflip_item = new JMenuItem("Vertical flip", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/vflip.gif")));
        final JMenuItem Print_item = new JMenuItem("Print", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/print.gif")));
        
        JMenuItem FullFrame_item = new JMenuItem("Close");
        JMenuItem exit_item = new JMenuItem("Quit JCDSee");
        JCheckBoxMenuItem Fullscreen_item = new JCheckBoxMenuItem("Full Screen", false);
        slideshow_item = new JMenuItem("Run slide show", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/play.gif")));
        stop_slideshow_item = new JMenuItem("Stop slide show", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/stop.gif")));
        stop_slideshow_item.setEnabled(false);

        Action BrowseAction = new AbstractAction("Browse", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/browse.gif"))) {
            public void actionPerformed(ActionEvent event)
            {
                mainFrame.show();
                dispose();
            }
        };

        Action DeleteAction = new AbstractAction("Delete", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/delete.gif"))) {
            public void actionPerformed(ActionEvent event)
            {
/*
                mainFrame.FileListScrollPane.deleteSelectedFile();
                String iFileName = mainFrame.GetNextImage();
                if(iFileName != null) {
                    pane.loadNewImage(mainFrame.Load_Image(iFileName));
                    ReSizeAndCenter();
                } else {
                    mainFrame.show();
                    dispose();
                }
*/
            }
        };

        Action ZoomInAction = new AbstractAction("Zoom in", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/ZoomIn.gif"))) {
            public void actionPerformed(ActionEvent event)
            {
                boolean setEnable = pane.Zoom(true);
                zoomInButton.setEnabled(setEnable);
                ZoomIn_item.setEnabled(setEnable);
                zoomOutButton.setEnabled(true);
                ZoomOut_item.setEnabled(true);
            }
        };

        Action ZoomOutAction = new AbstractAction("Zoom out", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/ZoomOut.gif"))) {
            public void actionPerformed(ActionEvent event)
            {
                boolean setEnable = pane.Zoom(false);
                zoomOutButton.setEnabled(setEnable);
                ZoomOut_item.setEnabled(setEnable);
                zoomInButton.setEnabled(true);
                ZoomIn_item.setEnabled(true);
            }
        };

        Action NextAction = new AbstractAction("Next Image", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/nextImage.gif"))) {
            public void actionPerformed(ActionEvent event)
            {
                OpenNextImage(true);
                try {
                    Robot robot = new Robot();
                    robot.mouseMove(getButtonX(nextButton), getButtonY(nextButton));
                } catch(AWTException awtexception) {}
            }
        };

        Action PreviousAction = new AbstractAction("Previous Image", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/previousImage.gif"))) {
            public void actionPerformed(ActionEvent event)
            {
                OpenNextImage(false);
                try {
                    Robot robot = new Robot();
                    robot.mouseMove(getButtonX(previousButton), getButtonY(nextButton));
                } catch(AWTException awtexception) { }
            }
        };

        Action RotateAction = new AbstractAction("Rotate", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/rotate.gif"))) {
            public void actionPerformed(ActionEvent event)
            {
                pane.RotateImage();
            }
        };
        
        Action HFlipAction = new AbstractAction("Rotate", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/hflip.gif"))) {
            public void actionPerformed(ActionEvent event)
            {
                pane.FlipImage(false);
            }
        };
        
        Action VFlipAction = new AbstractAction("Rotate", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/vflip.gif"))) {
            public void actionPerformed(ActionEvent event)
            {
                pane.FlipImage(true);
            }
        };

        Action PrintAction = new AbstractAction("Print", new ImageIcon(getClass().getResource("/org/net9/oops/jsee/image/print.gif"))) {
            public void actionPerformed(ActionEvent event)
            {
                pane.DoPrint();
            }
        };

        nextButton = new ToolBarButton(NextAction);
        previousButton = new ToolBarButton(PreviousAction);
        deleteButton = new ToolBarButton(DeleteAction);
        browseButton = new ToolBarButton(BrowseAction);
        zoomInButton = new ToolBarButton(ZoomInAction);
        zoomOutButton = new ToolBarButton(ZoomOutAction);
        rotateButton = new ToolBarButton(RotateAction);
        hflipButton = new ToolBarButton(HFlipAction);
        vflipButton = new ToolBarButton(VFlipAction);
        printButton = new ToolBarButton(PrintAction);
        jToolBar1.add(browseButton);
        jToolBar1.add(previousButton);
        jToolBar1.add(nextButton);
        jToolBar1.add(zoomOutButton);
        jToolBar1.add(zoomInButton);
        jToolBar1.add(rotateButton);
        jToolBar1.add(hflipButton);
        jToolBar1.add(vflipButton);
        jToolBar1.add(printButton);
        jToolBar1.add(deleteButton);

        ZoomIn_item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event)
            {
                boolean setEnable = pane.Zoom(true);
                zoomInButton.setEnabled(setEnable);
                ZoomIn_item.setEnabled(setEnable);
                ZoomOut_item.setEnabled(true);
                zoomOutButton.setEnabled(true);
            }
        });

        ZoomOut_item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event)
            {
                boolean setEnable = pane.Zoom(false);
                zoomOutButton.setEnabled(setEnable);
                ZoomOut_item.setEnabled(setEnable);
                zoomInButton.setEnabled(true);
                ZoomIn_item.setEnabled(true);
            }
        });

        Print_item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event)
            {
                pane.DoPrint();                
            }
        });

        exit_item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event)
            {
                mainFrame.Quit();
            }
        });

        PreviousImage_item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event)
            {
                OpenNextImage(false);
            }
        });

        NextImage_item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event)
            {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -