当前位置: 首页>>代码示例>>Java>>正文


Java JButton.setPreferredSize方法代码示例

本文整理汇总了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;
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:22,代码来源:XDMScrollBarUI.java

示例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);
    }
}
 
开发者ID:ser316asu,项目名称:SER316-Ingolstadt,代码行数:21,代码来源:CharTablePanel.java

示例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;
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:25,代码来源:YoutubeGrabberDlg.java

示例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);
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:19,代码来源:EpochPanel.java

示例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);
}
 
开发者ID:polemonium,项目名称:SE2Project,代码行数:20,代码来源:VormerkUI.java

示例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;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:24,代码来源:JWatStartScreen.java

示例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;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:24,代码来源:JWatMainPanel.java

示例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;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:24,代码来源:JWatStartScreen.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:VariablesViewButtons.java

示例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;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:33,代码来源:TypeSelectionView.java

示例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);
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:14,代码来源:UniqueStartScreen.java

示例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);
}
 
开发者ID:equella,项目名称:Equella,代码行数:32,代码来源:ScriptTargetChooser.java

示例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();
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-I,代码行数:9,代码来源:HomePage.java

示例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);
}
 
开发者ID:equella,项目名称:Equella,代码行数:33,代码来源:WhereTargetChooser.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:Test6910490.java


注:本文中的javax.swing.JButton.setPreferredSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。