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

📄 resizedialog.java

📁 一个用Java 造成的小画家
💻 JAVA
字号:
package onlyfun.caterpillar.dialog;

import java.awt.Component;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSpinner;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class ResizeDialog {
    private static JPanel resizePanel;
    
    private static JRadioButton customWidthHeightBtn, percentBtn;
    private static JCheckBox lockRatioBox;
    private static JSpinner resizePercentSpinner, resizeWidthSpinner, resizeHeightSpinner;
    
    private static double imageWidth, imageHeight;
    private static boolean resizeLocker;
    
    static {
        setUIComponent();
        setEventListener();
    }
    
    private static void setUIComponent() {
        resizePanel = new JPanel();
        resizePanel.setLayout(new GridLayout(4, 4, 5, 5));

        customWidthHeightBtn = new JRadioButton("Custom size");
        percentBtn = new JRadioButton("Percentage");
        percentBtn.setSelected(true);
        ButtonGroup buttonGroup = new ButtonGroup();
        buttonGroup.add(customWidthHeightBtn);
        buttonGroup.add(percentBtn);
        
        lockRatioBox = new JCheckBox("lock");
        lockRatioBox.setSelected(true);
        lockRatioBox.setEnabled(false);
        
        resizeWidthSpinner = new JSpinner();
        resizeHeightSpinner = new JSpinner();
        
        resizeWidthSpinner.setEnabled(false);
        resizeHeightSpinner.setEnabled(false);
        
        resizePercentSpinner = new JSpinner();
        resizePercentSpinner.setValue(new Integer(100));
        
        resizePanel.add(customWidthHeightBtn);
        
        resizePanel.add(new JLabel("Width"));
        resizePanel.add(resizeWidthSpinner);
        resizePanel.add(new JLabel("pixel"));
        
        resizePanel.add(lockRatioBox);
        resizePanel.add(new JLabel("Height"));
        resizePanel.add(resizeHeightSpinner);
        resizePanel.add(new JLabel("pixel"));
        
        resizePanel.add(new JLabel("

⌨️ 快捷键说明

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