本文整理匯總了Java中javax.swing.JButton.setBorder方法的典型用法代碼示例。如果您正苦於以下問題:Java JButton.setBorder方法的具體用法?Java JButton.setBorder怎麽用?Java JButton.setBorder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JButton
的用法示例。
在下文中一共展示了JButton.setBorder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createDetails
import javax.swing.JButton; //導入方法依賴的package包/類
private JComponent createDetails(String text, ActionListener action) {
try {
text = (action == null ? "<html>" : "<html><a href=\"_blank\">") + XMLUtil.toElementContent(text); //NOI18N
} catch (CharConversionException ex) {
throw new IllegalArgumentException(ex);
}
if (null == action) {
return new JLabel(text);
}
JButton btn = new JButton(text);
btn.setFocusable(false);
btn.setBorder(BorderFactory.createEmptyBorder());
btn.setBorderPainted(false);
btn.setFocusPainted(false);
btn.setOpaque(false);
btn.setContentAreaFilled(false);
btn.addActionListener(action);
btn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
Color c = UIManager.getColor("nb.html.link.foreground"); //NOI18N
if (c != null) {
btn.setForeground(c);
}
return btn;
}
示例2: getDetailsPanel
import javax.swing.JButton; //導入方法依賴的package包/類
private static JComponent getDetailsPanel(String summary) {
JPanel details = new JPanel(new GridBagLayout());
details.setOpaque(false);
JLabel lblMessage = new JLabel(summary);
JButton reportLink = new JButton("<html><a href=\"_blank\">" + NbBundle.getMessage(NotifyExcPanel.class, "NTF_ExceptionalExceptionReport")); //NOI18N
reportLink.setFocusable(false);
reportLink.setBorder(BorderFactory.createEmptyBorder());
reportLink.setBorderPainted(false);
reportLink.setFocusPainted(false);
reportLink.setOpaque(false);
reportLink.setContentAreaFilled(false);
reportLink.addActionListener(flash);
reportLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
details.add(reportLink, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 0, 3, 0), 0, 0));
details.add(lblMessage, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 0, 3, 0), 0, 0));
return details;
}
示例3: createDetails
import javax.swing.JButton; //導入方法依賴的package包/類
private JComponent createDetails( String text, ActionListener action ) {
if( null == action ) {
return new JLabel(text);
}
try {
text = "<html><u>" + XMLUtil.toElementContent(text); //NOI18N
} catch( CharConversionException ex ) {
throw new IllegalArgumentException(ex);
}
JButton btn = new JButton(text);
btn.setFocusable(false);
btn.setBorder(BorderFactory.createEmptyBorder());
btn.setBorderPainted(false);
btn.setFocusPainted(false);
btn.setOpaque(false);
btn.setContentAreaFilled(false);
btn.addActionListener(action);
btn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
Color c = UIManager.getColor("nb.html.link.foreground"); //NOI18N
if (c != null) {
btn.setForeground(c);
}
return btn;
}
示例4: createConfigureButton
import javax.swing.JButton; //導入方法依賴的package包/類
private JComponent createConfigureButton() {
if( null == browserProvider || !browserProvider.hasCustomizer() )
return null;
JButton button = new JButton(NbBundle.getMessage(BrowserMenu.class, "Ctl_ConfigurePhoneGap"));
button.addActionListener( new ActionListener() {
@Override
public void actionPerformed( ActionEvent e ) {
browserProvider.customize();
}
});
button.setBorder( new EmptyBorder(1, 1, 1, 1) );
button.setMargin( new Insets(0, 0, 0, 0) );
button.setCursor( Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) );
button.setHorizontalAlignment( JLabel.LEFT );
button.setFocusable( false );
button.setBorderPainted( false );
button.setFocusPainted( false );
button.setRolloverEnabled( true );
button.setContentAreaFilled( false );
return button;
}
示例5: InformationFrame
import javax.swing.JButton; //導入方法依賴的package包/類
public InformationFrame() {
setType(Type.POPUP);
setResizable(false);
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
this.setTitle("Approving question");
this.setPreferredSize(new Dimension(350, 170));
this.setAlwaysOnTop(isAlwaysOnTopSupported());
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(new BorderLayout());
final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation(screenSize.width / 2 - 150, screenSize.height / 2 - 75);
this.setIconImage(Toolkit.getDefaultToolkit().getImage(InformationFrame.class.getResource(LOGOPATH)));
final JPanel panel = new JPanel();
getContentPane().add(panel, BorderLayout.CENTER);
panel.setLayout(null);
okBtn = new JButton("OK");
okBtn.setIcon(new ImageIcon(InformationFrame.class.getResource("/com/coder/hms/icons/info_ok.png")));
okBtn.setFont(new Font("Lucida Grande", Font.PLAIN, 15));
okBtn.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
okBtn.setBounds(119, 102, 132, 35);
okBtn.addActionListener(getAction());
panel.add(okBtn);
lblMessage = new JLabel("");
lblMessage.setHorizontalTextPosition(SwingConstants.CENTER);
lblMessage.setHorizontalAlignment(SwingConstants.LEFT);
lblMessage.setBounds(87, 21, 246, 74);
panel.add(lblMessage);
lblIcon = new JLabel("");
lblIcon.setIcon(new ImageIcon(InformationFrame.class.getResource("/com/coder/hms/icons/dialogPane_question.png")));
lblIcon.setBounds(6, 36, 69, 70);
panel.add(lblIcon);
this.pack();
}
示例6: setLinkLikeButton
import javax.swing.JButton; //導入方法依賴的package包/類
/**
* Set button border and background to look like a label with link.
*/
private void setLinkLikeButton(JButton button) {
button.setBorderPainted(false);
button.setContentAreaFilled(false);
button.setBorder(new EmptyBorder(0, 0, 0, 0));
button.setCursor(Cursor.getPredefinedCursor(
Cursor.HAND_CURSOR));
}
示例7: createButton
import javax.swing.JButton; //導入方法依賴的package包/類
private static JButton createButton(String iconPath, String tooltip) {
Icon icon = ImageUtilities.loadImageIcon(iconPath, false);
final JButton button = new JButton(icon);
// ensure small size, just for the icon
Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8);
button.setPreferredSize(size);
button.setMargin(new Insets(1, 1, 1, 1));
button.setBorder(new EmptyBorder(button.getBorder().getBorderInsets(button)));
button.setToolTipText(tooltip);
button.setFocusable(false);
return button;
}
示例8: createButton
import javax.swing.JButton; //導入方法依賴的package包/類
private static JButton createButton (String iconPath, String tooltip) {
Icon icon = ImageUtilities.loadImageIcon(iconPath, false);
final JButton button = new JButton(icon);
// ensure small size, just for the icon
Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8);
button.setPreferredSize(size);
button.setMargin(new Insets(1, 1, 1, 1));
button.setBorder(new EmptyBorder(button.getBorder().getBorderInsets(button)));
button.setToolTipText(tooltip);
button.setFocusable(false);
return button;
}
示例9: mouseExited
import javax.swing.JButton; //導入方法依賴的package包/類
@Override
public void mouseExited(MouseEvent e) {
JButton now = (JButton) e.getSource();
if (!now.isSelected()) {
now.setBorder(transBorder);
}
}
示例10: prepareSearchPanel
import javax.swing.JButton; //導入方法依賴的package包/類
private void prepareSearchPanel() {
if( searchpanel == null ) {
searchpanel = new SearchPanel();
JLabel lbl = new JLabel(NbBundle.getMessage(PalettePanel.class, "LBL_QUICKSEARCH")); //NOI18N
searchpanel.setLayout(new GridBagLayout());
searchpanel.add(lbl, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,0,0,5), 0, 0));
searchpanel.add(searchTextField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,0,0,5), 0, 0));
searchpanel.add(new JLabel(), new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,0,0,0), 0, 0));
lbl.setLabelFor(searchTextField);
searchTextField.setColumns(10);
searchTextField.setMaximumSize(searchTextField.getPreferredSize());
searchTextField.putClientProperty("JTextField.variant", "search"); //NOI18N
lbl.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
JButton btnCancel = new JButton(ImageUtilities.loadImageIcon("org/netbeans/modules/palette/resources/cancel.png", true));
btnCancel.setBorder(BorderFactory.createEmptyBorder());
btnCancel.setBorderPainted(false);
btnCancel.setOpaque(false);
btnCancel.setContentAreaFilled(false);
searchpanel.add(btnCancel, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0,0,0,5), 0, 0));
btnCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
removeSearchField();
}
});
}
}
示例11: getLinkButton
import javax.swing.JButton; //導入方法依賴的package包/類
/**
* Return a button suitable for linking to another panel
* (e.g. ColopediaPanel).
*
* @param text a {@code String} value
* @param icon an {@code Icon} value
* @param action a {@code String} value
* @return a {@code JButton} value
*/
public static JButton getLinkButton(String text, Icon icon, String action) {
JButton button = new JButton(text, icon);
button.setMargin(EMPTY_MARGIN);
button.setOpaque(false);
button.setForeground(LINK_COLOR);
button.setAlignmentY(0.8f);
button.setBorder(blankBorder(0, 0, 0, 0));
button.setActionCommand(action);
button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
return button;
}
示例12: addImpl
import javax.swing.JButton; //導入方法依賴的package包/類
@Override
protected void addImpl( Component comp, Object constraints, int index ) {
super.addImpl( comp, constraints, index );
if( comp instanceof JButton ) {
JButton btn = (JButton) comp;
btn.setContentAreaFilled( false );
btn.setOpaque( false );
btn.setBorder( BorderFactory.createEmptyBorder(2,2,2,2) );
btn.setFocusable( false );
btn.setBorderPainted( false );
btn.setRolloverEnabled( false );
}
}
示例13: createButton
import javax.swing.JButton; //導入方法依賴的package包/類
private JButton createButton(String name, ActionListener listener) {
JButton button = new JButton(name);
button.setMargin(new Insets(0, 0, 0, 0));
button.setOpaque(false);
button.setHorizontalAlignment(SwingConstants.LEADING);
button.setForeground(Utility.LINK_COLOR);
button.setBorder(Utility.LEFTCELLBORDER);
button.addActionListener(listener);
return button;
}
示例14: createBigCloseButton
import javax.swing.JButton; //導入方法依賴的package包/類
/**
* Creates a big 'close' JButton with close icon, rollover icon and pressed icon according to Look and Feel
*
* @return JButton with close icons.
*/
public static JButton createBigCloseButton() {
JButton closeButton = new JButton();
int size = 19;
closeButton.setPreferredSize(new Dimension(size, size));
closeButton.setContentAreaFilled(false);
closeButton.setFocusable(false);
closeButton.setBorder(BorderFactory.createEmptyBorder());
closeButton.setBorderPainted(false);
closeButton.setRolloverEnabled(true);
closeButton.setIcon(getBigCloseTabImage());
closeButton.setRolloverIcon(getBigCloseTabRolloverImage());
closeButton.setPressedIcon(getBigCloseTabPressedImage());
return closeButton;
}
示例15: init
import javax.swing.JButton; //導入方法依賴的package包/類
public void init() {
JButton button = new JButton("Button"); // NON-NLS: the button text
button.setBorder(BorderFactory.createLineBorder(Color.red, 1));
TitledBorder border = new TitledBorder("Bordered Pane"); // NON-NLS: the panel title
border.setTitlePosition(TitledBorder.BELOW_BOTTOM);
JPanel panel = create(button, border);
panel.setBackground(Color.green);
getContentPane().add(create(panel, BorderFactory.createEmptyBorder(10, 10, 10, 10)));
}