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


Java JButton.setHorizontalTextPosition方法代码示例

本文整理汇总了Java中javax.swing.JButton.setHorizontalTextPosition方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.setHorizontalTextPosition方法的具体用法?Java JButton.setHorizontalTextPosition怎么用?Java JButton.setHorizontalTextPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JButton的用法示例。


在下文中一共展示了JButton.setHorizontalTextPosition方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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:max6cn,项目名称:jmt,代码行数:24,代码来源:JWatMainPanel.java

示例3: 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

示例4: 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

示例5: 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);
	panel.add(button);
	return panel;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:16,代码来源:GraphStartScreen.java

示例6: ButtonDemo

import javax.swing.JButton; //导入方法依赖的package包/类
public ButtonDemo() {
    ImageIcon leftButtonIcon = createImageIcon("images/right.gif");
    ImageIcon middleButtonIcon = createImageIcon("images/middle.gif");
    ImageIcon rightButtonIcon = createImageIcon("images/left.gif");

    b1 = new JButton("Disable middle button", leftButtonIcon);
    b1.setVerticalTextPosition(AbstractButton.CENTER);
    b1.setHorizontalTextPosition(AbstractButton.LEADING); // aka LEFT, for
                                                          // left-to-right
                                                          // locales
    b1.setMnemonic(KeyEvent.VK_D);
    b1.setActionCommand("disable");

    b2 = new JButton("Middle button", middleButtonIcon);
    b2.setVerticalTextPosition(AbstractButton.BOTTOM);
    b2.setHorizontalTextPosition(AbstractButton.CENTER);
    b2.setMnemonic(KeyEvent.VK_M);

    b3 = new JButton("Enable middle button", rightButtonIcon);
    // Use the default text position of CENTER, TRAILING (RIGHT).
    b3.setMnemonic(KeyEvent.VK_E);
    b3.setActionCommand("enable");
    b3.setEnabled(false);

    // Listen for actions on buttons 1 and 3.
    b1.addActionListener(this);
    b3.addActionListener(this);

    b1.setToolTipText("Click this button to disable the middle button.");
    b2.setToolTipText("This middle button does nothing when you click it.");
    b3.setToolTipText("Click this button to enable the middle button.");

    // Add Components to this container, using the default FlowLayout.
    add(b1);
    add(b2);
    add(b3);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:38,代码来源:ButtonDemo.java

示例7: generateControl

import javax.swing.JButton; //导入方法依赖的package包/类
@Override
public JComponent generateControl()
{
	field = new JTextField();
	field.setMaximumSize(new Dimension(Short.MAX_VALUE, 20));

	if( items.size() >= 1 )
	{
		field.setText(((Item) items.get(0)).getValue());
	}

	JButton browse = new JButton("Browse");
	browse.setIcon(new ImageIcon(getClass().getResource("/images/browse.gif")));
	browse.setHorizontalTextPosition(SwingConstants.RIGHT);
	Dimension browseSize = browse.getPreferredSize();
	browseSize.height = 20;
	browse.setMaximumSize(browseSize);
	browse.addActionListener(this);

	JPanel group = new JPanel();
	group.setLayout(new BoxLayout(group, BoxLayout.X_AXIS));
	group.add(field);
	group.add(Box.createRigidArea(new Dimension(5, 0)));
	group.add(browse);
	group.setAlignmentX(Component.LEFT_ALIGNMENT);

	return group;
}
 
开发者ID:equella,项目名称:Equella,代码行数:29,代码来源:GResourceSelector.java

示例8: initialise

import javax.swing.JButton; //导入方法依赖的package包/类
private void initialise()
{
	currentText = getTextComponent();
	popupButton = new JButton();
	popupButton.addActionListener(new PopupListener());
	popupButton.setIcon(new ArrowIcon(SwingConstants.SOUTH));
	popupButton.setHorizontalTextPosition(SwingConstants.LEFT);

	initialiseLayout("hidemode 3,insets 0,fill", "growx", true); //$NON-NLS-1$ //$NON-NLS-2$

	switchLocale(null);
}
 
开发者ID:equella,项目名称:Equella,代码行数:13,代码来源:I18nTextField.java

示例9: create

import javax.swing.JButton; //导入方法依赖的package包/类
private JButton create(String text) {
    JButton button = new JButton();
    button.setIcon(Utils.getIconByResourceName("/ui/resources/dock/" + text.toLowerCase()));
    button.setActionCommand(text);
    button.setHorizontalTextPosition(SwingConstants.CENTER);
    button.addActionListener(this);
    return button;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:9,代码来源:SimpleDock.java

示例10: prepareButton

import javax.swing.JButton; //导入方法依赖的package包/类
void prepareButton(JButton btn) {
	btn.setBorderPainted(false);
	btn.setFocusPainted(false);
	btn.setHorizontalAlignment(JButton.CENTER);
	btn.setHorizontalTextPosition(JButton.CENTER);
	btn.setVerticalTextPosition(JButton.BOTTOM);
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:8,代码来源:BrowserIntDlg.java

示例11: updateCharts

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Updates the charts.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void updateCharts() {
	for (int i = 0; i < listOfChartPanels.size(); i++) {
		JPanel panel = listOfChartPanels.get(i);
		panel.removeAll();
		final ChartPanel chartPanel = new ChartPanel(getModel().getChartOrNull(i)) {

			private static final long serialVersionUID = -6953213567063104487L;

			@Override
			public Dimension getPreferredSize() {
				return DIMENSION_CHART_PANEL_ENLARGED;
			}
		};
		chartPanel.setPopupMenu(null);
		chartPanel.setBackground(COLOR_TRANSPARENT);
		chartPanel.setOpaque(false);
		chartPanel.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
		panel.add(chartPanel, BorderLayout.CENTER);

		JPanel openChartPanel = new JPanel(new GridBagLayout());
		openChartPanel.setOpaque(false);

		GridBagConstraints gbc = new GridBagConstraints();
		gbc.anchor = GridBagConstraints.CENTER;
		gbc.fill = GridBagConstraints.NONE;
		gbc.weightx = 1.0;
		gbc.weighty = 1.0;

		JButton openChartButton = new JButton(OPEN_CHART_ACTION);
		openChartButton.setOpaque(false);
		openChartButton.setContentAreaFilled(false);
		openChartButton.setBorderPainted(false);
		openChartButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
		openChartButton.setHorizontalAlignment(SwingConstants.LEFT);
		openChartButton.setHorizontalTextPosition(SwingConstants.LEFT);
		openChartButton.setIcon(null);
		Font font = openChartButton.getFont();
		Map attributes = font.getAttributes();
		attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
		openChartButton.setFont(font.deriveFont(attributes).deriveFont(10.0f));

		openChartPanel.add(openChartButton, gbc);

		panel.add(openChartPanel, BorderLayout.SOUTH);
		panel.revalidate();
		panel.repaint();
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:53,代码来源:AttributeStatisticsPanel.java

示例12: ButtonHtmlDemo

import javax.swing.JButton; //导入方法依赖的package包/类
public ButtonHtmlDemo() {
    ImageIcon leftButtonIcon = createImageIcon("images/right.gif");
    ImageIcon middleButtonIcon = createImageIcon("images/middle.gif");
    ImageIcon rightButtonIcon = createImageIcon("images/left.gif");

    b1 = new JButton("<html><center><b><u>D</u>isable</b><br>" + "<font color=#ffffdd>middle button</font>", leftButtonIcon);
    Font font = b1.getFont().deriveFont(Font.PLAIN);
    b1.setFont(font);
    b1.setVerticalTextPosition(AbstractButton.CENTER);
    b1.setHorizontalTextPosition(AbstractButton.LEADING); // aka LEFT, for
                                                          // left-to-right
                                                          // locales
    b1.setMnemonic(KeyEvent.VK_D);
    b1.setActionCommand("disable");

    b2 = new JButton("middle button", middleButtonIcon);
    b2.setFont(font);
    b2.setForeground(new Color(0xffffdd));
    b2.setVerticalTextPosition(AbstractButton.BOTTOM);
    b2.setHorizontalTextPosition(AbstractButton.CENTER);
    b2.setMnemonic(KeyEvent.VK_M);

    b3 = new JButton("<html><center><b><u>E</u>nable</b><br>" + "<font color=#ffffdd>middle button</font>", rightButtonIcon);
    b3.setFont(font);
    // Use the default text position of CENTER, TRAILING (RIGHT).
    b3.setMnemonic(KeyEvent.VK_E);
    b3.setActionCommand("enable");
    b3.setEnabled(false);

    // Listen for actions on buttons 1 and 3.
    b1.addActionListener(this);
    b3.addActionListener(this);

    b1.setToolTipText("Click this button to disable the middle button.");
    b2.setToolTipText("This middle button does nothing when you click it.");
    b3.setToolTipText("Click this button to enable the middle button.");

    // Add Components to this container, using the default FlowLayout.
    add(b1);
    add(b2);
    add(b3);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:43,代码来源:ButtonHtmlDemo.java

示例13: launch

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Launch SwingAppleCommander.
 */
public void launch() {
	JMenuBar menuBar = createMenuBar();
	JToolBar toolBar = new JToolBar();
	JPanel topPanel = new JPanel(new BorderLayout());
	tabPane = new JTabbedPane(JTabbedPane.TOP);
	topPanel.add(menuBar,BorderLayout.NORTH);
	topPanel.add(toolBar,BorderLayout.SOUTH);
	JButton aButton = new JButton(textBundle.get("OpenButton"), new ImageIcon(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/webcodepro/applecommander/ui/images/opendisk.gif")))); //$NON-NLS-1$
	aButton.setToolTipText(textBundle.get("SwtAppleCommander.OpenDiskImageTooltip")); //$NON-NLS-1$
	aButton.setHorizontalTextPosition(JLabel.CENTER);
	aButton.setVerticalTextPosition(JLabel.BOTTOM);
    aButton.addActionListener(this);
	toolBar.add(aButton);
	JButton aButton2 = new JButton(textBundle.get("CreateButton"), new ImageIcon(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/webcodepro/applecommander/ui/images/newdisk.gif")))); //$NON-NLS-1$
	aButton2.setToolTipText(textBundle.get("SwtAppleCommander.CreateDiskImageTooltip")); //$NON-NLS-1$
	aButton2.setHorizontalTextPosition(JLabel.CENTER);
	aButton2.setVerticalTextPosition(JLabel.BOTTOM);
    aButton2.addActionListener(this);
	toolBar.add(aButton2);
	JButton aButton3 = new JButton(textBundle.get("CompareButton"), new ImageIcon(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/webcodepro/applecommander/ui/images/comparedisks.gif")))); //$NON-NLS-1$
	aButton3.setToolTipText(textBundle.get("SwtAppleCommander.CompareDiskImageTooltip")); //$NON-NLS-1$
	aButton3.setHorizontalTextPosition(JLabel.CENTER);
	aButton3.setVerticalTextPosition(JLabel.BOTTOM);
    aButton3.addActionListener(this);
	toolBar.add(aButton3);
	JButton aButton4 = new JButton(textBundle.get("AboutButton"), new ImageIcon(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/webcodepro/applecommander/ui/images/about.gif")))); //$NON-NLS-1$
	aButton4.setToolTipText(textBundle.get("SwtAppleCommander.AboutTooltip")); //$NON-NLS-1$
	aButton4.setHorizontalTextPosition(JLabel.CENTER);
	aButton4.setVerticalTextPosition(JLabel.BOTTOM);
    aButton4.addActionListener(this);
	toolBar.add(aButton4);
	SwingAppleCommander application = new SwingAppleCommander();
	application.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/webcodepro/applecommander/ui/images/diskicon.gif"))); //$NON-NLS-1$
	application.setTitle(textBundle.get("SwtAppleCommander.AppleCommander"));
	titleLabel = new JLabel(new ImageIcon(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/webcodepro/applecommander/ui/images/AppleCommanderLogo.gif"))));
	addTitleTabPane();
	application.getContentPane().add(topPanel, BorderLayout.NORTH);
	application.getContentPane().add(tabPane, BorderLayout.CENTER);
	application.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

	application.pack();
	application.setVisible(true);
   }
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:47,代码来源:SwingAppleCommander.java


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