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


Java JButton.setHorizontalAlignment方法代码示例

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


在下文中一共展示了JButton.setHorizontalAlignment方法的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: getContributeButton

import javax.swing.JButton; //导入方法依赖的package包/类
public JButton getContributeButton() {
	JButton contributeB = new JButton();
	contributeB.setLayout(new BorderLayout());
	JLabel label1 = new JLabel("Contribute");
	JLabel label2 = new JLabel("Data");
	label1.setFont(new Font("Arial", Font.BOLD, 11));
	contributeB.add(BorderLayout.CENTER,label1);
	label2.setFont(new Font("Arial", Font.BOLD, 11));
	label2.setHorizontalAlignment(SwingConstants.CENTER);
	contributeB.add(BorderLayout.SOUTH,label2);
	contributeB.setSize(new Dimension(115, 30));
	contributeB.setMargin(new Insets(0, 0, 0, 0));
	contributeB.setBackground(new Color( 224, 224, 224)); ;
	contributeB.setFont(new Font("Arial", Font.BOLD, 11));
	contributeB.setHorizontalAlignment(SwingConstants.LEFT);
	
	return contributeB;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:19,代码来源:MapTools.java

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

示例4: updateActionPane

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * 
 */
public void updateActionPane() {
	actions.removeAll();
	try {
		posActions = Main.guiControlller.getPossibleActions();
		String actionName;
		int i = 0;
		for (Action<?> posAction : posActions) {
			actionName = posAction.toString();
			JButton b1 = new JButton(actionName);
			b1.setHorizontalAlignment(SwingConstants.LEFT);
			b1.addActionListener(this);
			b1.setActionCommand(Integer.toString(i));
			b1.setMaximumSize(new Dimension(Integer.MAX_VALUE, b1.getMinimumSize().height));
			actions.add(b1);
			i++;
		}
		actions.revalidate();
		actions.repaint();
		this.repaint();


	} catch (Exception e) {
		Main.updateUserMsg(e.getMessage());
	}
}
 
开发者ID:tslaats,项目名称:SE2017-Team2,代码行数:29,代码来源:ActionPane.java

示例5: jPanel_srEquipmentBrowseCategoriesComponentShown

import javax.swing.JButton; //导入方法依赖的package包/类
private void jPanel_srEquipmentBrowseCategoriesComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jPanel_srEquipmentBrowseCategoriesComponentShown
    if (!initializedEquipmentBrowse) {
        List<String> categories = mil2525CSymbolController.getCategories();
        for (final String category : categories) {
            final JButton button = new JButton(category);
            button.setFont(BUTTON_FONT);
            button.setHorizontalAlignment(SwingConstants.LEFT);
            button.setFocusable(false);
            button.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    selectedCategory = category;
                    equipmentListJPanel_srEquipmentCategoryResults.removeAll();
                    jLabel_srEquipmentCategory.setText(selectedCategory);
                    showCard("Spot Report Equipment Category Card");
                }
            });
            button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 60));
            button.setMinimumSize(new Dimension(0, 60));
            jPanel_srEquipmentCategories.add(button);
        }

        initializedEquipmentBrowse = true;
    }
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:26,代码来源:MainMenuJPanel.java

示例6: createIncreaseButton

import javax.swing.JButton; //导入方法依赖的package包/类
protected JButton createIncreaseButton(int orientation) {
	JButton btn = new XDMButton();
	btn.setHorizontalAlignment(JButton.CENTER);
	btn.setPreferredSize(new Dimension(15, 15));
	btn.setContentAreaFilled(false);
	btn.setBorderPainted(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,代码行数:21,代码来源:XDMScrollBarUI.java

示例7: WarningMessage

import javax.swing.JButton; //导入方法依赖的package包/类
public WarningMessage(String ErrMessage) {
	setBounds(100, 100, 650, 500);
	this.getContentPane().setLayout(new BorderLayout());
	{
		JPanel buttonPane = new JPanel();
		buttonPane.setBackground(new Color(144, 238, 144));
		buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
		getContentPane().add(buttonPane, BorderLayout.SOUTH);
		{
			JButton cancelButton = new JButton("OK");
			cancelButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					dispose();
				}
			});
			cancelButton.setFont(new Font("Times New Roman", Font.BOLD, 12));
			cancelButton.setHorizontalAlignment(SwingConstants.LEFT);
			buttonPane.add(cancelButton);
		}
	}
	{
		JLabel label = new JLabel("Warning!");
		label.setBackground(new Color(144, 238, 144));
		label.setHorizontalAlignment(SwingConstants.CENTER);
		label.setForeground(new Color(100, 0, 0));
		label.setFont(new Font("Times New Roman", Font.BOLD, 24));
		getContentPane().add(label, BorderLayout.NORTH);
	}
	{
		JScrollPane scrollPane = new JScrollPane();
		getContentPane().add(scrollPane, BorderLayout.CENTER);
		{
			JTextArea txtErrMessage = new JTextArea();
			txtErrMessage.setText(ErrMessage);
			txtErrMessage.setFont(new Font("Monospaced", Font.PLAIN, 13));
			txtErrMessage.setBackground(new Color(144, 238, 144));
			scrollPane.setViewportView(txtErrMessage);
			txtErrMessage.setCaretPosition(0);
			txtErrMessage.setEditable(false);
		}
	}
}
 
开发者ID:RaduMarcel,项目名称:EspressoViews,代码行数:43,代码来源:WarningMessage.java

示例8: createButton

import javax.swing.JButton; //导入方法依赖的package包/类
static JButton createButton(String text, String imageName, String actionCommand) {
	final JButton button = new JButton();
	button.setOpaque(false);
	button.setHorizontalAlignment(SwingConstants.LEADING);
	if (text != null) {
		button.setText(text);
	}
	if (imageName != null) {
		button.setIcon(DcdUiHelper.createIcon(imageName));
	}
	if (actionCommand != null) {
		button.setActionCommand(actionCommand);
	}
	return button;
}
 
开发者ID:evernat,项目名称:dead-code-detector,代码行数:16,代码来源:DcdUiHelper.java

示例9: getUnitButton

import javax.swing.JButton; //导入方法依赖的package包/类
protected JButton getUnitButton(final UnitType unitType, String roleId) {
    ImageIcon unitIcon = new ImageIcon(
        getImageLibrary().getSmallUnitImage(unitType, roleId, false));
    JButton unitButton = getButton(unitType, null, unitIcon);
    unitButton.setHorizontalAlignment(JButton.LEFT);
    return unitButton;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:8,代码来源:ColopediaGameObjectTypePanel.java

示例10: 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;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:11,代码来源:CompactLabourReport.java

示例11: createLinkButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Erstellt automatisch einen anklickbaren Link, der aussieht wie ein Label.
 * @param title
 * @param target
 * @return
 */
@SuppressWarnings("SameParameterValue")
private JButton createLinkButton(String title, final URI target)
{
    JButton linkButton = new JButton();
    linkButton.setText("<HTML><FONT color=\"#000099\"><U>" + title + "</U></FONT></HTML>");
    linkButton.setHorizontalAlignment(SwingConstants.LEFT);
    linkButton.setBorderPainted(false);
    linkButton.setOpaque(false);
    linkButton.setBackground(Color.WHITE);
    linkButton.setToolTipText(target.toString());
    linkButton.setFocusPainted(false);
    linkButton.setHorizontalAlignment(JButton.CENTER);
    linkButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (Desktop.isDesktopSupported())
            {
                try {
                    Desktop.getDesktop().browse(target);
                } catch (IOException exc) {
                    exc.printStackTrace();
                }
            }
        }
    });

    return linkButton;
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:35,代码来源:AboutPanel.java

示例12: setEquipmentNames

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Sets the names of the equipment for which buttons should display.
 * @param equipmentNames the names of the equipment for which buttons should display.
 */
public void setEquipmentNames(List<String> equipmentNames) {
    removeAll();

    for (final String name : equipmentNames) {
        JButton button = new JButton(name) {
            @Override
            public void paint(Graphics g) {
                if (null == getIcon()) {
                    //Doing this here because it's expensive, so only
                    //do it when we actually need it.
                    setIcon(new ImageIcon(mil2525CSymbolController.getSymbolImage(name)));
                }
                super.paint(g);
            }
        };
        button.setFont(BUTTON_FONT);
        button.setHorizontalAlignment(SwingConstants.LEFT);
        button.setFocusable(false);
        button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 60));
        button.setMinimumSize(new Dimension(0, 60));
        button.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                for (ActionListener listener : listeners) {
                    listener.actionPerformed(e);
                }
            }
        });
        add(button);
    }
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:36,代码来源:EquipmentListJPanel.java

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

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

示例15: ErrorMessage

import javax.swing.JButton; //导入方法依赖的package包/类
public ErrorMessage(String ErrMessage) {
	setBounds(100, 100, 650, 500);
	this.getContentPane().setLayout(new BorderLayout());
	{
		JPanel buttonPane = new JPanel();
		buttonPane.setBackground(new Color(144, 238, 144));
		buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
		getContentPane().add(buttonPane, BorderLayout.SOUTH);
		{
			JButton cancelButton = new JButton("OK");
			cancelButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					dispose();
				}
			});
			cancelButton.setFont(new Font("Times New Roman", Font.BOLD, 12));
			cancelButton.setHorizontalAlignment(SwingConstants.LEFT);
			buttonPane.add(cancelButton);
		}
	}
	{
		JLabel label = new JLabel("ERROR!");
		label.setBackground(new Color(144, 238, 144));
		label.setHorizontalAlignment(SwingConstants.CENTER);
		label.setForeground(new Color(139, 0, 0));
		label.setFont(new Font("Times New Roman", Font.BOLD, 20));
		getContentPane().add(label, BorderLayout.NORTH);
	}
	{
		JScrollPane scrollPane = new JScrollPane();
		getContentPane().add(scrollPane, BorderLayout.CENTER);
		{
			JTextArea txtErrMessage = new JTextArea();
			txtErrMessage.setText(ErrMessage);
			txtErrMessage.setFont(new Font("Monospaced", Font.PLAIN, 13));
			txtErrMessage.setBackground(new Color(144, 238, 144));
			scrollPane.setViewportView(txtErrMessage);
			txtErrMessage.setCaretPosition(0);
			txtErrMessage.setEditable(false);
		}
	}
}
 
开发者ID:RaduMarcel,项目名称:EspressoViews,代码行数:43,代码来源:ErrorMessage.java


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