下面列出了javax.swing.JRadioButton#setBorder ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static JRadioButton makeRadioToolButton(URL icon, URL selectedIcon, String actionCommand, String tooltip, ActionListener listener, final ButtonGroup buttonGroup){
final JRadioButton button = new JRadioButton();
buttonGroup.add(button);
Utils.setupButton(button, icon, selectedIcon, actionCommand, tooltip, listener);
button.setBorder(BorderFactory.createRaisedBevelBorder());
button.setBorderPainted(true);
return button;
}
public ChartTableToggle(NMONVisualizerGui gui) {
// border layout pads differently than the default flow layout
// use it so the text for the radio buttons lines up with other text in the parent
super(new BorderLayout());
this.gui = gui;
charts = new JRadioButton("Charts");
table = new JRadioButton("Table");
charts.setFont(Styles.LABEL);
table.setFont(Styles.LABEL);
charts.setBorder(Styles.CONTENT_BORDER);
table.setBorder(Styles.CONTENT_BORDER);
charts.setActionCommand("Charts");
table.setActionCommand("Table");
ActionListener toggle = new ActionListener() {
public void actionPerformed(ActionEvent e) {
ChartTableToggle.this.gui.setProperty("chartsDisplayed", !e.getActionCommand().equals("Table"));
}
};
charts.addActionListener(toggle);
table.addActionListener(toggle);
ButtonGroup group = new ButtonGroup();
group.add(charts);
group.add(table);
charts.setSelected(true);
table.setSelected(false);
add(charts, BorderLayout.LINE_START);
add(table, BorderLayout.LINE_END);
gui.addPropertyChangeListener("chartsDisplayed", this);
}
private JRadioButton getCustomRadioButton(String caption) {
JRadioButton ret = new JRadioButton(caption);
ret.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
ret.setFont(MAIN_FONT);
return ret;
}
/**
* Adds a preconfigured radio button to the specified container. Does not currently assign the
* radio button to a group.
*
* @param text The text of the radio button
* @param container The container to add the button to
* @param leftIndent The amount of padding to add to the left of the radio button as an empty
* border argument.
* @return The newly created JRadioButton
*/
private JRadioButton addRadioButton(String text, Container container, int leftIndent) {
JRadioButton radioButton = new JRadioButton(text);
radioButton.setAlignmentX(Component.LEFT_ALIGNMENT);
radioButton.setBorder(BorderFactory.createEmptyBorder(0, leftIndent, 7, 5));
container.add(radioButton);
return radioButton;
}