Example usage for javax.swing JTable JTable

List of usage examples for javax.swing JTable JTable

Introduction

In this page you can find the example usage for javax.swing JTable JTable.

Prototype

public JTable() 

Source Link

Document

Constructs a default JTable that is initialized with a default data model, a default column model, and a default selection model.

Usage

From source file:aplicarFiltros.PanelResultado.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Sebastian Colavita
    DefaultComponentFactory compFactory = DefaultComponentFactory.getInstance();
    panel2 = new JPanel();
    panel1 = new JPanel();
    scrollPaneRasgos2 = new JScrollPane();
    tableRasgos2 = new JTable();
    button1 = new JButton();
    separator1 = compFactory.createSeparator("Clasificaci\u00f3n");
    label1 = new JLabel();
    resultado = new JLabel();
    label2 = new JLabel();
    Descuento = new JLabel();
    panel3 = new JPanel();
    panelGraficoPixel = new JPanel();

    //======== this ========

    // JFormDesigner evaluation mark
    setBorder(//  www  . j a  va 2 s . c  o  m
            new javax.swing.border.CompoundBorder(
                    new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
                            "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
                            javax.swing.border.TitledBorder.BOTTOM,
                            new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red),
                    getBorder()));
    addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent e) {
            if ("border".equals(e.getPropertyName()))
                throw new RuntimeException();
        }
    });

    setLayout(null);

    //======== panel2 ========
    {
        panel2.setBackground(Color.blue);
        panel2.setLayout(null);

        //======== panel1 ========
        {
            panel1.setBorder(new BevelBorder(BevelBorder.RAISED));
            panel1.setLayout(null);

            //======== scrollPaneRasgos2 ========
            {

                //---- tableRasgos2 ----
                tableRasgos2.setModel(new DefaultTableModel(new Object[][] {},
                        new String[] { "Clasificaciones", "Cantidad", "Porcentaje Area" }) {
                    Class<?>[] columnTypes = new Class<?>[] { String.class, String.class, Object.class };

                    @Override
                    public Class<?> getColumnClass(int columnIndex) {
                        return columnTypes[columnIndex];
                    }
                });
                tableRasgos2.setPreferredScrollableViewportSize(new Dimension(200, 100));
                tableRasgos2.setBackground(UIManager.getColor("RadioButton.light"));
                tableRasgos2.setCellSelectionEnabled(true);
                scrollPaneRasgos2.setViewportView(tableRasgos2);
            }
            panel1.add(scrollPaneRasgos2);
            scrollPaneRasgos2.setBounds(10, 60, 605, 155);

            //---- button1 ----
            button1.setIcon(new ImageIcon("\\\\img\\\\maiz_mon810_al.jpg"));
            panel1.add(button1);
            button1.setBounds(620, 60, 225, 155);
            panel1.add(separator1);
            separator1.setBounds(10, 5, 835, separator1.getPreferredSize().height);

            //---- label1 ----
            label1.setText("Resultado:");
            label1.setFont(new Font("Times New Roman", Font.BOLD, 13));
            panel1.add(label1);
            label1.setBounds(10, 35, 67, label1.getPreferredSize().height);

            //---- resultado ----
            resultado.setText("Grado A");
            resultado.setFont(new Font("Times New Roman", Font.BOLD, 13));
            resultado.setForeground(Color.blue);
            panel1.add(resultado);
            resultado.setBounds(79, 35, 171, 19);

            //---- label2 ----
            label2.setText(" Descuento:");
            label2.setFont(new Font("Times New Roman", Font.BOLD, 13));
            panel1.add(label2);
            label2.setBounds(250, 35, 72, 19);

            //---- Descuento ----
            Descuento.setText("10%");
            Descuento.setFont(new Font("Times New Roman", Font.BOLD, 13));
            Descuento.setForeground(Color.blue);
            panel1.add(Descuento);
            Descuento.setBounds(320, 35, 60, Descuento.getPreferredSize().height);

            { // compute preferred size
                Dimension preferredSize = new Dimension();
                for (int i = 0; i < panel1.getComponentCount(); i++) {
                    Rectangle bounds = panel1.getComponent(i).getBounds();
                    preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                    preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
                }
                Insets insets = panel1.getInsets();
                preferredSize.width += insets.right;
                preferredSize.height += insets.bottom;
                panel1.setMinimumSize(preferredSize);
                panel1.setPreferredSize(preferredSize);
            }
        }
        panel2.add(panel1);
        panel1.setBounds(15, 10, 856, 225);

        //======== panel3 ========
        {
            panel3.setBorder(new TitledBorder("Gr\u00e1ficos"));
            panel3.setLayout(new BoxLayout(panel3, BoxLayout.Y_AXIS));

            //======== panelGraficoPixel ========
            {
                panelGraficoPixel.setLayout(null);

                { // compute preferred size
                    Dimension preferredSize = new Dimension();
                    for (int i = 0; i < panelGraficoPixel.getComponentCount(); i++) {
                        Rectangle bounds = panelGraficoPixel.getComponent(i).getBounds();
                        preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                        preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
                    }
                    Insets insets = panelGraficoPixel.getInsets();
                    preferredSize.width += insets.right;
                    preferredSize.height += insets.bottom;
                    panelGraficoPixel.setMinimumSize(preferredSize);
                    panelGraficoPixel.setPreferredSize(preferredSize);
                }
            }
            panel3.add(panelGraficoPixel);
        }
        panel2.add(panel3);
        panel3.setBounds(13, 245, 857, 355);

        { // compute preferred size
            Dimension preferredSize = new Dimension();
            for (int i = 0; i < panel2.getComponentCount(); i++) {
                Rectangle bounds = panel2.getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            }
            Insets insets = panel2.getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
            panel2.setMinimumSize(preferredSize);
            panel2.setPreferredSize(preferredSize);
        }
    }
    add(panel2);
    panel2.setBounds(10, 5, 883, 610);

    { // compute preferred size
        Dimension preferredSize = new Dimension();
        for (int i = 0; i < getComponentCount(); i++) {
            Rectangle bounds = getComponent(i).getBounds();
            preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
            preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
        }
        Insets insets = getInsets();
        preferredSize.width += insets.right;
        preferredSize.height += insets.bottom;
        setMinimumSize(preferredSize);
        setPreferredSize(preferredSize);
    }
    // JFormDesigner - End of component initialization  //GEN-END:initComponents

    button1.setIcon(new ImageIcon("img\\maiz_mon810_al.jpg"));
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.DataImportDialog.java

/**
 * Constructor for Import Dialog for a csv
 * /*from  w  w  w.  j ava 2 s  .  c o m*/
 * @param config - the config class for configing a csv import
 * @param defaultDelimChar - default delimiter to be used
 * @param defaultTextQual - default text qualifer to be used
 * @param defaultCharSet - default character set to be used
 * @param defaultEscMode - default escape mode to be used
 * @param doesHaveHeaders - default for whether or not the data file contains headers in the first row.
 * @param useTxtQual
 */
public DataImportDialog(final ConfigureCSV config, char defaultDelimChar, char defaultTextQual,
        Charset defaultCharSet, int defaultEscMode, boolean doesHaveHeaders, boolean useTxtQual) {
    this.config = config;
    this.configCSV = config;
    this.file = config.getFile();
    this.fileName = file.getAbsolutePath().toString();
    this.doesFirstRowHaveHeaders = doesHaveHeaders;
    this.charset = defaultCharSet;
    this.escapeMode = defaultEscMode;
    this.delimChar = defaultDelimChar;
    this.stringQualifierChar = defaultTextQual;
    this.shouldUseTextQualifier = useTxtQual;
    highestColumnCount = 0;
    myDisplayTable = new JTable();
    model = new PreviewTableModel();

    ImageIcon appIcon = IconManager.getIcon("AppIcon"); //$NON-NLS-1$
    if (appIcon != null) {
        setIconImage(appIcon.getImage());
    }
}