本文整理汇总了Java中javax.swing.JButton.setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.setPreferredSize方法的具体用法?Java JButton.setPreferredSize怎么用?Java JButton.setPreferredSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JButton
的用法示例。
在下文中一共展示了JButton.setPreferredSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDecreaseButton
import javax.swing.JButton; //导入方法依赖的package包/类
protected JButton createDecreaseButton(int orientation) {
JButton btn = new XDMButton();
btn.setHorizontalAlignment(JButton.CENTER);
btn.setPreferredSize(new Dimension(15, 15));
btn.setContentAreaFilled(false);
btn.setBorderPainted(false);
btn.setOpaque(false);
if (orientation == SwingConstants.NORTH) {
btn.setIcon(XDMIconMap.getIcon("UP_ARROW"));
}
if (orientation == SwingConstants.SOUTH) {
btn.setIcon(XDMIconMap.getIcon("DOWN_ARROW"));
}
if (orientation == SwingConstants.EAST) {
btn.setIcon(XDMIconMap.getIcon("LEFT_ARROW"));
}
if (orientation == SwingConstants.WEST) {
btn.setIcon(XDMIconMap.getIcon("RIGHT_ARROW"));
}
return btn;
}
示例2: createButtons
import javax.swing.JButton; //导入方法依赖的package包/类
void createButtons() {
for (int i = 0; i < chars.length; i++) {
JButton button = new JButton(new CharAction(chars[i]));
button.setMaximumSize(new Dimension(50, 22));
//button.setMinimumSize(new Dimension(22, 22));
button.setPreferredSize(new Dimension(30, 22));
button.setRequestFocusEnabled(false);
button.setFocusable(false);
button.setBorderPainted(false);
button.setOpaque(false);
button.setMargin(new Insets(0,0,0,0));
button.setFont(new Font("serif", 0, 14));
if (i == chars.length-1) {
button.setText("nbsp");
button.setFont(new Font("Dialog",0,10));
button.setMargin(new Insets(0,0,0,0));
}
this.add(button, null);
}
}
示例3: createP3
import javax.swing.JButton; //导入方法依赖的package包/类
JPanel createP3() {
p3 = new JPanel(new BorderLayout());
model = new DefaultListModel();
list = new JList(model);
list.setCellRenderer(new YTListRenderer());
p3.add(new JScrollPane(list));
Box box = Box.createHorizontalBox();
box.add(Box.createHorizontalGlue());
btnDwnld = new JButton("Download");
btnDwnld.addActionListener(this);
btnCancel = new JButton("Close");
btnCancel.addActionListener(this);
box.add(btnDwnld);
box.add(Box.createHorizontalStrut(10));
box.add(btnCancel);
btnCancel.setPreferredSize(btnDwnld.getPreferredSize());
box.add(Box.createHorizontalStrut(10));
box.add(Box.createRigidArea(new Dimension(0, 40)));
p3.add(box, BorderLayout.SOUTH);
box.setOpaque(true);
box.setBackground(StaticResource.titleColor);
return p3;
}
示例4: initComponents
import javax.swing.JButton; //导入方法依赖的package包/类
private void initComponents() {
this.setLayout(new BorderLayout());
epochs = new JSpinner(new SpinnerNumberModel(10, 10, 50, 1));
JPanel epochOption = new JPanel(new BorderLayout());
JPanel flowTemp = new JPanel(new FlowLayout(FlowLayout.LEFT));
epochs.setPreferredSize(new Dimension(70, 40));
epochs.setFont(new Font(epochs.getFont().getName(), epochs.getFont().getStyle(), epochs.getFont().getSize() + 4));
flowTemp.add(new JLabel("<html><body><h3>Select the maximum number of epochs: </h3></body></html> "));
flowTemp.add(epochs);
JButton setEpoch = new JButton(this.setEpoch);
setEpoch.setPreferredSize(new Dimension(85, 35));
flowTemp.add(setEpoch);
epochOption.add(flowTemp, BorderLayout.CENTER);
//JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
//btnPanel.add(setEpoch);
//epochOption.add(btnPanel,BorderLayout.SOUTH);
this.add(epochOption, BorderLayout.NORTH);
}
示例5: erzeugeAusleihButton
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Erzeugt den Ausleih-Button.
*/
private void erzeugeAusleihButton()
{
JPanel _buttonPanel = new JPanel();
_ausleihePanel.add(_buttonPanel, BorderLayout.SOUTH);
_buttonPanel.setPreferredSize(new Dimension(-1, 110));
_buttonPanel.setSize(-1, -1);
_buttonPanel.setBackground(UIConstants.BACKGROUND_COLOR);
_vormerkenButton = new JButton();
_buttonPanel.add(_vormerkenButton);
_vormerkenButton.setText("vormerken");
_vormerkenButton.setPreferredSize(new Dimension(140, 100));
_vormerkenButton.setSize(-1, -1);
_vormerkenButton.setFont(UIConstants.BUTTON_FONT);
_vormerkenButton.setEnabled(false);
}
示例6: createButton
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Helper method used to create a button inside a JPanel
* @param action action associated to that button
* @return created component
*/
private JComponent createButton(AbstractAction action) {
JPanel panel = new JPanel(); // Use gridbag as centers by default
JButton button = new JButton(action);
button.setHorizontalTextPosition(SwingConstants.CENTER);
button.setVerticalTextPosition(SwingConstants.BOTTOM);
button.setPreferredSize(new Dimension((int) (BUTTONSIZE * 3.5), (BUTTONSIZE * 2)));
button.addMouseListener(rollover);
if (action == buttonAction[3]) {
button.setVisible(false);
}
if (action == buttonAction[0]) {
button.setEnabled(false);
}
//if (action == buttonAction[2]) button.setEnabled(false);
//if (action == buttonAction[4]) button.setEnabled(false);
panel.add(button);
return panel;
}
示例7: createButton
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Helper method used to create a button inside a JPanel
* @param action action associated to that button
* @return created component
*/
private JComponent createButton(AbstractAction action) {
JPanel panel = new JPanel(); // Use gridbag as centers by default
JButton button = new JButton(action);
button.setHorizontalTextPosition(SwingConstants.CENTER);
button.setVerticalTextPosition(SwingConstants.BOTTOM);
button.setPreferredSize(new Dimension((int) (BUTTONSIZE * 3.5), (BUTTONSIZE * 2)));
button.addMouseListener(rollover);
//if (action == buttonAction[4]) {
// button.setVisible(false);
//}
//if (action == buttonAction[0]) {
// button.setEnabled(false);
//}
//if(action == buttonAction[2]) button.setEnabled(false);
//if(action == buttonAction[4]) button.setEnabled(false);
panel.add(button);
return panel;
}
示例8: createButton
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Helper method used to create a button inside a JPanel
* @param action action associated to that button
* @return created component
*/
private JComponent createButton(AbstractAction action) {
JPanel panel = new JPanel(); // Use gridbag as centers by default
JButton button = new JButton(action);
button.setHorizontalTextPosition(SwingConstants.CENTER);
button.setVerticalTextPosition(SwingConstants.BOTTOM);
button.setPreferredSize(new Dimension((int) (BUTTONSIZE * 3.5), (BUTTONSIZE * 2)));
button.addMouseListener(rollover);
if (action == buttonAction[3]) {
button.setVisible(false);
}
if (action == buttonAction[0]) {
button.setEnabled(false);
}
//if(action == buttonAction[2]) button.setEnabled(false);
//if(action == buttonAction[4]) button.setEnabled(false);
panel.add(button);
return panel;
}
示例9: createButton
import javax.swing.JButton; //导入方法依赖的package包/类
public static JButton createButton (Icon icon, String tooltip) {
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;
}
示例10: createDataSourceSelectionButton
import javax.swing.JButton; //导入方法依赖的package包/类
private JButton createDataSourceSelectionButton(@SuppressWarnings("rawtypes") final DataSourceFactory factory) {
String label = DataImportWizardUtils.getFactoryLabel(factory);
String description = DataImportWizardUtils.getFactoryDescription(factory);
JButton typeSelectionButton = new JButton(new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
@SuppressWarnings("unchecked")
public void actionPerformed(ActionEvent e) {
enableDataSourceButtons(false);
// update the wizard by setting the selected factory
wizard.setDataSource(factory.createNew(), factory);
// switch to the next wizard step (location selection)
wizard.nextStep();
}
});
typeSelectionButton.setText(label);
typeSelectionButton.setToolTipText(description);
typeSelectionButton.setMinimumSize(TYPE_BUTTON_DIMENSION);
typeSelectionButton.setPreferredSize(TYPE_BUTTON_DIMENSION);
typeSelectionButton.setMaximumSize(TYPE_BUTTON_DIMENSION);
typeSelectionButton.setIcon(DataImportWizardUtils.getFactoryIcon(factory));
return typeSelectionButton;
}
示例11: addApplPanel
import javax.swing.JButton; //导入方法依赖的package包/类
private void addApplPanel(JPanel container, AbstractAction action, String engDescr, String itaDescr) {
FlowLayout fl = new FlowLayout(FlowLayout.LEFT, 3, 3);
JPanel newArea = new JPanel(fl);
newArea.setMaximumSize(new Dimension(400, 40));
newArea.setBorder(new EtchedBorder());
JButton newAppl = new JButton(action);
newAppl.setText(null);
newAppl.setPreferredSize(new Dimension(36, 36));
JLabel newDescr = new JLabel("<html><body>" + itaDescr + "<br>" + engDescr + "</body></html>");
newArea.add(newAppl);
newArea.add(newDescr);
container.add(newArea);
}
示例12: createGUI
import javax.swing.JButton; //导入方法依赖的package包/类
private void createGUI()
{
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
setLayout(gridbag);
setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
target = new JTextField();
target.setEditable(false);
target.setMinimumSize(new Dimension(150, 20));
target.setPreferredSize(new Dimension(150, 20));
target.setMaximumSize(new Dimension(150, 20));
c.gridx = 0;
c.weightx = 1;
c.gridy = 0;
c.fill = GridBagConstraints.HORIZONTAL;
gridbag.setConstraints(target, c);
add(target);
JButton search = new JButton("..."); //$NON-NLS-1$
search.setFont(new Font("Sans Serif", Font.PLAIN, 8)); //$NON-NLS-1$
search.addActionListener(new SearchHandler());
search.setMinimumSize(new Dimension(18, 20));
search.setPreferredSize(new Dimension(18, 20));
search.setMaximumSize(new Dimension(18, 20));
c.gridx = 1;
c.weightx = 0;
gridbag.setConstraints(search, c);
add(search);
}
示例13: setStartButton
import javax.swing.JButton; //导入方法依赖的package包/类
private void setStartButton()
{
start = new JButton();
start.setPreferredSize(new Dimension(60, 30));
StartButtonListener sbl = new StartButtonListener(this, progetto, elencoOggetti);
start.addActionListener(sbl);
setStartIcon();
}
示例14: createGUI
import javax.swing.JButton; //导入方法依赖的package包/类
protected void createGUI()
{
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
setLayout(gridbag);
setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
target = new JTextField();
target.setEditable(false);
target.setMinimumSize(new Dimension(150, 20));
target.setPreferredSize(new Dimension(150, 20));
target.setMaximumSize(new Dimension(150, 20));
c.gridx = 0;
c.weightx = 1;
c.gridy = 0;
c.fill = GridBagConstraints.HORIZONTAL;
gridbag.setConstraints(target, c);
add(target);
search = new JButton("...");
search.setFont(new Font("Sans Serif", Font.PLAIN, 8));
search.addActionListener(this);
search.setMinimumSize(new Dimension(18, 20));
search.setPreferredSize(new Dimension(18, 20));
search.setMaximumSize(new Dimension(18, 20));
c.gridx = 1;
c.weightx = 0;
gridbag.setConstraints(search, c);
add(search);
}
示例15: create
import javax.swing.JButton; //导入方法依赖的package包/类
private JScrollPane create(String name, Dimension size, MatteBorder border) {
JButton button = new JButton(name);
button.setPreferredSize(size);
button.setBorder(border);
return new JScrollPane(button);
}