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

📄 changedtranscriptionspane.java

📁 编辑视频文件
💻 JAVA
字号:
/* * File:     ChangedTranscriptionsPane.java * Project:  MPI Linguistic Application * Date:     02 May 2007 * * Copyright (C) 2001-2007  Max Planck Institute for Psycholinguistics * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */package mpi.eudico.client.annotator.gui;import mpi.eudico.client.annotator.ElanLocale;import mpi.eudico.client.util.CheckBoxTableCellRenderer;import java.awt.Dimension;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.util.ArrayList;import javax.swing.DefaultCellEditor;import javax.swing.JCheckBox;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.table.DefaultTableModel;/** * A pane with a message label and a table with 2 columns; a checkbox column * and a column with strings identifying the transcriptions or the windows. * The (string) values of the checked rows will be returned by * getSelectedValues(). * * @author Han Sloetjes, MPI */public class ChangedTranscriptionsPane extends JPanel {    private JLabel messageLabel;    private JTable transTable;    private JScrollPane pane;    private DefaultTableModel model;    /** Holds value of property DOCUMENT ME! */    private final int checkW = 30;    /** Holds value of property DOCUMENT ME! */    private final int tableW = 380;    /**     * Creates the panel and initializes the table.     *     * @param changedTrans string representation of the transcriptions (name,     *        path, url) or their windows     */    public ChangedTranscriptionsPane(ArrayList changedTrans) {        initComponents();        fillTable(changedTrans);    }    private void initComponents() {        messageLabel = new JLabel("<html>" +                ElanLocale.getString("Frame.ElanFrame.UnsavedMultiple1") +                "<br>" +                ElanLocale.getString("Frame.ElanFrame.UnsavedMultiple2") +                "</html>");        //messageLabel.setFont(messageLabel.getFont().deriveFont(Font.PLAIN, 16f));        model = new DefaultTableModel() {                    public boolean isCellEditable(int row, int column) {                        if (column > 0) {                            return false;                        }                        return true;                    }                };        model.setColumnCount(2);        transTable = new JTable(model);        transTable.setTableHeader(null);        transTable.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(                new JCheckBox()));        transTable.getColumnModel().getColumn(0).setCellRenderer(new CheckBoxTableCellRenderer());        transTable.getColumnModel().getColumn(0).setMaxWidth(checkW);        transTable.getColumnModel().getColumn(0).setMinWidth(checkW);        transTable.getColumnModel().getColumn(1).setPreferredWidth(tableW -            checkW - 4);        transTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);        ;        pane = new JScrollPane(transTable);        pane.setPreferredSize(new Dimension(tableW, 80));        setLayout(new GridBagLayout());        GridBagConstraints gbc = new GridBagConstraints();        gbc.insets = new Insets(3, 6, 10, 6);        gbc.fill = GridBagConstraints.HORIZONTAL;        gbc.weightx = 1.0;        add(messageLabel, gbc);        gbc.gridy = 1;        gbc.fill = GridBagConstraints.BOTH;        gbc.weighty = 1.0;        add(pane, gbc);    }    /**     * Adds a row to the table for each transcription with unsaved data.     * The first column of each row is a Boolean, defaults to true, the second     * contains the transcription/frame name.     * After the rows have been added the (minimum) width of the name column is calculated.     * @param changedTrans a list containing the names of the changed transcriptions     */    private void fillTable(ArrayList changedTrans) {        if (changedTrans != null) {            String ws = "";            String loopString;            for (int i = 0; i < changedTrans.size(); i++) {                loopString = (String) changedTrans.get(i);                model.addRow(new Object[] { Boolean.TRUE, loopString });                if (loopString.length() > ws.length()) {                    ws = loopString;                }            }            if (ws.length() > 0) {                // calculate pixel width                int w = transTable.getFontMetrics(transTable.getFont())                                  .stringWidth(ws);                if (w > (tableW - checkW)) {                    transTable.getColumnModel().getColumn(1).setMinWidth(w + 4);                }            }        }    }    /**     * Returns the values that are selected in the table.     *     * @return the selected values     */    public ArrayList getSelectedValues() {        if (model != null) {            ArrayList vals = new ArrayList(model.getRowCount());            for (int i = 0; i < model.getRowCount(); i++) {                if (((Boolean) model.getValueAt(i, 0)).booleanValue()) {                    vals.add(model.getValueAt(i, 1));                }            }            return vals;        }        return null;    }}

⌨️ 快捷键说明

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