Example usage for javax.swing.table DefaultTableCellRenderer setHorizontalAlignment

List of usage examples for javax.swing.table DefaultTableCellRenderer setHorizontalAlignment

Introduction

In this page you can find the example usage for javax.swing.table DefaultTableCellRenderer setHorizontalAlignment.

Prototype

@BeanProperty(visualUpdate = true, enumerationValues = { "SwingConstants.LEFT", "SwingConstants.CENTER",
        "SwingConstants.RIGHT", "SwingConstants.LEADING",
        "SwingConstants.TRAILING" }, description = "The alignment of the label's content along the X axis.")
public void setHorizontalAlignment(int alignment) 

Source Link

Document

Sets the alignment of the label's contents along the X axis.

Usage

From source file:com.vgi.mafscaling.ClosedLoop.java

private JTable createAfrDataTable(JPanel panel, String tableName, int gridy) {
    final JTable afrTable = new JTable() {
        private static final long serialVersionUID = 6526901361175099297L;

        public boolean isCellEditable(int row, int column) {
            return false;
        };/*from ww  w .  j av  a  2s .co  m*/
    };
    DefaultTableColumnModel afrModel = new DefaultTableColumnModel();
    final TableColumn afrColumn = new TableColumn(0, 250);
    afrColumn.setHeaderValue(tableName);
    afrModel.addColumn(afrColumn);
    JTableHeader lblAfrTableName = afrTable.getTableHeader();
    lblAfrTableName.setColumnModel(afrModel);
    lblAfrTableName.setReorderingAllowed(false);
    DefaultTableCellRenderer headerRenderer = (DefaultTableCellRenderer) lblAfrTableName.getDefaultRenderer();
    headerRenderer.setHorizontalAlignment(SwingConstants.LEFT);

    GridBagConstraints gbc_lblAfrTableName = new GridBagConstraints();
    gbc_lblAfrTableName.insets = new Insets((gridy == 0 ? 0 : 5), 0, 0, 0);
    gbc_lblAfrTableName.anchor = GridBagConstraints.PAGE_START;
    gbc_lblAfrTableName.fill = GridBagConstraints.HORIZONTAL;
    gbc_lblAfrTableName.gridx = 0;
    gbc_lblAfrTableName.gridy = gridy;
    panel.add(lblAfrTableName, gbc_lblAfrTableName);

    afrTable.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            afrColumn.setWidth(afrTable.getWidth());
        }
    });
    afrTable.getTableHeader().setReorderingAllowed(false);
    afrTable.setColumnSelectionAllowed(true);
    afrTable.setCellSelectionEnabled(true);
    afrTable.setBorder(new LineBorder(new Color(0, 0, 0)));
    afrTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    afrTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    afrTable.setModel(new DefaultTableModel(AfrTableRowCount, AfrTableColumnCount));
    Utils.initializeTable(afrTable, ColumnWidth);

    if (tableName.equals(Afr1TableName)) {
        Format[][] formatMatrix = { { new DecimalFormat("#"), new DecimalFormat("0.00") } };
        NumberFormatRenderer renderer = (NumberFormatRenderer) afrTable.getDefaultRenderer(Object.class);
        renderer.setFormats(formatMatrix);
    } else if (tableName.equals(Afr2TableName)) {
        Format[][] formatMatrix = { { new DecimalFormat("#"), new DecimalFormat("0.00") },
                { new DecimalFormat("#"), new DecimalFormat("#") } };
        NumberFormatRenderer renderer = (NumberFormatRenderer) afrTable.getDefaultRenderer(Object.class);
        renderer.setFormats(formatMatrix);
    }

    GridBagConstraints gbc_afrTable = new GridBagConstraints();
    gbc_afrTable.insets = new Insets(0, 0, 0, 0);
    gbc_afrTable.anchor = GridBagConstraints.PAGE_START;
    gbc_afrTable.gridx = 0;
    gbc_afrTable.gridy = gridy + 1;
    panel.add(afrTable, gbc_afrTable);

    excelAdapter.addTable(afrTable, true, false);

    return afrTable;
}

From source file:org.agmip.ui.afsirs.frames.SWFrame.java

public SWFrame(JFrame prev) {
    initComponents();/*from w w  w .  ja  v a2s.  c o m*/
    this.prev = prev;
    setLocation(400, 50);
    utils = AFSIRSUtils.getInstance();
    ir = utils.getIrrigationSystem();
    DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
    centerRenderer.setHorizontalAlignment(JLabel.CENTER);
    soilTable.setDefaultRenderer(Double.class, centerRenderer);
    soilTable.setDefaultRenderer(Integer.class, centerRenderer);
    infoButton.setForeground(Color.blue);
    infoButton.setBorder(LineBorder.createGrayLineBorder());

    JTableHeader tHeader = soilTable.getTableHeader();
    tHeader.setPreferredSize(new Dimension(300, 35));

    wcErrorLabel.setVisible(false);
    errorLabel.setVisible(false);

    init();

    if (AFSIRSUtils.defaultMode) {
        dwtText.setText(60.0 + "");
        soilListBox.setSelectedIndex(5);
        waterholdcapacityBox.setSelectedIndex(waterHoldSelectedItemIndex[0]);
    }

    getRootPane().setDefaultButton(nextButton);
}

From source file:br.com.jinsync.view.FrmJInSync.java

private void loadLayoutTableFile() {

    int i = 0;/*from  ww w.j  av  a  2  s .  com*/

    tableFile.setModel(tableFileModel);

    DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
    rightRenderer.setHorizontalAlignment(SwingConstants.RIGHT);

    DefaultTableCellRenderer leftRenderer = new DefaultTableCellRenderer();
    leftRenderer.setHorizontalAlignment(SwingConstants.LEFT);

    for (i = 0; i < defField.size(); i++) {
        if (defField.get(i).equals("Zoned Decimal") || defField.get(i).equals("Binary")
                || defField.get(i).equals("Packed Decimal")) {
            tableFile.getColumnModel().getColumn(i).setCellRenderer(rightRenderer);
        } else {
            tableFile.getColumnModel().getColumn(i).setCellRenderer(leftRenderer);
        }
    }

    for (i = 0; i < columnNamesFile.length; i++) {
        int teste = columnNamesFile[i].length();
        if (teste == 3) {
            teste = 5;
        }
        tableFile.getColumnModel().getColumn(i).setPreferredWidth(teste * 8);
    }

    tableFile.getTableHeader().setReorderingAllowed(false);
    tableFile.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    scrFile.setViewportView(tableFile);

}

From source file:marytts.tools.redstart.AdminWindow.java

private void buildPromptTable() {

    this.promptArray = this.currentSession.getPromptArray();

    System.out.println("Loading prompts...");
    Test.output("Array contains " + promptArray.length + " prompts.");

    // Make column names array
    String[] columnNames = new String[3];
    columnNames[REC_STATUS_COLUMN] = "Status";
    columnNames[BASENAME_COLUMN] = "Basename";
    columnNames[PROMPT_TEXT_COLUMN] = "Prompt Preview";

    // Now create the table itself        
    JTable table = new JTable(new PromptTableModel(promptArray, columnNames, redAlertMode));
    table.setColumnSelectionAllowed(false);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // Set alignment for the status colum to centered
    DefaultTableCellRenderer renderer = new ClippingColorRenderer();
    renderer.setHorizontalAlignment(JTextField.CENTER);
    table.getColumnModel().getColumn(REC_STATUS_COLUMN).setCellRenderer(renderer);

    // Set selection highlight colour to light blue
    table.setSelectionBackground(new java.awt.Color(153, 204, 255));

    // Add listeners
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            displayPromptText();/*from   ww  w  .  j ava  2 s  .c  o  m*/
        }
    });

    // Store the table in an instance field accessible to the entire class
    this.jTable_PromptSet = table;

    Thread recordingStatusInitialiser = new Thread() {
        public void run() {
            updateAllRecStatus();
        }
    };
    recordingStatusInitialiser.start();

    // Display table in the appropriate component pane
    jScrollPane_PromptSet.setViewportView(table);

    if (promptArray.length > 0) {
        table.setRowSelectionInterval(0, 0); // Show first row of prompt table as selected               
        displayPromptText(); // Display the prompt text for the first prompt in the prompt display pane 
    }
    setColumnWidths();

    System.out.println("Total " + table.getRowCount() + " prompts loaded.");

}

From source file:br.com.jinsync.view.FrmJInSync.java

private void listCopy(List<Copybook> listCopy) {

    tableCopy = new JTable();
    tableCopy.setBackground(Color.WHITE);
    tableCopy.setRowSelectionAllowed(true);
    tableCopy.setCellSelectionEnabled(true);
    tableCopy.setColumnSelectionAllowed(false);

    tableCopy.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
    rightRenderer.setHorizontalAlignment(SwingConstants.RIGHT);

    // listCopy = listTotCopy;

    modeloCopybook = new CopybookTableModel(listCopy);
    tableCopy.setModel(modeloCopybook);//from ww  w .j  av a 2s .c  o m
    tableCopy.setFont(new Font("Courier New", Font.PLAIN, 12));

    tableCopy.getColumnModel().getColumn(0).setMinWidth(0);
    tableCopy.getColumnModel().getColumn(0).setPreferredWidth(0);
    tableCopy.getColumnModel().getColumn(0).setMaxWidth(0);

    // Coluna Sequencia
    tableCopy.getColumnModel().getColumn(1).setPreferredWidth(60);

    // Coluna Nivel
    tableCopy.getColumnModel().getColumn(2).setMinWidth(0);
    tableCopy.getColumnModel().getColumn(2).setPreferredWidth(0);
    tableCopy.getColumnModel().getColumn(2).setMaxWidth(0);

    // Coluna Nome
    tableCopy.getColumnModel().getColumn(3).setPreferredWidth(300);

    // Coluna Redefines
    tableCopy.getColumnModel().getColumn(4).setPreferredWidth(300);

    // Coluna Formato
    tableCopy.getColumnModel().getColumn(5).setPreferredWidth(120);

    // Coluna Inteiro
    tableCopy.getColumnModel().getColumn(6).setPreferredWidth(70);
    tableCopy.getColumnModel().getColumn(6).setCellRenderer(rightRenderer);
    // Coluna Decimal
    tableCopy.getColumnModel().getColumn(7).setPreferredWidth(70);
    tableCopy.getColumnModel().getColumn(7).setCellRenderer(rightRenderer);

    // Coluna Inicio
    tableCopy.getColumnModel().getColumn(8).setPreferredWidth(50);
    tableCopy.getColumnModel().getColumn(8).setCellRenderer(rightRenderer);

    tableCopy.getColumnModel().getColumn(9).setPreferredWidth(68);

    tableCopy.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    scrCopy.setViewportView(tableCopy);

}

From source file:Clavis.Windows.WShedule.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*  w  w  w .ja  v  a2s  .c o  m*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jPanelInicial = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTable1 = new org.jdesktop.swingx.JXTable();
    ;
    jButtonSair = new javax.swing.JButton();
    jXDatePickerInicio = new org.jdesktop.swingx.JXDatePicker();
    jXDatePickerFim = new org.jdesktop.swingx.JXDatePicker();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jButtonImprimir = new javax.swing.JButton();
    jComboBoxEstado = new javax.swing.JComboBox<>();
    jLabel3 = new javax.swing.JLabel();
    jButtonExportar = new javax.swing.JButton();

    setMinimumSize(new java.awt.Dimension(900, 600));
    setSize(new java.awt.Dimension(900, 600));

    jPanelInicial.setBorder(javax.swing.BorderFactory.createCompoundBorder(
            javax.swing.BorderFactory.createLineBorder(painelcor, 4),
            javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))));
    jPanelInicial.setMinimumSize(new java.awt.Dimension(900, 500));
    jPanelInicial.setPreferredSize(new java.awt.Dimension(900, 500));

    org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder1 = new org.jdesktop.swingx.border.DropShadowBorder();
    dropShadowBorder1.setCornerSize(6);
    dropShadowBorder1.setShadowSize(3);
    dropShadowBorder1.setShowLeftShadow(true);
    jScrollPane1.setBorder(javax.swing.BorderFactory.createCompoundBorder(dropShadowBorder1,
            javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))));

    jTable1.setBorder(null);
    if (mat.getTypeOfMaterial().getMaterialTypeID() == 1) {
        jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {},
                new String[] { lingua.translate("Utilizador"), lingua.translate("Horrio"),
                        lingua.translate("Data"), lingua.translate("Atividade"),
                        lingua.translate("Disciplina") }));
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(250);
        jTable1.getColumnModel().getColumn(1).setMinWidth(90);
        jTable1.getColumnModel().getColumn(2).setMinWidth(90);
        jTable1.getColumnModel().getColumn(3).setMinWidth(150);
        jTable1.getColumnModel().getColumn(4).setMinWidth(150);
    } else {
        jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {},
                new String[] { lingua.translate("Utilizador"), lingua.translate("Data inicial"),
                        lingua.translate("Data final"), lingua.translate("Atividade") }));
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(250);
        jTable1.getColumnModel().getColumn(1).setMinWidth(90);
        jTable1.getColumnModel().getColumn(2).setMinWidth(90);
        jTable1.getColumnModel().getColumn(3).setMinWidth(150);
    }
    jScrollPane1.setViewportView(jTable1);
    Border border = BorderFactory.createEmptyBorder(5, 5, 0, 0);
    UIManager.put("Table.focusCellHighlightBorder", border);
    jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setHorizontalAlignment(javax.swing.JLabel.CENTER);
    renderer.setFocusable(false);
    javax.swing.JLabel lo = new javax.swing.JLabel();
    lo.setBackground(new Color(100, 100, 100));
    lo.setOpaque(true);
    jScrollPane1.setCorner(javax.swing.JScrollPane.UPPER_TRAILING_CORNER, lo);
    jTable1.setRowHeight(30);
    jTable1.setEditable(false);
    jTable1.setSelectionBackground(Color.DARK_GRAY);
    jTable1.getColumnModel().getColumn(1).setCellRenderer(renderer);
    jTable1.getColumnModel().getColumn(2).setCellRenderer(renderer);
    jTable1.getColumnModel().getColumn(3).setCellRenderer(renderer);
    if (mat.getTypeOfMaterial().getMaterialTypeID() == 1) {
        jTable1.getColumnModel().getColumn(4).setCellRenderer(renderer);
    }
    DefaultTableCellRenderer headerRenderer = new DefaultTableCellRenderer() {
        private static final long serialVersionUID = 2L;

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            setFont(new Font("Cantarell", Font.PLAIN, 14));
            this.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 0, new Color(1, 1, 1)));
            return this;
        }
    };
    DefaultTableCellRenderer headerRenderer2 = new DefaultTableCellRenderer() {
        private static final long serialVersionUID = 3L;

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            setFont(new Font("Cantarell", Font.PLAIN, 14));
            this.setBorder(BorderFactory.createCompoundBorder(
                    BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(1, 1, 1)),
                    BorderFactory.createEmptyBorder(0, 20, 0, 0)));
            this.setBackground(new Color(100, 100, 100));
            setForeground(Color.WHITE);
            setPreferredSize(new Dimension(100, 40));
            return this;
        }
    };

    headerRenderer.setBackground(new Color(100, 100, 100));
    headerRenderer.setForeground(Color.WHITE);
    headerRenderer.setPreferredSize(new Dimension(100, 40));
    headerRenderer.setHorizontalAlignment(javax.swing.JLabel.CENTER);
    for (int i = 0; i < jTable1.getColumnCount(); i++) {
        if (i == 0) {
            headerRenderer2.setHorizontalAlignment(javax.swing.JLabel.LEFT);
            jTable1.getColumnModel().getColumn(i).setHeaderRenderer(headerRenderer2);
        } else {
            jTable1.getColumnModel().getColumn(i).setHeaderRenderer(headerRenderer);
        }
    }

    jButtonSair.setBackground(new java.awt.Color(1, 1, 1));
    jButtonSair.setToolTipText("");
    jButtonSair.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jButtonSair.setFocusPainted(false);
    jButtonSair.setMaximumSize(new java.awt.Dimension(90, 40));
    jButtonSair.setMinimumSize(new java.awt.Dimension(90, 40));
    jButtonSair.setPreferredSize(new java.awt.Dimension(90, 40));
    jButtonSair.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonSairActionPerformed(evt);
        }
    });

    jXDatePickerInicio.setBackground(new java.awt.Color(254, 254, 254));
    org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder2 = new org.jdesktop.swingx.border.DropShadowBorder();
    dropShadowBorder2.setCornerSize(6);
    dropShadowBorder2.setShadowSize(3);
    dropShadowBorder2.setShowLeftShadow(true);
    jXDatePickerInicio.setBorder(javax.swing.BorderFactory.createCompoundBorder(dropShadowBorder2,
            javax.swing.BorderFactory.createMatteBorder(0, 1, 1, 1, new java.awt.Color(0, 0, 0))));
    jXDatePickerInicio.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N
    jXDatePickerInicio.setMaximumSize(new java.awt.Dimension(1155551, 26));
    jXDatePickerInicio.setMinimumSize(new java.awt.Dimension(66, 26));
    jXDatePickerInicio.setPreferredSize(new java.awt.Dimension(131, 26));
    jXDatePickerInicio.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jXDatePickerInicioActionPerformed(evt);
        }
    });

    jXDatePickerFim.setBackground(new java.awt.Color(254, 254, 254));
    org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder3 = new org.jdesktop.swingx.border.DropShadowBorder();
    dropShadowBorder3.setCornerSize(6);
    dropShadowBorder3.setShadowSize(3);
    dropShadowBorder3.setShowLeftShadow(true);
    jXDatePickerFim.setBorder(javax.swing.BorderFactory.createCompoundBorder(dropShadowBorder3,
            javax.swing.BorderFactory.createMatteBorder(0, 1, 1, 1, new java.awt.Color(0, 0, 0))));
    jXDatePickerFim.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N
    jXDatePickerFim.setMaximumSize(new java.awt.Dimension(1155551, 26));
    jXDatePickerFim.setMinimumSize(new java.awt.Dimension(66, 26));
    jXDatePickerFim.setPreferredSize(new java.awt.Dimension(121, 26));

    jLabel1.setBackground(new java.awt.Color(100, 100, 100));
    jLabel1.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N
    jLabel1.setForeground(new java.awt.Color(254, 254, 254));
    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel1.setText("Incio");
    jLabel1.setVerticalAlignment(javax.swing.SwingConstants.TOP);
    jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
    jLabel1.setMaximumSize(new java.awt.Dimension(3343446, 96));
    jLabel1.setMinimumSize(new java.awt.Dimension(36, 26));
    jLabel1.setOpaque(true);
    jLabel1.setPreferredSize(new java.awt.Dimension(100, 20));

    jLabel2.setBackground(new java.awt.Color(100, 100, 100));
    jLabel2.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N
    jLabel2.setForeground(new java.awt.Color(254, 254, 254));
    jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel2.setText("Fim");
    jLabel2.setVerticalAlignment(javax.swing.SwingConstants.TOP);
    jLabel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jLabel2.setMaximumSize(new java.awt.Dimension(355557, 96));
    jLabel2.setMinimumSize(new java.awt.Dimension(37, 26));
    jLabel2.setOpaque(true);
    jLabel2.setPreferredSize(new java.awt.Dimension(100, 20));

    jButtonImprimir.setBackground(new java.awt.Color(51, 102, 153));
    jButtonImprimir.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jButtonImprimir.setFocusPainted(false);
    jButtonImprimir.setMaximumSize(new java.awt.Dimension(5345, 40));
    jButtonImprimir.setPreferredSize(new java.awt.Dimension(90, 40));
    jButtonImprimir.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonImprimirActionPerformed(evt);
        }
    });

    jComboBoxEstado.setBackground(new java.awt.Color(213, 213, 213));
    jComboBoxEstado.setBorder(null);
    jComboBoxEstado.setFocusable(false);
    jComboBoxEstado.setMinimumSize(new java.awt.Dimension(35, 22));
    jComboBoxEstado.setPreferredSize(new java.awt.Dimension(125, 28));
    jComboBoxEstado.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jComboBoxEstadoActionPerformed(evt);
        }
    });

    jLabel3.setBackground(new java.awt.Color(100, 100, 100));
    jLabel3.setFont(new java.awt.Font("Cantarell", 0, 12)); // NOI18N
    jLabel3.setForeground(new java.awt.Color(254, 254, 254));
    jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel3.setText("Estado");
    jLabel3.setVerticalAlignment(javax.swing.SwingConstants.TOP);
    jLabel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jLabel3.setMaximumSize(new java.awt.Dimension(355557, 96));
    jLabel3.setMinimumSize(new java.awt.Dimension(37, 26));
    jLabel3.setOpaque(true);
    jLabel3.setPreferredSize(new java.awt.Dimension(100, 20));

    jButtonExportar.setBackground(new java.awt.Color(51, 102, 153));
    jButtonExportar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jButtonExportar.setFocusPainted(false);
    jButtonExportar.setMaximumSize(new java.awt.Dimension(5345, 40));
    jButtonExportar.setPreferredSize(new java.awt.Dimension(90, 40));
    jButtonExportar.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonExportarActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanelInicialLayout = new javax.swing.GroupLayout(jPanelInicial);
    jPanelInicial.setLayout(jPanelInicialLayout);
    jPanelInicialLayout.setHorizontalGroup(jPanelInicialLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(42, 42, 42)
                    .addGroup(jPanelInicialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelInicialLayout.createSequentialGroup().addComponent(jScrollPane1)
                                    .addGap(42, 42, 42))
                            .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(29, 29, 29)
                                    .addComponent(jButtonSair, javax.swing.GroupLayout.PREFERRED_SIZE, 90,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jButtonExportar, javax.swing.GroupLayout.PREFERRED_SIZE, 90,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jButtonImprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 90,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(71, 71, 71))))
            .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(71, 71, 71)
                    .addGroup(jPanelInicialLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jXDatePickerInicio, javax.swing.GroupLayout.DEFAULT_SIZE, 152,
                                    Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanelInicialLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                            .addComponent(jXDatePickerFim, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 201, Short.MAX_VALUE)
                    .addGroup(jPanelInicialLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jComboBoxEstado, 0, 241, Short.MAX_VALUE))
                    .addGap(71, 71, 71)));
    jPanelInicialLayout
            .setVerticalGroup(jPanelInicialLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelInicialLayout.createSequentialGroup().addGap(16, 16, 16)
                            .addGroup(jPanelInicialLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(0, 0, 0)
                            .addGroup(jPanelInicialLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jXDatePickerInicio, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            31, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jXDatePickerFim, javax.swing.GroupLayout.PREFERRED_SIZE, 31,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jComboBoxEstado, javax.swing.GroupLayout.PREFERRED_SIZE, 28,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 465,
                                    Short.MAX_VALUE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanelInicialLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jButtonImprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButtonSair, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButtonExportar, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(16, 16, 16)));

    try {
        if (Clavis.KeyQuest.class.getResource("Images/exit26x24.png") != null) {
            BufferedImage im = ImageIO.read(Clavis.KeyQuest.class.getResourceAsStream("Images/exit26x24.png"));
            ImageIcon imic = new ImageIcon(im);
            if (imic != null) {
                jButtonSair.setIcon(imic);
            }
        }
    } catch (IOException eo) {
    }

    jButtonSair.setToolTipText(lingua.translate("Voltar"));
    javax.swing.JPanel pan2 = new javax.swing.JPanel(null);
    String compoe = lingua.translate("Hoje  dia") + ": " + new TimeDate.Date().toString();
    javax.swing.JLabel fil2 = new javax.swing.JLabel(compoe);
    fil2.setBounds(0, 0, 300, 26);
    fil2.setHorizontalAlignment(SwingConstants.CENTER);
    pan2.setPreferredSize(new Dimension(300, 30));
    pan2.setBounds(0, 0, 300, 30);
    pan2.add(fil2);
    jXDatePickerInicio.setLinkPanel(pan2);

    jXDatePickerInicio.setLocale(lingua.systemlocale);
    jXDatePickerInicio.getEditor().setSelectionColor(Color.DARK_GRAY);
    jXDatePickerInicio.getEditor().setBorder(BorderFactory.createEmptyBorder());
    jXDatePickerInicio.getEditor().setHorizontalAlignment(SwingConstants.CENTER);
    javax.swing.JButton bbt2 = (javax.swing.JButton) jXDatePickerInicio.getComponent(1);
    bbt2.setBackground(Color.WHITE);

    jXDatePickerInicio.addActionListener(actionJXDatePicker());
    jXDatePickerInicio.setFormats("dd/MM/yyyy");
    javax.swing.JPanel pan = new javax.swing.JPanel(null);
    String compoe0 = lingua.translate("Hoje  dia") + ": " + new TimeDate.Date().toString();
    javax.swing.JLabel fil = new javax.swing.JLabel(compoe);
    fil.setBounds(0, 0, 300, 26);
    fil.setHorizontalAlignment(SwingConstants.CENTER);
    pan.setPreferredSize(new Dimension(300, 30));
    pan.setBounds(0, 0, 300, 30);
    pan.add(fil);
    jXDatePickerFim.setLinkPanel(pan);

    Component[] t = jXDatePickerFim.getLinkPanel().getComponents();

    jXDatePickerFim.setLocale(lingua.systemlocale);
    jXDatePickerFim.getEditor().setSelectionColor(Color.DARK_GRAY);
    jXDatePickerFim.getEditor().setBorder(BorderFactory.createEmptyBorder());
    jXDatePickerFim.getEditor().setHorizontalAlignment(SwingConstants.CENTER);
    javax.swing.JButton bbt = (javax.swing.JButton) jXDatePickerFim.getComponent(1);
    bbt.setBackground(Color.WHITE);
    jXDatePickerFim.addActionListener(actionJXDatePicker());
    jXDatePickerFim.setFormats("dd/MM/yyyy");
    jLabel1.setText(lingua.translate("Incio"));
    jLabel2.setText(lingua.translate("Fim"));
    try {
        if (Clavis.KeyQuest.class.getResource("Images/print.png") != null) {
            BufferedImage im = ImageIO.read(Clavis.KeyQuest.class.getResourceAsStream("Images/print.png"));
            ImageIcon imic = new ImageIcon(im);
            if (imic != null) {
                jButtonImprimir.setIcon(imic);
            }
        }
    } catch (IOException eo) {
    }

    jButtonImprimir.setToolTipText(lingua.translate("Imprimir"));
    jComboBoxEstado.setModel(new javax.swing.DefaultComboBoxModel<>(
            new String[] { lingua.translate("todos"), lingua.translate("terminado"),
                    lingua.translate("no realizado"), lingua.translate("por realizar") }));
    Clavis.KeyQuest.addVisualComboBox(jComboBoxEstado);
    ((javax.swing.JLabel) jComboBoxEstado.getRenderer()).setHorizontalAlignment(javax.swing.JLabel.CENTER);
    jLabel3.setText(lingua.translate("Estado"));
    try {
        if (Clavis.KeyQuest.class.getResource("Images/exportar.png") != null) {
            BufferedImage im = ImageIO.read(Clavis.KeyQuest.class.getResourceAsStream("Images/exportar.png"));
            ImageIcon imic = new ImageIcon(im);
            if (imic != null) {
                jButtonExportar.setIcon(imic);
            }
        }
    } catch (IOException eo) {
    }

    jButtonExportar.setToolTipText(lingua.translate("Exportar para excel"));

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addComponent(jPanelInicial,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGap(0, 0, 0)));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelInicial, javax.swing.GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE));
}

From source file:edu.harvard.i2b2.patientMapping.ui.PatientMappingJPanel.java

/** Creates new form PatientMappingJPanel */
public PatientMappingJPanel(java.awt.Container oAwtContainer) {
    columns = new ArrayList<SiteColumnData>();

    initComponents();//from w  ww  .  ja  v a 2  s . c o  m
    DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
    //model.addColumn("addedColumn1");
    //model.addColumn("addedColumn2");

    String[] columns = new String[3];
    columns[0] = new String("HIVE");
    columns[1] = new String("");
    columns[2] = new String("");
    //columns[3] = new String("");
    DefaultTableModel model1 = new DefaultTableModel(columns, 100);
    jTable1.setModel(model1);
    jTable1.setCellSelectionEnabled(true);
    TableColumn col = jTable1.getColumnModel().getColumn(0);
    DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
    dtcr.setHorizontalAlignment(SwingConstants.CENTER);
    col.setCellRenderer(dtcr);
    //jTable1.setCellSelectionEnabled(false);
    //model.setRowCount(100);
    //model.setValueAt(235600004, 0, 4);
    //model.setValueAt(235600005, 1, 5);
    //model.setValueAt(235600006, 5, 4);
    //model.setValueAt(235600007, 5, 5);
    //model.setValueAt(235600008, 6, 5);

    thisPanel = this;
    parent = oAwtContainer;

    //this.jLeftButton.setEnabled(false);
    this.jRightButton.setEnabled(false);
    this.jStartTextField.setEditable(false);
    this.jIncrementTextField.setEditable(false);
    //jAutoSaveCheckBox.setSelected(true);
}

From source file:net.sf.jabref.gui.MainTable.java

@Override
public TableCellRenderer getCellRenderer(int row, int column) {

    int score = -3;
    DefaultTableCellRenderer renderer = MainTable.defRenderer;

    int status = getCellStatus(row, column);

    if (!isFloatSearchActive || matches(row, searchMatcher)) {
        score++;/*from  w w  w .  j a va  2s.  co m*/
    }
    if (!isFloatGroupingActive || matches(row, groupMatcher)) {
        score += 2;
    }

    // Now, a grayed out renderer is for entries with -1, and
    // a very grayed out one for entries with -2
    if (score < -1) {
        if (column == 0) {
            MainTable.veryGrayedOutNumberRenderer.setNumber(row);
            renderer = MainTable.veryGrayedOutNumberRenderer;
        } else {
            renderer = MainTable.veryGrayedOutRenderer;
        }
    } else if (score == -1) {
        if (column == 0) {
            MainTable.grayedOutNumberRenderer.setNumber(row);
            renderer = MainTable.grayedOutNumberRenderer;
        } else {
            renderer = MainTable.grayedOutRenderer;
        }
    }

    else if (column == 0) {
        // Return a renderer with red background if the entry is incomplete.
        if (!isComplete(row)) {
            MainTable.incRenderer.setNumber(row);
            renderer = MainTable.incRenderer;
        } else {
            MainTable.compRenderer.setNumber(row);
            int marking = isMarked(row);
            if (marking > 0) {
                marking = Math.min(marking, EntryMarker.MARK_COLOR_LEVELS);
                renderer = MainTable.markedNumberRenderers[marking - 1];
                MainTable.markedNumberRenderers[marking - 1].setNumber(row);
            } else {
                renderer = MainTable.compRenderer;
            }
        }
        renderer.setHorizontalAlignment(JLabel.CENTER);
    } else if (tableColorCodes) {
        if (status == MainTable.REQUIRED) {
            renderer = MainTable.reqRenderer;
        } else if (status == MainTable.OPTIONAL) {
            renderer = MainTable.optRenderer;
        } else if (status == MainTable.BOOLEAN) {
            renderer = (DefaultTableCellRenderer) getDefaultRenderer(Boolean.class);
        }
    }

    // For MARKED feature:
    int marking = isMarked(row);
    if ((column != 0) && (marking > 0)) {
        marking = Math.min(marking, EntryMarker.MARK_COLOR_LEVELS);
        renderer = MainTable.markedRenderers[marking - 1];
    }

    return renderer;

}

From source file:edu.ku.brc.ui.UIHelper.java

/**
 * Sets a JTable to have the headers be centered. Also, the caller can indicate whether
 * and "String" columns are also centered.
 * @param table the table//  w w w  . j av a2  s  .  c o  m
 * @param dataColsAlso whether the String data columns should be cetnered.
 */
public static void makeTableHeadersCentered(final JTable table, final boolean dataColsAlso) {
    ((DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer())
            .setHorizontalAlignment(SwingConstants.CENTER);

    if (dataColsAlso) {
        TableCellRenderer tcr = table.getDefaultRenderer(String.class);

        // For Strings with no changes made to the table, the render is a DefaultTableCellRender.
        DefaultTableCellRenderer dtcr = (DefaultTableCellRenderer) tcr;

        // set the alignment to center
        dtcr.setHorizontalAlignment(SwingConstants.CENTER);
    }
}

From source file:edu.ku.brc.af.ui.forms.TableViewObj.java

/**
 * Build the table now that we have all the information we need for the columns.
 *//*from  w ww.j  ava2 s. c om*/
protected void buildTable() {
    // Now Build the JTable
    model = new ColTableModel();
    table = new JTable(model);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setRowSelectionAllowed(true);
    table.setColumnSelectionAllowed(false);
    table.setFocusable(false);
    //table.setPreferredScrollableViewportSize(new Dimension(200,table.getRowHeight()*6));

    configColumns();

    //table.setCellSelectionEnabled(false);

    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                updateUI(!lsm.isSelectionEmpty());
            }
        }
    });

    table.addMouseListener(new java.awt.event.MouseAdapter() {
        @Override
        public void mouseClicked(java.awt.event.MouseEvent e) {
            if (e.getClickCount() == 2) {
                int index = table.getSelectedRow();
                editRow(index, false);
            }
        }
    });

    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setHorizontalAlignment(SwingConstants.CENTER);

    /*
             
    // This is BROKEN!
    table.setCellSelectionEnabled(true);
            
    for (int i=0;i<model.getColumnCount();i++) 
    {
    TableColumn column = table.getColumn(model.getColumnName(i));
            
    //log.info(model.getColumnName(i));
    //column.setCellRenderer(renderer);
            
    ColumnInfo columnInfo = columnList.get(i);
    Component  comp       = columnInfo.getComp();
            
    //column.setCellEditor(new DefaultCellEditor(new JTextField()));
    if (comp instanceof GetSetValueIFace)
    {
        column.setCellEditor(new MyTableCellEditor(columnInfo));
                
    } else if (comp instanceof JTextField)
    {
        column.setCellEditor(new DefaultCellEditor((JTextField)comp));
                
    } else
    {
        log.error("Couldn't figure out DefaultCellEditor for comp ["+comp.getClass().getSimpleName()+"]");
    }
    }
    */

    tableScroller = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    orderablePanel = new JPanel(new BorderLayout());
    orderablePanel.add(tableScroller, BorderLayout.CENTER);

    mainComp.add(orderablePanel, BorderLayout.CENTER);

    initColumnSizes(table);
}