protected void installDefaults() { Color defaultGridColor = UIManager.getColor("Table.gridColor"); Color defaultForegroundColor = UIManager.getColor("Table.foreground"); Color defaultBackgroundColor = UIManager.getColor("Table.background"); Border defaultBorder = UIManager.getBorder("Table.scrollPaneBorder"); Color defaultSelectionForeground = UIManager.getColor("Table.selectionForeground"); Color defaultSelectionBackground = UIManager.getColor("Table.selectionBackground"); Color defaultFocusCellForeground = UIManager.getColor("Table.focusCellForeground"); Color defaultFocusCellBackground = new Color(153, 153, 204); Font defaultFont = UIManager.getFont("Table.font"); Border defaultGridBorder = UIManager.getBorder("Table.border"); InputMap inputMap = (InputMap) UIManager.get("Table.ancestorInputMap"); if (!installed) { UIManager.getDefaults().put("Grid.gridColor", defaultGridColor); UIManager.getDefaults().put("Grid.foreground", defaultForegroundColor); UIManager.getDefaults().put("Grid.background", defaultBackgroundColor); UIManager.getDefaults().put("Grid.selectionForegroundColor", defaultSelectionForeground); UIManager.getDefaults().put("Grid.selectionBackgroundColor", defaultSelectionBackground); UIManager.getDefaults().put("Grid.focusForegroundColor", defaultFocusCellForeground); UIManager.getDefaults().put("Grid.focusBackgroundColor", defaultFocusCellBackground); UIManager.getDefaults().put("Grid.border", defaultGridBorder); UIManager.getDefaults().put("Grid.font", defaultFont); UIManager.getDefaults().put("Grid.scrollPaneBorder", defaultBorder); UIManager.getDefaults().put("Grid.ancestorInputMap", inputMap); installed = true; } Color foregroundColor = grid.getForeground(); Color backgroundColor = grid.getBackground(); Font font = grid.getFont(); Border border = grid.getBorder(); Color gridColor = grid.getGridColor(); Color selectionForeground = grid.getSelectionForegroundColor(); Color selectionBackground = grid.getSelectionBackgroundColor(); Color focusForeground = grid.getFocusForegroundColor(); Color focusBackground = grid.getFocusBackgroundColor(); if (foregroundColor == null || foregroundColor instanceof UIResource) grid.setForeground(defaultForegroundColor); if (backgroundColor == null || backgroundColor instanceof UIResource) grid.setBackground(defaultBackgroundColor); if (font == null || font instanceof UIResource) grid.setFont(defaultFont); if (gridColor == null || gridColor instanceof UIResource) grid.setGridColor(defaultGridColor); if (border == null || border instanceof UIResource) grid.setBorder(defaultGridBorder); if (selectionForeground == null || selectionForeground instanceof UIResource) grid.setSelectionForegroundColor(defaultSelectionForeground); if (selectionBackground == null || selectionBackground instanceof UIResource) grid.setSelectionBackgroundColor(defaultSelectionBackground); if (focusForeground == null || focusForeground instanceof UIResource) grid.setFocusForegroundColor(defaultFocusCellForeground); if (focusBackground == null || focusBackground instanceof UIResource) grid.setFocusBackgroundColor(defaultFocusCellBackground); }
public MyRenderComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { super(); this.table = table; this.col = col; if (value != null) { setText(value.toString()); } else { setText(""); } setOpaque(false); setFont(UIManager.getFont("TableHeader.font")); setForeground(UIManager.getColor("TableHeader.foreground")); setHorizontalAlignment(JLabel.CENTER); setHorizontalTextPosition(SwingConstants.LEADING); setBorder(UIManager.getBorder("TableHeader.cellBorder")); if ((JTattooUtilities.getJavaVersion() >= 1.6) && (UIManager.getLookAndFeel() instanceof AbstractLookAndFeel)) { RowSorter rowSorter = table == null ? null : table.getRowSorter(); List keyList = rowSorter == null ? null : rowSorter.getSortKeys(); if ((keyList != null) && (keyList.size() > 0)) { RowSorter.SortKey sortKey = (RowSorter.SortKey) keyList.get(0); if (sortKey.getColumn() == table.convertColumnIndexToModel(col)) { AbstractIconFactory iconFactory = ((AbstractLookAndFeel) UIManager.getLookAndFeel()).getIconFactory(); if (sortKey.getSortOrder().equals(SortOrder.ASCENDING)) { setIcon(iconFactory.getUpArrowIcon()); } else if (sortKey.getSortOrder().equals(SortOrder.DESCENDING)) { setIcon(iconFactory.getDownArrowIcon()); } } } } gv = ColorHelper.getGrayValue(AbstractLookAndFeel.getTheme().getRolloverColor()); }
public FileNameRenderer(JTable table) { Border b = UIManager.getBorder("Table.noFocusBorder"); if (Objects.isNull(b)) { // Nimbus??? Insets i = focusCellHighlightBorder.getBorderInsets(textLabel); b = BorderFactory.createEmptyBorder(i.top, i.left, i.bottom, i.right); } noFocusBorder = b; p.setOpaque(false); panel.setOpaque(false); // http://www.icongalore.com/ XP Style Icons - Windows Application Icon, Software XP Icons nicon = new ImageIcon(getClass().getResource("wi0063-16.png")); sicon = new ImageIcon( p.createImage( new FilteredImageSource(nicon.getImage().getSource(), new SelectedImageFilter()))); iconLabel = new JLabel(nicon); iconLabel.setBorder(BorderFactory.createEmptyBorder()); p.add(iconLabel, BorderLayout.WEST); p.add(textLabel); panel.add(p, BorderLayout.WEST); Dimension d = iconLabel.getPreferredSize(); dim.setSize(d); table.setRowHeight(d.height); }
private void init() { isExperimentalSheet = UIManager.getBoolean("Sheet.experimentalSheet"); if (getOwner() != null && isShowAsSheet()) { if (isNativeSheetSupported()) { // J2SE 7 requires that we set undecorated to true. setUndecorated(true); getRootPane().putClientProperty("apple.awt.documentModalSheet", Boolean.TRUE); } else if (isExperimentalSheet()) { setUndecorated(true); } else { setUndecorated(true); getRootPane().setWindowDecorationStyle(JRootPane.NONE); getRootPane().setBorder(UIManager.getBorder("Sheet.border")); } if (isDocumentModalitySupported()) { Methods.invokeIfExistsWithEnum( this, "setModalityType", "java.awt.Dialog$ModalityType", "DOCUMENT_MODAL"); } } // We move the sheet when the user moves the owner, so that it // will always stay centered below the title bar of the owner. // If the user has moved the owner, we 'forget' the shift back location, // and don't shift the owner back to the place it was, when we opened // the sheet. ownerMovementHandler = new ComponentAdapter() { @Override public void componentMoved(ComponentEvent evt) { Window owner = getOwner(); Point newLocation = owner.getLocation(); if (!newLocation.equals(oldLocation)) { setLocation( newLocation.x + (owner.getWidth() - getWidth()) / 2, newLocation.y + owner.getInsets().top); shiftBackLocation = null; oldLocation = newLocation; } } }; // If the sheet is experimental, we need some special handling // so that the JSheet is handled correctly windowEventHandler = new WindowAdapter() { // public void windowIconified(WindowEvent e) { // TODO The sheet is reshown when the parent window is iconified. // setVisible(false) on the sheet only deiconifies the owner window. // } @Override public void windowActivated(WindowEvent e) { if (JSheet.this.isVisible() && JSheet.this.getOwner() == e.getWindow()) JSheet.this.toFront(); } }; }
/** * Creates the default renderer that will be used in a non-editiable combo box. A default renderer * will used only if a renderer has not been explicitly set with <code>setRenderer</code>. * * <p>This method differs from the superclass implementation in that it uses an empty border with * wider left and right margins of 2 pixels instead of 1. * * @return a <code>ListCellRender</code> used for the combo box * @see javax.swing.JComboBox#setRenderer */ protected ListCellRenderer createRenderer() { if (tableCellEditor) { return super.createRenderer(); } BasicComboBoxRenderer renderer = new BasicComboBoxRenderer.UIResource(); renderer.setBorder(UIManager.getBorder("ComboBox.rendererBorder")); return renderer; }
RowHeaderRenderer(JTable table) { JTableHeader header = table.getTableHeader(); setOpaque(true); setBorder(UIManager.getBorder("TableHeader.cellBorder")); setHorizontalAlignment(CENTER); setForeground(header.getForeground()); setBackground(header.getBackground()); setFont(header.getFont()); }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { setText(value.toString()); setBackground(isSelected ? list.getSelectionBackground() : list.getBackground()); setForeground(isSelected ? list.getSelectionForeground() : list.getForeground()); setFont(list.getFont()); setBorder( (cellHasFocus) ? UIManager.getBorder("List.focusCellHighlightBorder") : m_noFocusBorder); return this; }
protected void installDefaults() { String string = UIManager.getLookAndFeel().getName(); Color defaultGridColor = UIManager.getColor("Table.gridColor"); Color defaultForegroundColor = UIManager.getColor("TableHeader.foreground"); Color defaultBackgroundColor = UIManager.getColor("TableHeader.background"); Font defaultGridFont = UIManager.getFont("Table.font"); Border defaultGridBorder = UIManager.getBorder("TableHeader.border"); Color defaultSelectionForegroundColor = defaultForegroundColor.brighter(); Color defaultSelectionBackgroundColor = defaultBackgroundColor; Color defaultFocusForegroundColor = defaultForegroundColor.brighter(); Color defaultFocusBackgroundColor = defaultBackgroundColor.brighter(); if (!installedHeader) { UIManager.getDefaults().put("GridHeader.gridColor", defaultGridColor); UIManager.getDefaults().put("GridHeader.foreground", defaultForegroundColor); UIManager.getDefaults().put("GridHeader.background", defaultBackgroundColor); UIManager.getDefaults() .put("GridHeader.selectionForegroundColor", defaultSelectionForegroundColor); UIManager.getDefaults() .put("GridHeader.selectionBackgroundColor", defaultSelectionBackgroundColor); UIManager.getDefaults().put("GridHeader.focusForegroundColor", defaultFocusForegroundColor); UIManager.getDefaults().put("GridHeader.focusBackgroundColor", defaultFocusBackgroundColor); UIManager.getDefaults().put("GridHeader.border", defaultGridBorder); UIManager.getDefaults().put("GridHeader.font", defaultGridFont); } Color foregroundColor = gridHeader.getForeground(); Color backgroundColor = gridHeader.getBackground(); Font gridFont = gridHeader.getFont(); Border gridBorder = gridHeader.getBorder(); Color gridColor = gridHeader.getGridColor(); Color selectionForegroundColor = gridHeader.getSelectionForegroundColor(); Color selectionBackgroundColor = gridHeader.getSelectionBackgroundColor(); Color focusForegroundColor = gridHeader.getFocusForegroundColor(); Color focusBackgroundColor = gridHeader.getFocusBackgroundColor(); if (foregroundColor == null || foregroundColor instanceof UIResource) gridHeader.setForeground(defaultForegroundColor); if (backgroundColor == null || backgroundColor instanceof UIResource) gridHeader.setBackground(defaultBackgroundColor); if (gridColor == null || gridColor instanceof UIResource) gridHeader.setGridColor(defaultGridColor); if (gridFont == null || gridFont instanceof UIResource) gridHeader.setFont(defaultGridFont); if (gridBorder == null || gridBorder instanceof UIResource) gridHeader.setBorder(defaultGridBorder); if (selectionForegroundColor == null || selectionForegroundColor instanceof UIResource) gridHeader.setSelectionForegroundColor(defaultSelectionForegroundColor); if (selectionBackgroundColor == null || selectionBackgroundColor instanceof UIResource) gridHeader.setSelectionBackgroundColor(defaultSelectionBackgroundColor); if (focusForegroundColor == null || focusForegroundColor instanceof UIResource) gridHeader.setFocusForegroundColor(defaultFocusForegroundColor); if (focusBackgroundColor == null || focusBackgroundColor instanceof UIResource) gridHeader.setFocusBackgroundColor(defaultFocusBackgroundColor); }
protected ToolTipAttributes getSystemLookAndFeelAttributes() { Font font = UIManager.getFont("ToolTip.font"); Color textColor = UIManager.getColor("ToolTip.foreground"); Color interiorColor = UIManager.getColor("ToolTip.background"); Color outlineColor = javax.swing.UIManager.getColor("ToolTip.foreground"); double textOpacity = this.getOpacity(); double interiorOpacity = this.getOpacity(); double outlineOpacity = this.getOpacity(); double outlineWidth = this.getOutlineWidth(); Insets insets = null; Border border = UIManager.getBorder("ToolTip.border"); if (border instanceof LineBorder) // Implicitly checks for non-null. { outlineColor = ((LineBorder) border).getLineColor(); outlineWidth = ((LineBorder) border).getThickness(); } if (border != null) insets = border.getBorderInsets(null); if (font == null) font = this.getFont(); if (textColor == null) textColor = this.getTextColor(); if (interiorColor == null) interiorColor = this.getInteriorColor(); if (outlineColor == null) outlineColor = this.getOutlineColor(); if (insets == null) insets = this.getInsets(); return new ToolTipAttributes( font, textColor, interiorColor, outlineColor, textOpacity, interiorOpacity, outlineOpacity, outlineWidth, insets); }
public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (table != null) { JTableHeader header = table.getTableHeader(); if (header != null) { setForeground(header.getForeground()); setBackground(header.getBackground()); setFont(header.getFont()); } } if (isSelected) { setFont(getFont().deriveFont(Font.BOLD)); } setText((value == null) ? "" : value.toString()); setBorder(UIManager.getBorder("TableHeader.cellBorder")); return this; }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (containerBox == null) { containerBox = Box.createHorizontalBox(); checkBox = new JCheckBox(); checkBox.setEnabled(isEnabled()); checkBox.setFont(getFont()); checkBox.setFocusPainted(false); checkBox.setBorderPainted(true); checkBox.setBorder( isSelected ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder); containerBox.add(checkBox); } checkBox.setBackground(isSelected ? getSelectionBackground() : getBackground()); checkBox.setForeground(isSelected ? getSelectionForeground() : getForeground()); if (value != null) { ListItem item = (ListItem) value; checkBox.setText(item.dataItem.toString()); checkBox.setSelected(item.selected); } return containerBox; }
public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Color foreground = null; Color background = null; Font font = null; TableModel model = table.getModel(); if (model instanceof AttributiveCellTableModel) { CellAttribute cellAtt = ((AttributiveCellTableModel) model).getCellAttribute(); if (cellAtt instanceof ColoredCell) { foreground = ((ColoredCell) cellAtt).getForeground(row, column); background = ((ColoredCell) cellAtt).getBackground(row, column); } if (cellAtt instanceof CellFont) { font = ((CellFont) cellAtt).getFont(row, column); } } if (isSelected) { setForeground((foreground != null) ? foreground : table.getSelectionForeground()); setBackground(table.getSelectionBackground()); } else { setForeground((foreground != null) ? foreground : table.getForeground()); setBackground((background != null) ? background : table.getBackground()); } setFont((font != null) ? font : table.getFont()); if (hasFocus) { setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); if (table.isCellEditable(row, column)) { setForeground( (foreground != null) ? foreground : UIManager.getColor("Table.focusCellForeground")); setBackground(UIManager.getColor("Table.focusCellBackground")); } } else { setBorder(noFocusBorder); } setValue(value); return this; }
public Component getTableCellRendererComponent( JTable table, Setting owner, Object value, boolean isSelected, boolean hasFocus, boolean isEnabled, int row, int column) { // renderer.setMargin(new Insets(0, 2, 4, 2)); if (isSelected) { renderer.setForeground(table.getSelectionForeground()); panel.setBackground(table.getSelectionBackground()); blank1.setBackground(table.getSelectionBackground()); blank2.setBackground(table.getSelectionBackground()); } else { renderer.setForeground(table.getForeground()); panel.setBackground(table.getBackground()); blank1.setBackground(table.getBackground()); blank2.setBackground(table.getBackground()); } if (hasFocus) { panel.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); } else { panel.setBorder(new EmptyBorder(1, 2, 2, 1)); } if (value instanceof Color) { Color col = (Color) value; // System.out.println("setting background to "+col.toString()); renderer.setText("[" + col.getRed() + "," + col.getGreen() + "," + col.getBlue() + "]"); renderer.setEnabled(isEnabled); renderer.setFont(font); colourPanel.setBackground(col); } else if (value instanceof ArrayList) { ArrayList values = (ArrayList) value; if (values.size() > 0) { // if we have multiple properties selected. Color last = null; boolean allSame = true; for (int i = 0; i < values.size(); i++) { if (values.get(i) instanceof Color) { Color str = (Color) values.get(i); if (last != null) { if (!str.equals(last)) { allSame = false; break; } last = str; } else { last = str; } } } if (allSame) { renderer.setText( "[" + last.getRed() + "," + last.getGreen() + "," + last.getBlue() + "]"); renderer.setEnabled(isEnabled); renderer.setFont(font); colourPanel.setBackground(last); } else { renderer.setText("(Different values)"); renderer.setEnabled(isEnabled); renderer.setFont(font); colourPanel.setBackground(Color.lightGray); panel.setBackground(Color.lightGray); blank1.setBackground(Color.lightGray); blank2.setBackground(Color.lightGray); } } } return panel; }
private CellRenderer() { mySelectedBorder = UIManager.getBorder("List.focusCellHighlightBorder"); final Insets borderInsets = mySelectedBorder.getBorderInsets(new JCheckBox()); myBorder = new EmptyBorder(borderInsets); }
public Principal() { setResizable(false); setForeground(UIManager.getColor("CheckBoxMenuItem.selectionBackground")); setFont(new Font("Andalus", 1, 12)); setTitle("CEREAIS PEGER LTDA - EMISSOR DE RECIBO"); setIconImage( Toolkit.getDefaultToolkit() .getImage("img\\Super Collection\\Applications\\Script Editor.png")); setDefaultCloseOperation(0); setBounds(100, 100, 566, 497); JPanel contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(new BorderLayout(0, 0)); JLayeredPane layeredPane = new JLayeredPane(); layeredPane.setBorder( new CompoundBorder( new LineBorder(new Color(0, 0, 0), 3), new BevelBorder(1, null, null, null, null))); contentPane.add(layeredPane, "Center"); JButton btEmiteRecibo = new JButton("Emitir Recibo"); btEmiteRecibo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { new Recibo().setVisible(true); } }); btEmiteRecibo.setIcon(new ImageIcon("img\\PNG-48\\Modify.png")); btEmiteRecibo.setFont(new Font("Tahoma", 1, 12)); btEmiteRecibo.setBackground(UIManager.getColor("Button.focus")); btEmiteRecibo.setBounds(74, 212, 181, 56); layeredPane.add(btEmiteRecibo); JButton btRelatorio = new JButton("Relatórios"); btRelatorio.setIcon(new ImageIcon("img\\PNG-48\\Load.png")); btRelatorio.setFont(new Font("Tahoma", 1, 12)); btRelatorio.setBackground(SystemColor.inactiveCaptionBorder); btRelatorio.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new Relatorios().setVisible(true); } }); btRelatorio.setBounds(74, 279, 181, 56); layeredPane.add(btRelatorio); JButton btInfo = new JButton("Informações"); btInfo.setIcon(new ImageIcon("img\\PNG-48\\Info.png")); btInfo.setFont(new Font("Tahoma", 1, 12)); btInfo.setBackground(SystemColor.inactiveCaptionBorder); btInfo.setBounds(304, 279, 181, 56); layeredPane.add(btInfo); btInfo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { (new Informacoes()).setVisible(true); } }); JButton btSair = new JButton("Sair"); btSair.setIcon(new ImageIcon("img\\PNG-32\\Exit.png")); btSair.setFont(new Font("Tahoma", 1, 13)); btSair.setBackground(SystemColor.controlShadow); btSair.setBounds(379, 368, 106, 41); layeredPane.add(btSair); btSair.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (JOptionPane.showConfirmDialog( null, "Deseja Encerrar o programa?", "ATENÇÃO !!! ", 0) == 0) System.exit(EXIT_ON_CLOSE); } }); JButton btfornecedores = new JButton("Fornecedores"); btfornecedores.setIcon(new ImageIcon("img\\PNG-48\\Profile.png")); btfornecedores.setFont(new Font("Tahoma", 1, 12)); btfornecedores.setBackground(SystemColor.inactiveCaptionBorder); btfornecedores.setBounds(304, 212, 181, 56); layeredPane.add(btfornecedores); btfornecedores.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { new CrudFornecedores().setVisible(true); } }); JPanel panelRecibo = new JPanel(); panelRecibo.setForeground(UIManager.getColor("Button.disabledShadow")); panelRecibo.setBackground(UIManager.getColor("CheckBoxMenuItem.foreground")); panelRecibo.setBorder(UIManager.getBorder("DesktopIcon.border")); panelRecibo.setBounds(10, 11, 530, 77); layeredPane.add(panelRecibo); JLabel LabelRecibo = new JLabel("Emissor de Recibo Eletrônico"); LabelRecibo.setForeground(UIManager.getColor("Button.background")); LabelRecibo.setHorizontalAlignment(2); LabelRecibo.setIcon(new ImageIcon("img\\PNG-48\\Modify.png")); LabelRecibo.setFont(new Font("Tahoma", 3, 18)); panelRecibo.add(LabelRecibo); JPanel panel = new JPanel(); panel.setBackground(UIManager.getColor("CheckBox.foreground")); panel.setBounds(45, 420, 457, 26); layeredPane.add(panel); JLabel lblAnthonyTailerCopy = new JLabel(" Anthony Tailer Copyright © "); lblAnthonyTailerCopy.setForeground(UIManager.getColor("Button.background")); panel.add(lblAnthonyTailerCopy); JLabel lblNewLabel = new JLabel(""); lblNewLabel.setIcon(new ImageIcon("img\\LOGO PEGER 2.png")); lblNewLabel.setBounds(165, 99, 234, 88); layeredPane.add(lblNewLabel); }
private void initComponents() { panel1 = new JPanel(); label1 = new JLabel(); separator1 = new JSeparator(); button3 = new JButton(); button4 = new JButton(); button5 = new JButton(); scrollPane2 = new JScrollPane(); tableModel1 = new DefaultTableModel(); table1 = new JTable(tableModel1); panel2 = new JPanel(); label5 = new JLabel(); textField1 = new JTextField(); label2 = new JLabel(); label3 = new JLabel(); textField2 = new JTextField(); textField3 = new JTextField(); button1 = new JButton(); button2 = new JButton(); // ======== this ======== setResizable(false); Container contentPane = getContentPane(); contentPane.setLayout(null); // ======== panel1 ======== { panel1.setLayout(null); // ---- label1 ---- label1.setText("Manage Vat %"); panel1.add(label1); label1.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 30)); label1.setBounds(200, 10, 400, 50); panel1.add(separator1); separator1.setBounds(0, 100, 600, 5); // ======== panel2 ======== { panel2.setBorder(UIManager.getBorder("TitledBorder.border")); panel2.setLayout(null); // ---- label3 ---- label3.setText("<html>Year : <font color='red'><b>*</b></font></html>"); panel2.add(label3); label3.setBounds(new Rectangle(new Point(25, 25), label3.getPreferredSize())); panel2.add(textField1); textField1.setBounds(95, 25, 100, textField1.getPreferredSize().height); // ---- label5 ---- label5.setText("<html>To : <font color='red'><b>*</b></font></html>"); panel2.add(label5); label5.setBounds(new Rectangle(new Point(250, 25), label5.getPreferredSize())); panel2.add(textField2); textField2.setBounds(310, 25, 100, textField2.getPreferredSize().height); // ---- label2 ---- label2.setText("<html>Vat % : <font color='red'><b>*</b></font></html>"); panel2.add(label2); label2.setBounds(new Rectangle(new Point(25, 85), label2.getPreferredSize())); panel2.add(textField3); textField3.setBounds(95, 85, 315, textField3.getPreferredSize().height); // ---- button1 ---- button1.setText("Add"); panel2.add(button1); button1.setBounds(70, 150, 100, 30); button1.addActionListener(this); // ---- button2 ---- button2.setText("Clear"); panel2.add(button2); button2.setBounds(280, 150, 100, 30); button2.addActionListener(this); } panel1.add(panel2); panel2.setBounds(50, 125, 500, 200); tableModel1.addColumn("Sr. No."); tableModel1.addColumn("vat %"); tableModel1.addColumn("Year From"); tableModel1.addColumn("Year To"); // ======== scrollPane2 ======== { scrollPane2.setViewportView(table1); } panel1.add(scrollPane2); scrollPane2.setBounds(50, 340, 500, 250); // ---- button3 ---- button3.setText("Delete"); panel1.add(button3); button3.setBounds(50, 610, 150, 30); button3.addActionListener(this); // ---- button4 ---- button4.setText("Update"); panel1.add(button4); button4.setBounds(225, 610, 150, 30); button4.addActionListener(this); button4.setEnabled(false); // ---- button5 ---- button5.setText("Refresh"); panel1.add(button5); button5.setBounds(400, 610, 150, 30); button5.addActionListener(this); } contentPane.add(panel1); panel1.setBounds(0, 0, 600, 700); pack(); setVisible(true); setLocation(200, 10); setSize(600, 700); }
public void installUI(JComponent c) { super.installUI(c); c.setBorder(UIManager.getBorder("ProgressBar.border")); propertyChangeListener = new PropertyChangeHandler(); c.addPropertyChangeListener(propertyChangeListener); }
class FileNameRenderer implements TableCellRenderer { private final Dimension dim = new Dimension(); private final JPanel p = new JPanel(new BorderLayout()) { @Override public Dimension getPreferredSize() { return dim; } }; private final JPanel panel = new JPanel(new BorderLayout()); private final JLabel textLabel = new JLabel(" "); private final JLabel iconLabel; private final Border focusCellHighlightBorder = UIManager.getBorder("Table.focusCellHighlightBorder"); private final Border noFocusBorder; private final ImageIcon nicon; private final ImageIcon sicon; public FileNameRenderer(JTable table) { Border b = UIManager.getBorder("Table.noFocusBorder"); if (Objects.isNull(b)) { // Nimbus??? Insets i = focusCellHighlightBorder.getBorderInsets(textLabel); b = BorderFactory.createEmptyBorder(i.top, i.left, i.bottom, i.right); } noFocusBorder = b; p.setOpaque(false); panel.setOpaque(false); // http://www.icongalore.com/ XP Style Icons - Windows Application Icon, Software XP Icons nicon = new ImageIcon(getClass().getResource("wi0063-16.png")); sicon = new ImageIcon( p.createImage( new FilteredImageSource(nicon.getImage().getSource(), new SelectedImageFilter()))); iconLabel = new JLabel(nicon); iconLabel.setBorder(BorderFactory.createEmptyBorder()); p.add(iconLabel, BorderLayout.WEST); p.add(textLabel); panel.add(p, BorderLayout.WEST); Dimension d = iconLabel.getPreferredSize(); dim.setSize(d); table.setRowHeight(d.height); } @Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { textLabel.setFont(table.getFont()); textLabel.setText(Objects.toString(value, "")); textLabel.setBorder(hasFocus ? focusCellHighlightBorder : noFocusBorder); FontMetrics fm = table.getFontMetrics(table.getFont()); Insets i = textLabel.getInsets(); int swidth = iconLabel.getPreferredSize().width + fm.stringWidth(textLabel.getText()) + i.left + i.right; int cwidth = table.getColumnModel().getColumn(column).getWidth(); dim.width = swidth > cwidth ? cwidth : swidth; if (isSelected) { textLabel.setOpaque(true); textLabel.setForeground(table.getSelectionForeground()); textLabel.setBackground(table.getSelectionBackground()); iconLabel.setIcon(sicon); } else { textLabel.setOpaque(false); textLabel.setForeground(table.getForeground()); textLabel.setBackground(table.getBackground()); iconLabel.setIcon(nicon); } return panel; } }