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

📄 macossettingsdialog.java

📁 Java版本的屏幕截图 工具,可以自己放到系统托盘使用
💻 JAVA
字号:
/* * Copyright (c) 2002-2008 TeamDev Ltd. All rights reserved. * * Use is subject to license terms. * * The complete licence text can be found at * http://www.teamdev.com/winpack/license.jsf */package teamdev.jxcapture.samples.demo;import javax.swing.*;import javax.swing.event.ChangeEvent;import javax.swing.event.ChangeListener;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;/** * @author slavapak */public class MacOSSettingsDialog extends SettingsDialog {    public MacOSSettingsDialog() {        delay.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                updateDelayArea();                settings.setDelayBeforeCapture(MacOSSettingsDialog.this.delay.isSelected());                settings.setDelayTime(((Integer) delayTime.getValue()).intValue() * 1000);                System.out.println("Delay before capture: " + settings.isDelayBeforeCapture());                System.out.println("Delay time = " + settings.getDelayTime());            }        });        delayTime.addChangeListener(new ChangeListener() {            public void stateChanged(ChangeEvent e) {                settings.setDelayTime(((Integer) delayTime.getValue()).intValue() * 1000);                System.out.println("Delay time = " + settings.getDelayTime());            }        });        templateName.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                String fileNameTemplate = templateName.getText();                if (fileNameTemplate.length() == 0) {                    String title = resource.getString("SettingsDialog.Error.EmptyFileName.Title");                    String message = resource.getString("SettingsDialog.Error.EmptyFileName.Message");                    JOptionPane.showMessageDialog(MacOSSettingsDialog.this, message, title, JOptionPane.ERROR_MESSAGE);                    return;                }                settings.setTemplateFileName(fileNameTemplate);                System.out.println("Template file name = " + settings.getTemplateFileName());            }        });        templateNumber.addChangeListener(new ChangeListener() {            public void stateChanged(ChangeEvent e) {                settings.setTemplateNumber(((Integer) templateNumber.getValue()).intValue());                System.out.println("Teplate number to strart from = " + settings. getTemplateNumber());            }        });        autoSave.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                updateAutoSave();            }        });        outputFolder.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                String outputPath = getOutputFolder();                if (outputPath == null) return;                settings.setOutputFolder(outputPath);                System.out.println("Output folder = " + settings.getOutputFolder());            }        });        chooseFolder.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                JFileChooser chooser = new JFileChooser();                chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);                int result = chooser.showOpenDialog(MacOSSettingsDialog.this);                if (result == JFileChooser.APPROVE_OPTION) {                    String absolutePath = chooser.getSelectedFile().getAbsolutePath();                    outputFolder.setText(absolutePath);                }            }        });        formats.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                settings.setImageFormatIndex(formats.getSelectedIndex());                System.out.println("Image format = " + settings.getImageFormatIndex());            }        });    }    protected JPanel createContentPane() {        JPanel mainPane = new JPanel(new GridBagLayout());        mainPane.add(createCapturePane(), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,                GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));        mainPane.add(new JSeparator(JSeparator.HORIZONTAL), new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0,                GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));        mainPane.add(createFilePane(), new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,                GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));        return mainPane;    }    protected JPanel createCapturePane() {        return createDelayTimePane();    }    protected JPanel createFilePane() {        JPanel contentPane = new JPanel(new GridBagLayout());        templateName = new JTextField(settings.getTemplateFileName(), 15);        int value = settings.getTemplateNumber();        SpinnerModel spinnerModel = new SpinnerNumberModel(value < 1 ? 1 : value, 1, 1000, 1);        templateNumber.setModel(spinnerModel);        templateNumber.setPreferredSize(new Dimension(45, 20));        outputFolder = new JTextField(settings.getOutputFolder(), 15);        chooseFolder.setPreferredSize(new Dimension(20, 20));        formats = new JComboBox(settings.getFormatDescriptions());        formats.setPreferredSize(new Dimension(60, 20));        formats.setSelectedIndex(settings.getImageFormatIndex());        JPanel fileChoosePane = new JPanel(new GridBagLayout());        fileChoosePane.add(outputFolder, new GridBagConstraints(0, 0, 1, 1, 0, 0.0,                GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 3), 0, 0));        fileChoosePane.add(chooseFolder, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,                GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));        folderLabel.setText(resource.getString("SettingsDialog.Label.Folder.Text"));        formatLabel.setText(resource.getString("SettingsDialog.Label.Format.Text"));        autoSave.setText(resource.getString("SettingsDialog.Action.AutoSave.Text.MacOS"));        JLabel title = new JLabel(resource.getString("SettingsDialog.Border.File.Text.MacOS"));        JLabel fileNameTemplate = new JLabel(resource.getString("SettingsDialog.Label.FileNameTmp.Text"));        JLabel templateAnnotation = new JLabel(resource.getString("SettingsDialog.Label.StartsFrom.Annotation"));        JLabel startsFrom = new JLabel(resource.getString("SettingsDialog.Label.StartsFrom.Text.MacOS"));        JLabel autosaveAnnotation = new JLabel((resource.getString("SettingsDialog.Action.AutoSave.Annotation")));        //apply font        Font font = fileNameTemplate.getFont().deriveFont(Font.PLAIN, 12);        title.setFont(font);        fileNameTemplate.setFont(font);        templateName.setFont(font);        templateNumber.setFont(font);        startsFrom.setFont(font);        autoSave.setFont(font);        folderLabel.setFont(font);        outputFolder.setFont(font);        chooseFolder.setFont(font);        formatLabel.setFont(font);        formats.setFont(font);        Font annotationFont = fileNameTemplate.getFont().deriveFont(Font.PLAIN, 10);        templateAnnotation.setFont(annotationFont);        autosaveAnnotation.setFont(annotationFont);        templateAnnotation.setForeground(Color.DARK_GRAY);        autosaveAnnotation.setForeground(Color.DARK_GRAY);        contentPane.add(title, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,                GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(6, 30, 0, 0), 0, 0));        contentPane.add(fileNameTemplate, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,                GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(6, 10, 0, 0), 0, 0));        contentPane.add(templateName, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,                GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 3, 0, 0), 0, 0));        contentPane.add(templateAnnotation, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,                GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0));        contentPane.add(startsFrom, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0,                GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(6, 10, 0, 0), 0, 0));        contentPane.add(this.templateNumber, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0,                GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 3, 0, 0), 0, 0));        contentPane.add(autoSave, new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0,                GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 10, 0, 0), 0, 0));        contentPane.add(autosaveAnnotation, new GridBagConstraints(1, 4, 2, 1, 0.0, 0.0,                GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 32, 0, 0), 0, 0));        contentPane.add(folderLabel, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0,                GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(6, 10, 0, 0), 0, 0));        contentPane.add(fileChoosePane, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0,                GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 3, 0, 30), 0, 0));        contentPane.add(formatLabel, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0,                GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(6, 10, 10, 0), 0, 0));        contentPane.add(formats, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0,                GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(6, 3, 10, 30), 0, 0));        updateAutoSave();        return contentPane;    }    protected JPanel layoutDelayTimePane() {        JLabel capturing = new JLabel(resource.getString("SettingsDialog.Border.Capture.Text.MacOS"));        Font font = capturing.getFont().deriveFont(Font.PLAIN, 12);        capturing.setFont(font);        delay.setFont(font);        delayTime.setFont(font);        delayTimeLabel.setFont(font);        JPanel delayTimePane = new JPanel(new GridBagLayout());        delayTimePane.add(capturing, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,                GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));        delayTimePane.add(delay, new GridBagConstraints(GridBagConstraints.RELATIVE, 0, 1, 1, 0.0, 0.0,                GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0));        delayTimePane.add(delayTime, new GridBagConstraints(GridBagConstraints.RELATIVE, 0, 1, 1, 0.0, 0.0,                GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));        delayTimePane.add(delayTimeLabel, new GridBagConstraints(GridBagConstraints.RELATIVE, 0, 1, 1, 0.0, 0.0,                GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0));        delayTimePane.add(Box.createHorizontalStrut(52));        return delayTimePane;    }}

⌨️ 快捷键说明

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