Example usage for javax.swing JCheckBox setHorizontalAlignment

List of usage examples for javax.swing JCheckBox setHorizontalAlignment

Introduction

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

Prototype

@BeanProperty(visualUpdate = true, enumerationValues = { "SwingConstants.LEFT", "SwingConstants.CENTER",
        "SwingConstants.RIGHT", "SwingConstants.LEADING",
        "SwingConstants.TRAILING" }, description = "The horizontal alignment of the icon and text.")
public void setHorizontalAlignment(int alignment) 

Source Link

Document

Sets the horizontal alignment of the icon and text.

Usage

From source file:com.sec.ose.osi.ui.frm.main.manage.ManagedProjectTableModel.java

public void setColumnType(JTable table) {
    table.setShowVerticalLines(false);/*from   www .j  a  va  2s  .c  o  m*/
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(false);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setRowHeight(30);

    JTableHeader header = table.getTableHeader();
    header.setPreferredSize(new java.awt.Dimension(table.getTableHeader().getWidth(), 30));
    header.setFont(new Font("Arial", Font.BOLD, 12));
    header.setReorderingAllowed(false);

    TableColumnModel cm = table.getColumnModel();
    TableColumn col = null;

    analyzeHeader = new CheckBoxHeader(new CheckboxHeaderItemListener(table, COL_ANALYZE_TARGET),
            "Analyze Target");
    col = cm.getColumn(COL_ANALYZE_TARGET);
    col.setHeaderRenderer(analyzeHeader);

    JCheckBox chkbox = new JCheckBox();
    chkbox.setBackground(Color.white);
    chkbox.setHorizontalAlignment(JLabel.CENTER);
    col.setCellRenderer(new DefaultTableCellRenderer() {
        private static final long serialVersionUID = 1L;

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            ManagedProjectTableModel model = (ManagedProjectTableModel) table.getModel();

            String sPrjName = (String) table.getValueAt(row, ManagedProjectTableModel.COL_PROJECT_NAME);
            OSIProjectInfo item = model.getProjectInfo(sPrjName);

            JCheckBox chkbox = new JCheckBox();
            chkbox.setSelected(((Boolean) value).booleanValue());
            if (item != null) {
                chkbox.setEnabled(item.isLocationValid());
            }
            chkbox.setHorizontalAlignment(JLabel.CENTER);
            chkbox.setBackground(Color.white);

            return (Component) chkbox;
        }
    });
    col.setCellEditor(new DefaultCellEditor(chkbox));

    col = cm.getColumn(COL_ANALYZE_STATUS);
    col.setCellRenderer(new StatusIconCellRenderer());

    col = cm.getColumn(COL_SOURCE_LOCATION);
    col.setCellRenderer(new FileBrowseCellRenderer());
    col.setCellEditor(new FileBrowseCellEditor());
}

From source file:com.jbombardier.console.charts.XYTimeChartPanel.java

public XYTimeChartPanel() {

    DateAxis numberaxis = new DateAxis("Time");

    yAxis = new NumberAxis("Count");
    yAxis.setAutoRangeIncludesZero(true);

    XYSplineRenderer renderer = new XYSplineRenderer();
    // XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    xyplot = new XYPlot(xyseriescollection, numberaxis, yAxis, renderer);
    xyplot.setBackgroundPaint(Color.white);
    xyplot.setDomainGridlinePaint(Color.lightGray);
    xyplot.setRangeGridlinePaint(Color.lightGray);

    // xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D));

    // XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer)
    // xyplot.getRenderer();
    // xylineandshaperenderer.setBaseShapesVisible(false);
    // xylineandshaperenderer.setBaseShapesFilled(false);

    chart = new JFreeChart("Running threads", JFreeChart.DEFAULT_TITLE_FONT, xyplot, true);

    /*//from www  . ja va  2 s.  c  o  m
     * ValueMarker valuemarker1 = new ValueMarker(175D);
     * valuemarker1.setLabelOffsetType(LengthAdjustmentType.EXPAND);
     * valuemarker1.setPaint(Color.red); valuemarker1.setLabel("Target Price");
     * valuemarker1.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
     * valuemarker1.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
     * xyplot.addRangeMarker(valuemarker1);
     */

    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);

    // ChartUtilities.applyCurrentTheme(chart);
    setLayout(new BorderLayout());
    jFreeChartPanel = new ChartPanel(chart);
    jFreeChartPanel.setMinimumDrawHeight(0);
    jFreeChartPanel.setMinimumDrawWidth(0);
    jFreeChartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    jFreeChartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);

    add(jFreeChartPanel, BorderLayout.CENTER);

    JPanel controls = new JPanel(new MigLayout("gap 0, ins 0", "[grow,center,fill]", "[grow,center]"));
    final JCheckBox checkbox = new JCheckBox("Auto-scale");
    checkbox.setSelected(true);
    checkbox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            toggleAutoscroll(checkbox.isSelected());
        }
    });
    checkbox.setHorizontalAlignment(SwingConstants.RIGHT);
    controls.add(checkbox, "cell 0 0,alignx center");
    add(controls, BorderLayout.SOUTH);
}

From source file:org.nuclos.client.ui.collect.component.CollectableComponentTableCellEditor.java

@Override
public Component getTableCellEditorComponent(final JTable tbl, Object oValue, boolean bSelected, final int iRow,
        final int iColumn) {
    final CollectableComponent clctcomp = this.getCollectableComponent();
    log.debug("getTableCellEditorComponent - row: " + iRow + " - column: " + iColumn + " - component name: "
            + clctcomp.getFieldName() + " - selected: " + bSelected);

    this.editingRow = iRow;

    clctcomp.getModel().removeCollectableComponentModelListener(this);

    if (this.isSearchable()) {
        clctcomp.getSearchModel().setSearchCondition((CollectableSearchCondition) oValue);
    } else {//from  www.  java 2 s. com
        clctcomp.getModel().setField((CollectableField) oValue);
    }

    clctcomp.getModel().addCollectableComponentModelListener(this);

    boolean subformMinRowHeight = false;

    // a datefield gets a inputverifier
    /** @todo this needs to be called only once for the component - move to getCollectableComponent/ctor! */
    /** @todo no input verifier for searchable components? */
    if (!this.isSearchable() && clctcomp instanceof CollectableDateChooser) {
        final CollectableDateChooser clctdatechooser = (CollectableDateChooser) clctcomp;
        clctdatechooser.getDateChooser().getJTextField().setInputVerifier(editorDateInputVerifier);
    }
    if (!this.isSearchable() && clctcomp instanceof CollectableTextField) {
        final CollectableTextField clcttextfield = (CollectableTextField) clctcomp;
        clcttextfield.getJTextComponent().setInputVerifier(floatAndDoubleInputVerifier);
    }
    if (!this.isSearchable() && clctcomp instanceof CollectableComboBox) {
        final CollectableComboBox clctcombobox = (CollectableComboBox) clctcomp;
        ((JTextField) clctcombobox.getJComboBox().getEditor().getEditorComponent())
                .setInputVerifier(trueInputVerifier);
        //subformMinRowHeight = true;
    }
    if (!this.isSearchable() && clctcomp instanceof CollectableListOfValues) {
        final CollectableListOfValues clctlov = (CollectableListOfValues) clctcomp;
        clctlov.getJTextField().setInputVerifier(trueInputVerifier);
    }

    JComponent result = this.clctcomp.getJComponent();
    if (result instanceof LabeledComponent) {
        /** @todo find a better solution */
        result = ((LabeledComponent) result).getControlComponent();
    } else if (result instanceof JCheckBox) {
        final JCheckBox chkbx = (JCheckBox) result;
        chkbx.setHorizontalAlignment(JCheckBox.CENTER);
        /** @todo setting the colors here doesn't work as bSelected is false when clicking in a nonselected row. */
        //         result.setBackground(bSelected ? tbl.getSelectionBackground() : tbl.getBackground());
        //         result.setForeground(bSelected ? tbl.getSelectionForeground() : tbl.getForeground());
    }

    if (clctcomp instanceof DynamicRowHeightChangeProvider) {
        return result;
    } else {
        return new AlignTop(result, subformMinRowHeight);
    }
}