Java Code Examples for javax.swing.JLabel#getBorder()
The following examples show how to use
javax.swing.JLabel#getBorder() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DateTableEditor.java From LGoodDatePicker with MIT License | 7 votes |
/** * Constructor, with options. * * @param autoAdjustMinimumTableRowHeight Set this to true to have this class automatically * adjust the the minimum row height of all rows in the table, the first time that a * DateTableEditor is displayed. Set this to false to turn off any row height adjustments. The * default value is true. * * @param matchTableBackgroundColor This indicates whether this table editor should set the * picker text area background color to match the background color of the table. The default * value is true. * * @param matchTableSelectionBackgroundColor This indicates whether this table editor should set * the picker text area background color to match the background color of the table selection * (when selected). The default value is true. */ public DateTableEditor(boolean autoAdjustMinimumTableRowHeight, boolean matchTableBackgroundColor, boolean matchTableSelectionBackgroundColor) { // Save the constructor parameters. this.autoAdjustMinimumTableRowHeight = autoAdjustMinimumTableRowHeight; this.matchTableBackgroundColor = matchTableBackgroundColor; this.matchTableSelectionBackgroundColor = matchTableSelectionBackgroundColor; // Create the borders that should be used for focused and unfocused cells. JLabel exampleDefaultRenderer = (JLabel) new DefaultTableCellRenderer(). getTableCellRendererComponent(new JTable(), "", true, true, 0, 0); borderFocusedCell = exampleDefaultRenderer.getBorder(); borderUnfocusedCell = new EmptyBorder(1, 1, 1, 1); // Create and set up the date picker. datePicker = new DatePicker(); datePicker.setBorder(borderUnfocusedCell); datePicker.getComponentDateTextField().setBorder(null); // Adjust any needed date picker settings. DatePickerSettings settings = datePicker.getSettings(); settings.setGapBeforeButtonPixels(0); settings.setSizeTextFieldMinimumWidthDefaultOverride(false); settings.setSizeTextFieldMinimumWidth(20); // Calculate and store the minimum row height needed to display the date picker. minimumRowHeightInPixels = (datePicker.getPreferredSize().height + 1); }
Example 2
Source File: FlatTableHeaderUI.java From FlatLaf with Apache License 2.0 | 6 votes |
@Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column ) { Component c = delegate.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, column ); if( !(c instanceof JLabel) ) return c; l = (JLabel) c; if( sortIconPosition == SwingConstants.LEFT ) { if( oldHorizontalTextPosition < 0 ) oldHorizontalTextPosition = l.getHorizontalTextPosition(); l.setHorizontalTextPosition( SwingConstants.RIGHT ); } else { // top or bottom sortIcon = l.getIcon(); origBorder = l.getBorder(); l.setIcon( null ); l.setBorder( this ); } return l; }
Example 3
Source File: TimeTableEditor.java From LGoodDatePicker with MIT License | 6 votes |
/** * Constructor, with options. * * @param autoAdjustMinimumTableRowHeight Set this to true to have this class automatically * adjust the the minimum row height of all rows in the table, the first time that a * TimeTableEditor is displayed. Set this to false to turn off any row height adjustments. The * default value is true. */ public TimeTableEditor(boolean autoAdjustMinimumTableRowHeight, boolean matchTableBackgroundColor, boolean matchTableSelectionBackgroundColor) { // Save the constructor parameters. this.autoAdjustMinimumTableRowHeight = autoAdjustMinimumTableRowHeight; this.matchTableBackgroundColor = matchTableBackgroundColor; this.matchTableSelectionBackgroundColor = matchTableSelectionBackgroundColor; // Create the borders that should be used for focused and unfocused cells. JLabel exampleDefaultRenderer = (JLabel) new DefaultTableCellRenderer(). getTableCellRendererComponent(new JTable(), "", true, true, 0, 0); borderFocusedCell = exampleDefaultRenderer.getBorder(); borderUnfocusedCell = new EmptyBorder(1, 1, 1, 1); // Create and set up the time picker. timePicker = new TimePicker(); timePicker.setEnableArrowKeys(false); timePicker.setBorder(borderUnfocusedCell); timePicker.getComponentTimeTextField().setBorder(null); // Adjust any needed time picker settings. TimePickerSettings settings = timePicker.getSettings(); settings.setGapBeforeButtonPixels(0); settings.setSizeTextFieldMinimumWidthDefaultOverride(false); settings.setSizeTextFieldMinimumWidth(20); // Calculate and store the minimum row height needed to display the time picker. minimumRowHeightInPixels = (timePicker.getPreferredSize().height + 1); }
Example 4
Source File: ScaleFactorsTableModel.java From opensim-gui with Apache License 2.0 | 6 votes |
public Component getScaleFactorsSubCellRenderer(JTable table, BodyScaleFactors scaleFactors, boolean isSelected, boolean hasFocus, int row, int col, int i, int n) { String str; Font font = null; if(scaleFactors.useManualScale()) { str = numberFormat.format(scaleFactors.manualScales[i]); font = boldFont; } else { if(scaleFactors.measurements[i]==-1) str = "1.0"; else { Double val = scaleToolModel.getMeasurementValue(scaleFactors.measurements[i]); if(val==null) str = "?"; else str = numberFormat.format(val); } font = regularFont; } setBackground(null); setForeground(null); JLabel label = (JLabel)super.getTableCellRendererComponent(table,str,isSelected,hasFocus,row,col); intendedBorder = label.getBorder(); if(n==3) label.setBorder(interiorBorders[i]); else label.setBorder(null); label.setHorizontalAlignment(SwingConstants.TRAILING); label.setFont(font); return label; }
Example 5
Source File: DateTimeTableEditor.java From LGoodDatePicker with MIT License | 5 votes |
/** * Constructor, with options. * * @param autoAdjustMinimumTableRowHeight Set this to true to have this class automatically * adjust the the minimum row height of all rows in the table, the first time that a * DateTimeTableEditor is displayed. Set this to false to turn off any row height adjustments. * The default value is true. */ public DateTimeTableEditor(boolean autoAdjustMinimumTableRowHeight, boolean matchTableBackgroundColor, boolean matchTableSelectionBackgroundColor) { // Save the constructor parameters. this.autoAdjustMinimumTableRowHeight = autoAdjustMinimumTableRowHeight; this.matchTableBackgroundColor = matchTableBackgroundColor; this.matchTableSelectionBackgroundColor = matchTableSelectionBackgroundColor; // Create the borders that should be used for focused and unfocused cells. JLabel exampleDefaultRenderer = (JLabel) new DefaultTableCellRenderer(). getTableCellRendererComponent(new JTable(), "", true, true, 0, 0); borderFocusedCell = exampleDefaultRenderer.getBorder(); borderUnfocusedCell = new EmptyBorder(1, 1, 1, 1); // Create and set up the DateTimePicker. dateTimePicker = new DateTimePicker(); dateTimePicker.timePicker.setEnableArrowKeys(false); dateTimePicker.setBorder(borderUnfocusedCell); dateTimePicker.setGapSize(2, ConstantSize.PIXEL); dateTimePicker.setBackground(Color.white); dateTimePicker.datePicker.setBackground(Color.white); dateTimePicker.timePicker.setBackground(Color.white); dateTimePicker.datePicker.getComponentDateTextField().setBorder(null); dateTimePicker.timePicker.getComponentTimeTextField().setBorder(null); // Adjust any needed picker settings. DatePickerSettings dateSettings = dateTimePicker.datePicker.getSettings(); dateSettings.setGapBeforeButtonPixels(0); dateSettings.setSizeTextFieldMinimumWidthDefaultOverride(false); dateSettings.setSizeTextFieldMinimumWidth(20); TimePickerSettings timeSettings = dateTimePicker.timePicker.getSettings(); timeSettings.setGapBeforeButtonPixels(0); timeSettings.setSizeTextFieldMinimumWidthDefaultOverride(false); timeSettings.setSizeTextFieldMinimumWidth(20); // Calculate and store the minimum row height needed to display the DateTimePicker. minimumRowHeightInPixels = (dateTimePicker.getPreferredSize().height + 1); }
Example 6
Source File: ScaleFactorsTableModel.java From opensim-gui with Apache License 2.0 | 5 votes |
public Component getMeasurementSubCellRenderer(JTable table, BodyScaleFactors scaleFactors, boolean isSelected, boolean hasFocus, int row, int col, int i, int n) { String name; Font font = null; boolean valid = true; if(scaleFactors.useManualScale()) { name = "MANUAL SCALES"; font = boldFont; } else { name = (scaleFactors.measurements[i]==-1) ? ScaleFactorsTableModel.unassignedMeasurement : scaleToolModel.getMeasurementName(scaleFactors.measurements[i]); font = regularFont; if(scaleFactors.measurements[i]!=-1 && scaleToolModel.getMeasurementValue(scaleFactors.measurements[i])==null) valid = false; } // Reset bg/fg colors before calling super.getTableCellRendererComponent() setBackground(null); setForeground(null); JLabel label = (JLabel)super.getTableCellRendererComponent(table,name,isSelected,hasFocus,row,col); intendedBorder = label.getBorder(); if(n==3) label.setBorder(interiorBorders[i]); else label.setBorder(null); label.setHorizontalAlignment(SwingConstants.LEADING); label.setFont(font); // Override bg/fg colors for invalid measurment (most likely it refers to markers which are not available in the model) if(!valid) { if(isSelected) label.setForeground(invalidColor); else label.setBackground(invalidColor); } return label; }
Example 7
Source File: OptionsDialog.java From CQL with GNU Affero General Public License v3.0 | 4 votes |
/** * Creates a JPanel with the specified options. Interal use only. * * @param opts the options * @return a jpanel */ private static JPanel optionsPanel(final List<Option> opts) { final JPanel options = new JPanel(); final GroupLayout gl = new GroupLayout(options); options.setLayout(gl); gl.setAutoCreateGaps(true); gl.setAutoCreateContainerGaps(true); final GroupLayout.ParallelGroup labels = gl.createParallelGroup(); final GroupLayout.ParallelGroup values = gl.createParallelGroup(); final GroupLayout.ParallelGroup titles = gl.createParallelGroup(); final GroupLayout.ParallelGroup horiz = gl.createParallelGroup(); final GroupLayout.SequentialGroup cols = gl.createSequentialGroup(); final GroupLayout.SequentialGroup rows = gl.createSequentialGroup(); cols.addGroup(labels); cols.addGroup(values); horiz.addGroup(cols); horiz.addGroup(titles); for (final Option o : opts) { final JLabel l = o.getLabel(); final JComponent c = o.getComponent(); if (c == null) { // This is a label-only row, allowed to take up the whole row titles.addComponent(l); rows.addComponent(l); } else { if (l.getBorder() == null) { l.setBorder(new EmptyBorder(3, 0, 0, 0)); } if (l.getLabelFor() == null) { l.setLabelFor(c); } labels.addComponent(l); values.addComponent(c); final GroupLayout.ParallelGroup row = gl.createParallelGroup(GroupLayout.Alignment.BASELINE); row.addComponent(l); row.addComponent(c); rows.addGroup(row); } } gl.setHorizontalGroup(horiz); gl.setVerticalGroup(rows); return options; }