本文整理汇总了Java中javax.swing.JComponent.getBorder方法的典型用法代码示例。如果您正苦于以下问题:Java JComponent.getBorder方法的具体用法?Java JComponent.getBorder怎么用?Java JComponent.getBorder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComponent
的用法示例。
在下文中一共展示了JComponent.getBorder方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: wrapDialogContent
import javax.swing.JComponent; //导入方法依赖的package包/类
/**
*/
private static JComponent wrapDialogContent(JComponent comp,
boolean selfResizing) {
JComponent result;
if ((comp.getBorder() != null) || selfResizing) {
result = selfResizing ? new SelfResizingPanel() : new JPanel();
result.setLayout(new GridLayout());
result.add(comp);
} else {
result = comp;
}
result.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
result.getAccessibleContext().setAccessibleDescription(bundle.getString("AD_title_select_generator"));
return result;
}
示例2: handleSummary
import javax.swing.JComponent; //导入方法依赖的package包/类
void handleSummary(Summary summary)
{
inSummary = true;
JComponent summaryComp = (JComponent) summary.getSummaryComponent(); // XXX
if (summaryComp.getBorder() != null)
{
CompoundBorder b = new CompoundBorder(new EmptyBorder(5, 5, 5, 5), summaryComp
.getBorder());
summaryComp.setBorder(b);
}
setCurrentWizardPanel(summaryComp); // XXX
instructions.setInSummaryPage(true);
ttlLabel.setText(NbBridge.getString("org/netbeans/api/wizard/Bundle", // NOI18N
WizardDisplayerImpl.class, "Summary")); // NOI18N
getButtonManager().setSummaryShowingMode();
summaryComp.requestFocus();
}
示例3: applyFocus
import javax.swing.JComponent; //导入方法依赖的package包/类
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);
}
}
}
示例4: getRenderer
import javax.swing.JComponent; //导入方法依赖的package包/类
JComponent getRenderer(PropertyDisplayer_Inline inline) {
inGetRenderer = true;
JComponent result = rfactory(inline).getRenderer(inline.getProperty());
if (inline.isTableUI() && null == result.getBorder() ) {
//Actually want an empty border, not null - some components treat
//a null border as an invitation to improvise
result.setBorder(BorderFactory.createEmptyBorder());
}
inGetRenderer = false;
return result;
}
示例5: handleTabSwitched
import javax.swing.JComponent; //导入方法依赖的package包/类
private void handleTabSwitched(String searchText, List<String> matchedKeywords) {
final int selectedIndex = tabbedPanel.getSelectedIndex() >= 0 ? tabbedPanel.getSelectedIndex() : -1;
if (selectedIndex != -1) {
String category = tabbedPanel.getTitleAt(selectedIndex);
if (tabbedPanel.getSelectedComponent() instanceof JLabel) {
JComponent panel = model.getPanel(category);
if( null == panel.getBorder() ) {
panel.setBorder(BorderFactory.createEmptyBorder(11,11,11,11));
}
JScrollPane scroll = new JScrollPane(panel);
scroll.setOpaque(false);
scroll.getViewport().setOpaque(false);
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.getVerticalScrollBar().setUnitIncrement(Utils.ScrollBarUnitIncrement);
scroll.getHorizontalScrollBar().setUnitIncrement(Utils.ScrollBarUnitIncrement);
tabbedPanel.setComponentAt(tabbedPanel.getSelectedIndex(), scroll);
}
model.update(category);
if (searchText != null && matchedKeywords != null) {
OptionsPanelController controller = model.getController(model.getID(category));
if(controller == null) {
LOGGER.log(Level.WARNING, "No controller found for category: {0}", category); //NOI18N
} else {
controller.handleSuccessfulSearch(searchText, matchedKeywords);
}
}
firePropertyChange (OptionsPanelController.PROP_HELP_CTX, null, null);
}
}
示例6: addBorder
import javax.swing.JComponent; //导入方法依赖的package包/类
/**
* 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
}
}
示例7: getCBRBPadding
import javax.swing.JComponent; //导入方法依赖的package包/类
private int getCBRBPadding(JComponent c, int position) {
if (c.getUIClassID() == "CheckBoxUI" ||
c.getUIClassID() == "RadioButtonUI") {
Border border = c.getBorder();
if (border instanceof UIResource) {
return getInset(c, position);
}
}
return 0;
}
示例8: mouseExited
import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public void mouseExited(MouseEvent e) {
JComponent now = (JComponent) e.getSource();
if (now.getBorder() != Border.thumbPrevSelected) {
now.setBorder(thumbPrevOffFocus);
}
}
示例9: createBorder
import javax.swing.JComponent; //导入方法依赖的package包/类
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));
}
示例10: createStrut
import javax.swing.JComponent; //导入方法依赖的package包/类
private static Component createStrut(JComponent c, int width, boolean before) {
Border b = c.getBorder();
Insets i = b != null ? b.getBorderInsets(c) : null;
int w = i == null ? width : Math.max(width - (before ? i.left : i.right), 0);
return Box.createHorizontalStrut(w);
}
示例11: handleTabSwitched
import javax.swing.JComponent; //导入方法依赖的package包/类
/** 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);
}
}
示例12: enlargeBorder
import javax.swing.JComponent; //导入方法依赖的package包/类
private static void enlargeBorder(JComponent c, int t, int l, int b, int r) {
Border current = c.getBorder();
Border larger = BorderFactory.createEmptyBorder(t, l, b, r);
if (current == null) c.setBorder(larger);
else c.setBorder(BorderFactory.createCompoundBorder(larger, current));
}
示例13: addAsFrame
import javax.swing.JComponent; //导入方法依赖的package包/类
/**
* Adds a component on this Canvas inside a frame.
*
* @param comp The component to add to the canvas.
* @param toolBox Should be set to true if the resulting frame is
* used as a toolbox (that is: it should not be counted as a
* frame).
* @param popupPosition A preferred {@code PopupPosition}.
* @param resizable Whether this component can be resized.
* @return The {@code JInternalFrame} that was created and added.
*/
private JInternalFrame addAsFrame(JComponent comp, boolean toolBox,
PopupPosition popupPosition,
boolean resizable) {
final int FRAME_EMPTY_SPACE = 60;
final JInternalFrame f = (toolBox) ? new ToolBoxFrame()
: new JInternalFrame();
if (f.getContentPane() instanceof JComponent) {
JComponent c = (JComponent) f.getContentPane();
c.setOpaque(false);
c.setBorder(null);
}
if (comp.getBorder() != null) {
if (comp.getBorder() instanceof EmptyBorder) {
f.setBorder(Utility.blankBorder(10, 10, 10, 10));
} else {
f.setBorder(comp.getBorder());
comp.setBorder(Utility.blankBorder(5, 5, 5, 5));
}
} else {
f.setBorder(null);
}
final FrameMotionListener fml = new FrameMotionListener(f);
comp.addMouseMotionListener(fml);
comp.addMouseListener(fml);
if (f.getUI() instanceof BasicInternalFrameUI) {
BasicInternalFrameUI biu = (BasicInternalFrameUI) f.getUI();
biu.setNorthPane(null);
biu.setSouthPane(null);
biu.setWestPane(null);
biu.setEastPane(null);
}
f.getContentPane().add(comp);
f.setOpaque(false);
f.pack();
int width = f.getWidth();
int height = f.getHeight();
if (width > getWidth() - FRAME_EMPTY_SPACE) {
width = Math.min(width, getWidth());
}
if (height > getHeight() - FRAME_EMPTY_SPACE) {
height = Math.min(height, getHeight());
}
f.setSize(width, height);
Point p = chooseLocation(comp, width, height, popupPosition);
f.setLocation(p);
this.add(f, MODAL_LAYER);
f.setName(comp.getClass().getSimpleName());
f.setFrameIcon(null);
f.setVisible(true);
f.setResizable(resizable);
try {
f.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
return f;
}
示例14: localizeBorder
import javax.swing.JComponent; //导入方法依赖的package包/类
/**
* Localize the a titled border.
*
* @param component The {@code JComponent} to localize.
* @param template The {@code StringTemplate} to use.
*/
public static void localizeBorder(JComponent component,
StringTemplate template) {
TitledBorder tb = (TitledBorder)component.getBorder();
tb.setTitle(Messages.message(template));
}