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

📄 tools.java

📁 一个小公司要求给写的很简单的任务管理系统。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * @(#)Tools.java	1.44 06/08/29 *  * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. *  * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: *  * -Redistribution of source code must retain the above copyright notice, this *  list of conditions and the following disclaimer. *  * -Redistribution in binary form must reproduce the above copyright notice,  *  this list of conditions and the following disclaimer in the documentation *  and/or other materials provided with the distribution. *  * Neither the name of Sun Microsystems, Inc. or the names of contributors may  * be used to endorse or promote products derived from this software without  * specific prior written permission. *  * This software is provided "AS IS," without a warranty of any kind. ALL  * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST  * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,  * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY  * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,  * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. *  * You acknowledge that this software is not designed, licensed or intended * for use in the design, construction, operation or maintenance of any * nuclear facility. *//* * @(#)Tools.java	1.44 06/08/29 */package java2d;import static java.awt.Color.*;import java.awt.*;import java.awt.event.*;import java.awt.print.PrinterJob;import javax.print.attribute.*;import javax.swing.*;import javax.swing.event.*;import javax.swing.border.*;import java.net.URL;import java.text.DecimalFormat;/** * Tools to control individual demo graphic attributes.  Also, control for * start & stop on animated demos; control for cloning the demo; control for * printing the demo.  Expand and collapse the Tools panel with ToggleIcon. */public class Tools extends JPanel implements ActionListener, ChangeListener, MouseListener, Runnable {    private ImageIcon stopIcon, startIcon;    private Font font = new Font("serif", Font.PLAIN, 10);    private Color roColor = new Color(187, 213, 238);     private Surface surface;    private Thread thread;    private JPanel toolbarPanel;    private JPanel sliderPanel;    private JLabel label;    private ToggleIcon bumpyIcon, rolloverIcon;        private DecimalFormat decimalFormat = new DecimalFormat("000");     protected boolean focus;    public JToggleButton toggleB;    public JButton printB;    public JComboBox screenCombo;    public JToggleButton renderB, aliasB;     public JToggleButton textureB, compositeB;     public JButton startStopB;    public JButton cloneB;    public boolean issueRepaint = true;    public JToolBar toolbar;    public JSlider slider;    public boolean doSlider;    public boolean isExpanded;    public Tools(Surface surface) {        this.surface = surface;        setLayout(new BorderLayout());        stopIcon     = new  ImageIcon(DemoImages.getImage( "stop.gif",this));        startIcon    = new  ImageIcon(DemoImages.getImage("start.gif",this));        bumpyIcon    = new ToggleIcon(this, LIGHT_GRAY);        rolloverIcon = new ToggleIcon(this, roColor);        toggleB = new JToggleButton(bumpyIcon);        toggleB.addMouseListener(this);        isExpanded = false;        toggleB.addActionListener(this);        toggleB.setMargin(new Insets(0,0,-4,0));        toggleB.setBorderPainted(false);        toggleB.setFocusPainted(false);        toggleB.setContentAreaFilled(false);        toggleB.setRolloverIcon(rolloverIcon);        add("North", toggleB);        toolbar = new JToolBar();        toolbar.setPreferredSize(new Dimension(112, 26));        toolbar.setFloatable(false);        String s = surface.AntiAlias == RenderingHints.VALUE_ANTIALIAS_ON             ? "On" : "Off";        aliasB = addTool( "A", "Antialiasing " + s, this);        s = surface.Rendering == RenderingHints.VALUE_RENDER_SPEED            ? "Speed" : "Quality";        renderB = addTool("R", "Rendering " + s, this);        s = surface.texture != null ? "On" : "Off";        textureB = addTool("T", "Texture " + s, this);        s = surface.composite != null ? "On" : "Off";        compositeB = addTool("C", "Composite " + s, this);        Image printBImg = DemoImages.getImage("print.gif", this);        printB = addTool(printBImg, "Print the Surface", this);        if (surface instanceof AnimatingSurface) {            Image stopImg = DemoImages.getImage("stop.gif", this);            startStopB = addTool(stopImg, "Stop Animation", this);            toolbar.setPreferredSize(new Dimension(132, 26));        }        screenCombo = new JComboBox();        screenCombo.setPreferredSize(new Dimension(100, 18));        screenCombo.setFont(font);        for (String name : GlobalControls.screenNames) {            screenCombo.addItem(name);        }         screenCombo.addActionListener(this);        toolbarPanel = new JPanel(new FlowLayout(FlowLayout.CENTER,5,0));        toolbarPanel.setLocation(0,6);        toolbarPanel.setVisible(false);        toolbarPanel.add(toolbar);        toolbarPanel.add(screenCombo);        toolbarPanel.setBorder(new EtchedBorder());        add(toolbarPanel);        setPreferredSize(new Dimension(200,8));        if (surface instanceof AnimatingSurface) {            sliderPanel = new JPanel(new BorderLayout());            label = new JLabel(" Sleep = 030 ms");            label.setForeground(BLACK);            sliderPanel.add(label, BorderLayout.WEST);            slider = new JSlider(JSlider.HORIZONTAL, 0, 200, 30);            slider.addChangeListener(this);            sliderPanel.setBorder(new EtchedBorder());            sliderPanel.add(slider);            addMouseListener(new MouseAdapter() {                public void mouseClicked(MouseEvent e) {                   if (toolbarPanel.isVisible()) {                       invalidate();                       if ((doSlider = !doSlider)) {                           remove(toolbarPanel);                           add(sliderPanel);                       } else {                           remove(sliderPanel);                           add(toolbarPanel);                       }                       validate();                       repaint();                   }                }            });        }    }    public JButton addTool(Image img,                           String toolTip,                           ActionListener al) {        JButton b = new JButton(new ImageIcon(img)) {            Dimension prefSize = new Dimension(21, 22);            public Dimension getPreferredSize() {                return prefSize;            }            public Dimension getMaximumSize() {                return prefSize;            }            public Dimension getMinimumSize() {                return prefSize;            }        };        toolbar.add(b);        b.setFocusPainted(false);        b.setSelected(true);        b.setToolTipText(toolTip);        b.addActionListener(al);        return b;    }    public JToggleButton addTool(String name,                                 String toolTip,                                 ActionListener al) {        JToggleButton b = new JToggleButton(name) {            Dimension prefSize = new Dimension(21, 22);            public Dimension getPreferredSize() {                return prefSize;            }            public Dimension getMaximumSize() {                return prefSize;            }            public Dimension getMinimumSize() {                return prefSize;            }        };        toolbar.add(b);        b.setFocusPainted(false);        if (toolTip.equals("Rendering Quality") ||            toolTip.equals("Antialiasing On") ||            toolTip.equals("Texture On")  ||            toolTip.equals("Composite On")) {            b.setSelected(true);        } else {            b.setSelected(false);        }        b.setToolTipText(toolTip);        b.addActionListener(al);        return b;    }    public void actionPerformed(ActionEvent e) {

⌨️ 快捷键说明

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