List of usage examples for javax.swing JComponent setBorder
@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.") public void setBorder(Border border)
From source file:org.martus.client.swingui.dialogs.UiChartPreviewDlg.java
private JComponent createScrollablePreview(JFreeChart chart) { JLabel label = createChartComponent(chart); JComponent scrollablePreview = new UiScrollPane(label); scrollablePreview.setBorder(new EmptyBorder(5, 5, 5, 5)); return scrollablePreview; }
From source file:MyButtonUI.java
public void mousePressed(MouseEvent e) { JComponent c = (JComponent) e.getComponent(); c.setBorder(m_borderLowered); c.setBackground(m_backgroundPressed); }
From source file:MyButtonUI.java
public void mouseReleased(MouseEvent e) { JComponent c = (JComponent) e.getComponent(); c.setBorder(m_borderRaised); c.setBackground(m_backgroundNormal); }
From source file:MyButtonUI.java
public void keyPressed(KeyEvent e) { int code = e.getKeyCode(); if (code == KeyEvent.VK_ENTER || code == KeyEvent.VK_SPACE) { JComponent c = (JComponent) e.getComponent(); c.setBorder(m_borderLowered); c.setBackground(m_backgroundPressed); }//from w w w . j a v a 2 s . co m }
From source file:MyButtonUI.java
public void keyReleased(KeyEvent e) { int code = e.getKeyCode(); if (code == KeyEvent.VK_ENTER || code == KeyEvent.VK_SPACE) { JComponent c = (JComponent) e.getComponent(); c.setBorder(m_borderRaised); c.setBackground(m_backgroundNormal); }//from www . j a va 2s .c o m }
From source file:com.moneydance.modules.features.importlist.table.HeaderRenderer.java
@Override public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) { Component component = this.defaultHeaderTableCellRenderer.getTableCellRendererComponent(table, value, hasFocus, hasFocus, row, column); if (component instanceof JComponent) { JComponent jComponent = (JComponent) component; jComponent.setBorder(new EmptyBorder(1, 1, 1, 1)); jComponent.setOpaque(false);/* w w w. j a va 2 s .c o m*/ if (jComponent instanceof JLabel) { JLabel jLabel = (JLabel) jComponent; jLabel.setHorizontalAlignment(SwingConstants.LEFT); } } component.setFont(Preferences.getHeaderFont()); component.setForeground(Preferences.getHeaderForeground()); component.setSize( new Dimension(component.getWidth(), Helper.INSTANCE.getPreferences().getHeaderRowHeight())); component.setMinimumSize( new Dimension(component.getWidth(), Helper.INSTANCE.getPreferences().getHeaderRowHeight())); component.setPreferredSize( new Dimension(component.getWidth(), Helper.INSTANCE.getPreferences().getHeaderRowHeight())); component.setMaximumSize( new Dimension(component.getWidth(), Helper.INSTANCE.getPreferences().getHeaderRowHeight())); return component; }
From source file:lu.lippmann.cdb.common.gui.MultiPanel.java
/** * Constructor./*from ww w . j av a2s . c o m*/ */ public MultiPanel(final ListOrderedMap<JComponent, Integer> mapPanels, final int w, final int h, final boolean withWeight) { final int total = mapPanels.keySet().size(); if (!withWeight) setLayout(new GridLayout(0, 1)); final int w2 = w - 10 * total; final int h2 = h - 75; final Map<JComponent, Color> choosedColor = new HashMap<JComponent, Color>(); int i = 0; for (final JComponent p : mapPanels.keySet()) { final Dimension size = new Dimension((int) (w2 * (mapPanels.get(p) / 100.0)), h2); p.setPreferredSize(size); choosedColor.put(p, COLORS[i]); p.setBackground(COLORS[i]); p.setBorder(BorderFactory.createLineBorder(Color.BLACK)); add(p); i++; } if (withWeight) { /** add percents **/ for (final JComponent p : mapPanels.keySet()) { final int perc = mapPanels.get(p); final int percent = (int) (w2 * (mapPanels.get(p) / 100.0)); final Dimension size = new Dimension(percent, 20); final JPanel arrow = new JPanel(); arrow.setPreferredSize(size); final JLabel label = new JLabel(perc + "%"); label.setForeground(choosedColor.get(p).darker()); arrow.add(label); add(arrow); } } }
From source file:com.diversityarrays.kdxplore.field.OriginDirectionTraversalChoicePanel.java
private JComponent withInsets(JComponent comp, Insets insets) { comp.setBorder(new EmptyBorder(insets)); return comp;/*from w ww.j a v a2s .c o m*/ }
From source file:BoxAlignmentDemo.java
protected JPanel createLabelAndComponent(boolean doItRight) { JPanel pane = new JPanel(); JComponent component = new JPanel(); Dimension size = new Dimension(150, 100); component.setMaximumSize(size);/*from w ww . j ava2 s .co m*/ component.setPreferredSize(size); component.setMinimumSize(size); TitledBorder border = new TitledBorder(new LineBorder(Color.black), "A JPanel", TitledBorder.CENTER, TitledBorder.BELOW_TOP); border.setTitleColor(Color.black); component.setBorder(border); JLabel label = new JLabel("This is a JLabel"); String title; if (doItRight) { title = "Matched"; label.setAlignmentX(CENTER_ALIGNMENT); } else { title = "Mismatched"; } pane.setBorder(BorderFactory.createTitledBorder(title)); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); pane.add(label); pane.add(component); return pane; }
From source file:BoxAlignmentDemo.java
protected JPanel createYAlignmentExample(boolean doItRight) { JPanel pane = new JPanel(); String title;/*from ww w . j a va 2 s . c om*/ JComponent component1 = new JPanel(); Dimension size = new Dimension(100, 50); component1.setMaximumSize(size); component1.setPreferredSize(size); component1.setMinimumSize(size); TitledBorder border = new TitledBorder(new LineBorder(Color.black), "A JPanel", TitledBorder.CENTER, TitledBorder.BELOW_TOP); border.setTitleColor(Color.black); component1.setBorder(border); JComponent component2 = new JPanel(); size = new Dimension(100, 50); component2.setMaximumSize(size); component2.setPreferredSize(size); component2.setMinimumSize(size); border = new TitledBorder(new LineBorder(Color.black), "A JPanel", TitledBorder.CENTER, TitledBorder.BELOW_TOP); border.setTitleColor(Color.black); component2.setBorder(border); if (doItRight) { title = "Matched"; } else { component1.setAlignmentY(TOP_ALIGNMENT); title = "Mismatched"; } pane.setBorder(BorderFactory.createTitledBorder(title)); pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS)); pane.add(component1); pane.add(component2); return pane; }