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

📄 bsplandialog.java

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

/*
 * BSPlanDialog.java
 *
 * Project: BuddySpace
 * (C) Copyright Knowledge Media Institute 2003
 *
 *
 * Created on 29 October 2003, 16:57
 */

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

import org.jabber.jabberbeans.Extension.*;
import org.jabber.jabberbeans.util.*;

import edu.ou.kmi.buddyspace.gui.*;
import edu.ou.kmi.buddyspace.core.*;

import edu.ou.kmi.buddyspace.plugins.maps.xml.*;

/**
 * <code>BSPlanDialog</code> allows entering / shows plan
 * items should be saved.
 *
 * @author  Jiri Komzak, Knowledge Media Institute, Open University, United Kingdom
 */

public class BSPlanDialog extends JDialog {
    private JOptionPane optionPane;
    public String plan = null;
    
    /** Constructor */
    public BSPlanDialog(Frame _parent, String person, String _plan, boolean _received) {
        super(_parent, "Plan", true);
        
        final Frame parent = _parent;
        final boolean received = _received;
        
        JLabel label;
        if (received)
            label = new JLabel("Received plan of " + person);
        else
            label = new JLabel("Publish plan for " + person);
        
        final JTextArea textArea = new JTextArea();
        if (_plan != null) textArea.setText(_plan);
        textArea.setEditable(!received);
        JScrollPane scrollPane = new JScrollPane(textArea);
        scrollPane.setPreferredSize(new Dimension(200, 200));
        
        Object[] fields = {label,
                           "Plan: ", scrollPane};
        
        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)) {
                        plan = textArea.getText();
                        setVisible(false);
                        return;
                    }
                    else if (value.equals(cancelButton)) {
                        plan = null;
                        setVisible(false);
                    }
                }
            }
        });
    }
    
    
    public class BSMapPubsubSaveListCellRenderer extends JLabel 
                                   implements ListCellRenderer {
                                       
        protected Border noFocusBorder;

        /**
         * Constructor.
         */
        public BSMapPubsubSaveListCellRenderer() {
            super();
            if (noFocusBorder == null) {
                noFocusBorder = new EmptyBorder(1, 1, 1, 1);
            }
            setOpaque(true);
            setBorder(noFocusBorder);
        }
    
        public Component getListCellRendererComponent(
        JList list,
        Object value,            // value to display
        int index,               // cell index
        boolean isSelected,      // is the cell selected
        boolean cellHasFocus) {  // the list and the cell have the focus
        
            setComponentOrientation(list.getComponentOrientation());
            if (isSelected) {
                setBackground(list.getSelectionBackground());
                setForeground(list.getSelectionForeground());
            }
            else {
                setBackground(list.getBackground());
                setForeground(list.getForeground());
            }

            if (value instanceof MapTag) {
                setText(((MapTag)value).getID());
            }
            else if (value instanceof OOB) {
                setText(((OOB)value).getDescription());
            }
            
            setEnabled(list.isEnabled());
            setFont(list.getFont());
            setBorder((cellHasFocus) ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
            
            return this;
        }
    }
}

⌨️ 快捷键说明

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