Java Code Examples for javax.swing.JComponent.setBorder()

The following are Jave code examples for showing how to use setBorder() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: StartPageContent.java   View Source Code Vote up 6 votes
public StartPageContent() {
    super( new GridBagLayout() );

    JComponent tabs = new TabbedPane( new LearnAndDiscoverTab(),
            new MyNetBeansTab(),
            new WhatsNewTab());
    tabs.setBorder(BorderFactory.createEmptyBorder(10,15,15,15));
    tabs.setOpaque(false);

    add( tabs, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(27,0,0,0), 0, 0) );

    add( new JLabel(), new GridBagConstraints(0, 2, 1, 1, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0,0,0,0), 0, 0) );
}
 
Example 2
Project: incubator-netbeans   File: RepositorySelectorBuilder.java   View Source Code Vote up 5 votes
private static void addInsetsToPanel(JComponent comp) {
    LayoutStyle layoutStyle = LayoutStyle.getInstance();
    comp.setBorder(BorderFactory.createEmptyBorder(
            layoutStyle.getContainerGap(comp, NORTH, null),
            layoutStyle.getContainerGap(comp, WEST,  null),
            layoutStyle.getContainerGap(comp, SOUTH, null),
            layoutStyle.getContainerGap(comp, EAST,  null)));
}
 
Example 3
Project: incubator-netbeans   File: GuiUtils.java   View Source Code Vote up 5 votes
/**
 * Adds a given border to a given component.
 * If the component already has some border, the given border is put
 * around the existing border.
 *
 * @param  component  component the border should be added to
 * @param  border  the border to be added
 */
private static void addBorder(JComponent component,
                              Border newBorder) {
    Border currentBorder = component.getBorder();
    if (currentBorder == null) {
        component.setBorder(newBorder);
    } else {
        component.setBorder(BorderFactory.createCompoundBorder(
                newBorder,          //outside
                currentBorder));    //inside
    }
}
 
Example 4
Project: SER316-Dresden   File: TaskTreeTableCellRenderer.java   View Source Code Vote up 5 votes
private void applyFocus(boolean hasFocus, JComponent c) {
    if (hasFocus) {
        c.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, table.getSelectionBackground()
                .darker()));
    } else {
        if (c.getBorder() != null) {
            c.setBorder(null);
        }
    }
}
 
Example 5
Project: incubator-netbeans   File: JavaTestCreatorConfiguration.java   View Source Code Vote up 5 votes
/**
 * Adds a border and a title around a given component.
 * If the component already has some border, it is overridden (not kept).
 *
 * @param  component  component the border and title should be added to
 * @param  insets  insets between the component and the titled border
 * @param  title  text of the title
 */
private static void addTitledBorder(JComponent component,
                                    Insets insets,
                                    String title) {
    Border insideBorder = BorderFactory.createEmptyBorder(
            insets.top, insets.left, insets.bottom, insets.right);
    Border outsideBorder = new TitledBorder(
            BorderFactory.createEtchedBorder(), title);
    component.setBorder(new CompoundBorder(outsideBorder, insideBorder));
}
 
Example 6
Project: DicomViewer   File: VismeVerifier.java   View Source Code Vote up 5 votes
@Override
public boolean verify(JComponent input) {
    boolean isValid = isValid(input);
    if (!isValid) {
        input.setBorder(BorderFactory.createLineBorder(Color.red));
    } else {
        input.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    }
    return isValid;
}
 
Example 7
Project: Cognizant-Intelligent-Test-Scripter   File: Listeners.java   View Source Code Vote up 5 votes
@Override
public void mouseEntered(MouseEvent e) {
    JComponent now = (JComponent) e.getSource();
    if (now.getBorder() != Border.thumbPrevSelected) {
        now.setBorder(thumbPrevOnFocus);
    }
}
 
Example 8
Project: incubator-netbeans   File: JavaHelp.java   View Source Code Vote up 5 votes
private void init(Runnable run) {
    this.run = run;
    JComponent c = ProgressHandleFactory.createProgressComponent(progressHandle);
    c.setPreferredSize(new Dimension(3 * c.getPreferredSize().width, 3 * c.getPreferredSize().height));
    c.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
    getContentPane().add(c);
    progressHandle.start();
    getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(JavaHelp.class, "ACSD_Loading_Dialog"));  //NOI18N
    pack();
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension me = getSize();
    setLocation((screen.width - me.width) / 2, (screen.height - me.height) / 2);
}
 
Example 9
Project: rapidminer   File: DefaultRMCellEditor.java   View Source Code Vote up 5 votes
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
	Component c = super.getTableCellEditorComponent(table, value, isSelected, row, column);
	if (c instanceof JComponent && !(c instanceof JCheckBox)) {
		JComponent component = (JComponent) c;
		if (isSelected) {
			component.setBorder(FocusedComponentBorder.getInstance());
		} else {
			component.setBorder(null);
		}
	}
	return c;
}
 
Example 10
Project: Reinickendorf_SER316   File: TaskTreeTableCellRenderer.java   View Source Code Vote up 5 votes
private void applyFocus(boolean hasFocus, JComponent c) {
    if (hasFocus) {
        c.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, table.getSelectionBackground()
                .darker()));
    } else {
        if (c.getBorder() != null) {
            c.setBorder(null);
        }
    }
}
 
Example 11
Project: Equella   File: ItemdefExtraTabs.java   View Source Code Vote up 5 votes
@Override
public JPanel getComponent()
{
	JPanel temp = new JPanel(new BorderLayout());
	JTabbedPane p = new JTabbedPane();
	for( BaseEntityTab<ItemDefinition> t : extra )
	{
		JComponent comp = t.getComponent();
		comp.setBorder(AppletGuiUtils.DEFAULT_BORDER);
		p.add(comp, t.getTitle());
	}
	temp.add(p);
	return temp;
}
 
Example 12
Project: rapidminer   File: OnboardingDialog.java   View Source Code Vote up 5 votes
private void decorateJComponent(JComponent component) {
    String prop = (String)component.getClientProperty("com.rapidminer.ui.label.type");
    if("header".equals(prop)) {
        component.setFont(OPEN_SANS_LIGHT_28);
        component.setForeground(SwingTools.RAPIDMINER_ORANGE);
    } else if("bold".equals(prop)) {
        component.setFont(OPEN_SANS_SEMIBOLD_14);
        component.setForeground(Color.DARK_GRAY);
    } else if("normal".equals(prop)) {
        component.setFont(OPEN_SANS_LIGHT_14);
        component.setForeground(Color.DARK_GRAY);
    } else if("large".equals(prop)) {
        component.setFont(OPEN_SANS_SEMIBOLD_16);
        component.setForeground(Color.DARK_GRAY);
    }

    prop = (String)component.getClientProperty("com.rapidminer.ui.button.type");
    if("cfa".equals(prop)) {
        component.setFont(OPEN_SANS_SEMIBOLD_14);
        component.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15));
    } else if("normal".equals(prop)) {
        component.setFont(OPEN_SANS_LIGHT_14);
        component.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
        component.setMinimumSize(new Dimension(175, component.getPreferredSize().height));
        component.setPreferredSize(new Dimension(175, component.getPreferredSize().height));
    }

    prop = (String)component.getClientProperty("com.rapidmniner.ui.link_button.id");
    if(prop != null && component instanceof LinkButton) {
        ((LinkButton)component).setText(this.generateHTML(prop));
    }

    Color foregroundColor = (Color)component.getClientProperty("com.rapidminer.ui.label.foreground");
    if(foregroundColor != null) {
        component.setForeground(foregroundColor);
    }

}
 
Example 13
Project: incubator-netbeans   File: DefaultSuiteProjectOperationsImplementation.java   View Source Code Vote up 4 votes
private static JComponent wrapPanel(JComponent component) {
    component.setBorder(new EmptyBorder(12, 12, 12, 12));
    
    return component;
}
 
Example 14
Project: incubator-netbeans   File: DefaultProjectOperationsImplementation.java   View Source Code Vote up 4 votes
private static JComponent wrapPanel(JComponent component) {
    component.setBorder(new EmptyBorder(12, 12, 12, 12));
    
    return component;
}
 
Example 15
Project: Cognizant-Intelligent-Test-Scripter   File: AbstractRenderer.java   View Source Code Vote up 4 votes
protected void setEmpty(JComponent comp) {
    comp.setBorder(errorBorder);
    comp.setToolTipText(empty);
}
 
Example 16
Project: Rubus   File: SetupUtils.java   View Source Code Vote up 4 votes
public static void setEtchedTitledBorder(JComponent comp, String title) {
    comp.setBorder(new TitledBorder(getEtchedBorder(), title));
}
 
Example 17
Project: incubator-netbeans   File: HierarchyTopComponent.java   View Source Code Vote up 4 votes
@NbBundle.Messages({
    "TXT_NonActiveContent=<No View Available - Refresh Manually>",
    "TXT_InspectHierarchyHistory=<empty>",
    "TOOLTIP_RefreshContent=Refresh for entity under cursor",
    "TOOLTIP_OpenJDoc=Open Javadoc Window",
    "TOOLTIP_ViewHierarchyType=Hierachy View Type",
    "TOOLTIP_InspectHierarchyHistory=Inspect Hierarchy History"
})
public HierarchyTopComponent() {
    history = HistorySupport.getInstnace(this.getClass());
    jdocFinder = SelectJavadocTask.create(this);
    jdocTask = RP.create(jdocFinder);
    explorerManager = new ExplorerManager();
    rootChildren = new RootChildren();
    filters = new HierarchyFilters();
    explorerManager.setRootContext(Nodes.rootNode(rootChildren, filters));
    selectedNodes  = new InstanceContent();
    lookup = new AbstractLookup(selectedNodes);
    explorerManager.addPropertyChangeListener(this);
    initComponents();
    setName(Bundle.CTL_HierarchyTopComponent());
    setToolTipText(Bundle.HINT_HierarchyTopComponent());        
    viewTypeCombo = new JComboBox(new DefaultComboBoxModel(ViewType.values()));
    viewTypeCombo.setMinimumSize(new Dimension(MIN_TYPE_WIDTH,COMBO_HEIGHT));
    viewTypeCombo.addActionListener(this);
    viewTypeCombo.setToolTipText(Bundle.TOOLTIP_ViewHierarchyType());
    historyCombo = new JComboBox(HistorySupport.createModel(history, Bundle.TXT_InspectHierarchyHistory()));
    historyCombo.setMinimumSize(new Dimension(MIN_HISTORY_WIDTH,COMBO_HEIGHT));
    historyCombo.setRenderer(HistorySupport.createRenderer(history));
    historyCombo.addActionListener(this);
    historyCombo.setEnabled(false);
    historyCombo.getModel().addListDataListener(this);
    historyCombo.setToolTipText(Bundle.TOOLTIP_InspectHierarchyHistory());
    refreshButton = new JButton(ImageUtilities.loadImageIcon(REFRESH_ICON, true));
    refreshButton.addActionListener(this);
    refreshButton.setToolTipText(Bundle.TOOLTIP_RefreshContent());
    jdocButton = new JButton(ImageUtilities.loadImageIcon(JDOC_ICON, true));
    jdocButton.addActionListener(this);
    jdocButton.setToolTipText(Bundle.TOOLTIP_OpenJDoc());
    final Box upperToolBar = new MainToolBar(
        constrainedComponent(viewTypeCombo, GridBagConstraints.HORIZONTAL, 1.0, new Insets(0,0,0,0)),
        constrainedComponent(historyCombo, GridBagConstraints.HORIZONTAL, 1.5, new Insets(0,3,0,0)),
        constrainedComponent(refreshButton, GridBagConstraints.NONE, 0.0, new Insets(0,3,0,0)),
        constrainedComponent(jdocButton, GridBagConstraints.NONE, 0.0, new Insets(0,3,0,3)));
    add(decorateAsUpperPanel(upperToolBar), BorderLayout.NORTH);
    contentView = new JPanel();
    contentView.setLayout(new CardLayout());
    JPanel nonActiveContent = Utils.updateBackground(new JPanel());
    nonActiveContent.setLayout(new BorderLayout());
    nonActiveInfo = new JLabel(Bundle.TXT_NonActiveContent());
    nonActiveInfo.setEnabled(false);
    nonActiveInfo.setHorizontalAlignment(SwingConstants.CENTER);
    nonActiveContent.add(nonActiveInfo, BorderLayout.CENTER);
    btw = createBeanTreeView();
    contentView.add(nonActiveContent, NON_ACTIVE_CONTENT);
    contentView.add(btw, ACTIVE_CONTENT);
    add(contentView,BorderLayout.CENTER);
    lowerToolBar = new TapPanel();
    lowerToolBar.setOrientation(TapPanel.DOWN);
    final JComponent lowerButtons = filters.getComponent();
    lowerButtons.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 0));
    lowerToolBar.add(lowerButtons);
    final boolean expanded = NbPreferences.forModule(HierarchyTopComponent.class).
            getBoolean(PROP_LOWER_TOOLBAR_EXPANDED, true); //NOI18N
    lowerToolBar.setExpanded(expanded);
    lowerToolBar.addPropertyChangeListener(this);
    add(Utils.updateBackground(lowerToolBar), BorderLayout.SOUTH);
}
 
Example 18
Project: incubator-netbeans   File: TracerOptionsPanel.java   View Source Code Vote up 4 votes
private static void createBorder(JComponent component, Border border) {
    Border cBorder = component.getBorder();
    if (cBorder == null) component.setBorder(border);
    else component.setBorder(BorderFactory.createCompoundBorder(border, cBorder));
}
 
Example 19
Project: incubator-netbeans   File: UnitTable.java   View Source Code Vote up 4 votes
@Override
public Component prepareRenderer (TableCellRenderer renderer,
        int rowIndex, int vColIndex) {
    if (rowIndex < 0 || vColIndex < 0) {
        return null;
    }
    Component c = super.prepareRenderer (renderer, rowIndex, vColIndex);
    Color bgColor = getBackground ();
    Color bgColorDarker = getDarkerColor(bgColor);
    
    Unit u = model.getUnitAtRow(convertRowIndexToModel(rowIndex));
    if (u != null && !u.canBeMarked ()) {
        c.setForeground (Color.gray);
    } else {
        if (vColIndex == 1 && u != null && UpdateManager.TYPE.FEATURE.equals(u.updateUnit.getType())) {
            c.setFont(getFont().deriveFont(java.awt.Font.BOLD));
        } else {
            c.setFont(getFont());
        }
        if (isRowSelected(rowIndex)) {
            c.setForeground(getSelectionForeground());
        } else {
            c.setForeground(getForeground());
        }
    }
    if (!isCellSelected (rowIndex, vColIndex)) {
        if (rowIndex % 2 == 0 && !model.isExpansionControlAtRow(rowIndex)) {
            c.setBackground (bgColorDarker);
        } else {
            c.setBackground (bgColor);
        }
    } else if (model.isExpansionControlAtRow(rowIndex)) {
        c.setBackground (getBackground ());
        c.setForeground(getForeground());
        JComponent jc = (JComponent)c;
        jc.setBorder(BorderFactory.createEmptyBorder());
    }
    int fontHeight = c.getFontMetrics(c.getFont()).getHeight();
    if (rowHeight < 0 || rowHeight < fontHeight) {
        int def = new JTable().getRowHeight();
        rowHeight = Math.max(def, fontHeight);
        setRowHeight(rowHeight);
    }
    
    return c;
}
 
Example 20
Project: incubator-netbeans   File: TabbedController.java   View Source Code Vote up 4 votes
/** Replace placeholder with real panel and change help context. */
  private void handleTabSwitched(String searchText, List<String> matchedKeywords) {
      final int selectedIndex = pane.getSelectedIndex();
      if (selectedIndex != -1) {
          String tabTitle = pane.getTitleAt(selectedIndex);
          OptionsPanelController controller = tabTitle2controller.get(tabTitle);
          if (pane.getSelectedComponent() instanceof JLabel) {
              JComponent comp;
              if (controller == null) {
                  AdvancedOption advancedOption = tabTitle2Option.get(tabTitle);
                  if (advancedOption == null) {
                      LOGGER.log(Level.INFO, "AdvancedOption for {0} is not present.", tabTitle);
                      return;
                  } else {
                      controller = advancedOption.create();
                      tabTitle2controller.put(tabTitle, controller);
                      // must be here because many controllers rely on fact that getComponent() is called first than other methods
                      comp = controller.getComponent(masterLookup);
                      // add existing listeners
                      for (PropertyChangeListener pcl : pcs.getPropertyChangeListeners()) {
                          controller.addPropertyChangeListener(pcl);
                      }
                  }
              } else {
                  comp = controller.getComponent(masterLookup);
              }
              if( null == comp.getBorder() ) {
                  comp.setBorder(BorderFactory.createEmptyBorder(11,11,11,11));
              }
              JScrollPane scroll = new JScrollPane(comp);
              scroll.setBorder(BorderFactory.createEmptyBorder());
              scroll.setOpaque(false);
              scroll.getViewport().setOpaque(false);
              scroll.getVerticalScrollBar().setUnitIncrement(Utils.ScrollBarUnitIncrement);
              scroll.getHorizontalScrollBar().setUnitIncrement(Utils.ScrollBarUnitIncrement);
              pane.setComponentAt(selectedIndex, scroll);
              controller.update();
controller.isValid();
          }
   if (searchText != null && matchedKeywords != null) {
controller.handleSuccessfulSearch(searchText, matchedKeywords);
          }
          pcs.firePropertyChange(OptionsPanelController.PROP_HELP_CTX, null, null);
      }
  }