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

📄 bssendurldialog.java

📁 一款即时通讯软件
💻 JAVA
字号:
package edu.ou.kmi.buddyspace.gui;

/*
 * BSSendURLDialog.java
 *
 *
 * Project: BuddySpace
 * (C) Copyright Knowledge Media Institute 2003
 *
 *
 * Created on 17 March 2003, 10:02
 */

import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.beans.*; // Property change stuff

/**
 * Dialog for sending URLs.
 *
 * @author  Jiri Komzak, Knowledge Media Institute, Open University, United Kingdom
 */
public class BSSendURLDialog extends JDialog {
    
    private JOptionPane optionPane;
    
    public String url = null;
    public String desc = null;
    
    private Frame parent;
    private JTextField urlTextField;
    private JTextField descTextField;
    
    /** Creates new form BSSendURLDialog for sending URLs */
    public BSSendURLDialog(Frame parent) {
                                  
        super(parent, "Send URL", true);
        
        this.parent = parent;
        
        urlTextField = new JTextField("http://");
        descTextField = new JTextField();
        
        Object[] fields = {"URL: ", urlTextField,
                           "Description: ", descTextField};
        
        final String okButton = "OK";
        final String cancelButton = "Cancel";
        Object[] options = {okButton, cancelButton};

        optionPane = new JOptionPane(fields, 
                                     JOptionPane.PLAIN_MESSAGE,
                                     JOptionPane.OK_CANCEL_OPTION,
                                     null,
                                     options,
                                     options[0]);
        setContentPane(optionPane);
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

        pack();
        setLocationRelativeTo(parent);
        
        // handles actions
        optionPane.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
                String prop = e.getPropertyName();
			
                if (isVisible() 
                    && (e.getSource() == optionPane)
                    && (prop.equals(JOptionPane.VALUE_PROPERTY) ||
                      prop.equals(JOptionPane.INPUT_VALUE_PROPERTY))) {
                    Object value = optionPane.getValue();

                    if (value == JOptionPane.UNINITIALIZED_VALUE) {
                        // ignore reset
                        return;
                    }

                    // Reset the JOptionPane's value.
                    // If you don't do this, then if the user
                    // presses the same button next time, no
                    // property change event will be fired.
                    optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

                    if (value.equals(okButton)) {
                        url = urlTextField.getText();
                        desc = descTextField.getText();
                        setVisible(false);
                        return;
                    }
                    else if (value.equals(cancelButton)) {
                        setVisible(false);
                    }
                }
            }
        });
    }

}

⌨️ 快捷键说明

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