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

📄 dialogcelleditor.java

📁 The program is used for Classroom Scheduling for tutors and students. It contain gui tools for mana
💻 JAVA
字号:
/*
 * DialogCellEditor.java
 *
 * Created on April 19, 2004, 2:41 PM
 */

package resources;

import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import panels.*;

/**
 *
 * @author  kyle
 */
public class DialogCellEditor extends AbstractCellEditor implements TableCellEditor {
    
    private String value;
    private JButton component;
    private JTable table;
    
    /** Creates a new instance of DialogCellEditor */
    public DialogCellEditor() {
        value = "Click to edit";
        component = new JButton();
        component.addActionListener(new buttonActionListener());
    }
    
    public Object getCellEditorValue() {
        return value;
    }
    
    public boolean shouldSelectCell (EventObject anEvent) {
        return false;
    }
    
    public Component getTableCellEditorComponent (JTable table, Object value, boolean isSelected, int row, int column) {
        this.value = (String) value;
        if(table == null) {
            System.out.println("Hmm, got null table");
        }
        this.table = table;
        addCellEditorListener(table);
        return component;
    }

    public Component getTableCellEditorComponent () {
        return component;
    }
    
    class buttonActionListener implements ActionListener {
        public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
            if(actionEvent.getSource() == component) {
//                System.out.println("Should do a popup dialog here");
//                String inputValue = JOptionPane.showInputDialog("Please input a value");
//                value = inputValue;
                
                NoteDialog dialog = new NoteDialog((Frame) table.getTopLevelAncestor(), true);
                dialog.setNote(value);
                dialog.setVisible(true);
                int ret = dialog.getReturnStatus();
                if(ret == NoteDialog.RET_CANCEL) {
                    fireEditingCanceled();
                    return;
                }
                value = dialog.getNote();
                fireEditingStopped();
                //component.setText(value);
//                fireEditingStopped();
            }
        }
    }
}

⌨️ 快捷键说明

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