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


Java JButton.setText方法代码示例

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


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

示例1: 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,项目名称:Neukoelln_SER316,代码行数:21,代码来源:CharTablePanel.java

示例2: erzeugeRuecknahmeButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Erzeuge den Rücknahme-Button.
 */
private void erzeugeRuecknahmeButton()
{
    JPanel buttonPanel = new JPanel();
    _ruecknahmePanel.add(buttonPanel, BorderLayout.SOUTH);
    buttonPanel.setPreferredSize(new java.awt.Dimension(-1, 110));
    buttonPanel.setSize(-1, -1);
    buttonPanel.setBackground(UIConstants.BACKGROUND_COLOR);

    _ruecknahmeButton = new JButton();
    buttonPanel.add(_ruecknahmeButton);
    _ruecknahmeButton.setText("zurücknehmen");
    _ruecknahmeButton.setPreferredSize(new java.awt.Dimension(140, 100));
    _ruecknahmeButton.setSize(-1, -1);
    _ruecknahmeButton.setEnabled(false);
    _ruecknahmeButton.setFont(UIConstants.BUTTON_FONT);
}
 
开发者ID:polemonium,项目名称:SE2Project,代码行数:20,代码来源:RueckgabeUI.java

示例3: makeButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Creates a button for toolbar.
 */
private JButton makeButton(String imageName, String actionCommand, String toolTipText, String altText) {
    //Look for the image.
    String imgLocation = "images/" + imageName + "16.png";
    URL imageURL = PlotCanvas.class.getResource(imgLocation);

    //Create and initialize the button.
    JButton button = new JButton();
    button.setActionCommand(actionCommand);
    button.setToolTipText(toolTipText);
    button.addActionListener(this);

    if (imageURL != null) {                      //image found
        button.setIcon(new ImageIcon(imageURL, altText));
    } else {                                     //no image found
        button.setText(altText);
        logger.error("Resource not found: {}", imgLocation);
    }

    return button;
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:24,代码来源:PlotPanel.java

示例4: makeNavigationButton

import javax.swing.JButton; //导入方法依赖的package包/类
protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {
    // Look for the image.
    String imgLocation = "images/" + imageName + ".gif";
    URL imageURL = ToolBarDemo.class.getResource(imgLocation);

    // Create and initialize the button.
    JButton button = new JButton();
    button.setActionCommand(actionCommand);
    button.setToolTipText(toolTipText);
    button.addActionListener(this);

    if (imageURL != null) { // image found
        button.setIcon(new ImageIcon(imageURL, altText));
    } else { // no image found
        button.setText(altText);
        System.err.println("Resource not found: " + imgLocation);
    }

    return button;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:ToolBarDemo.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);

    _ausleihButton = new JButton();
    _buttonPanel.add(_ausleihButton);
    _ausleihButton.setText("ausleihen");
    _ausleihButton.setPreferredSize(new Dimension(140, 100));
    _ausleihButton.setSize(-1, -1);
    _ausleihButton.setFont(UIConstants.BUTTON_FONT);
    _ausleihButton.setEnabled(false);
}
 
开发者ID:polemonium,项目名称:SE2Project,代码行数:20,代码来源:AusleiheUI.java

示例6: getTableCellEditorComponent

import javax.swing.JButton; //导入方法依赖的package包/类
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
	
	currentClass = (String)value;
	JButton btn = new JButton();
	btn.setText(currentClass);
	btn.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			classSelector.setClassSelected(currentClass);
			classSelector.setVisible(true);
			
		}
	});
	return btn;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:18,代码来源:TableCellEditor4ClassSelector.java

示例7: getJButtonExample

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Gets an example JButton.
 * @return the JButton example
 */
private JButton getJButtonExample() {
	
	JButton myButton = new JButton();
	myButton.setText("! My customized button !");
	myButton.setToolTipText("This is the tool tip text of your customized toolbar button");
	myButton.setSize(36, 36);
	// --------------------------------------------------------------------
	// Usually we took this Dimension and left the setText() empty !!
	// myButton.setPreferredSize( new Dimension(26,26) ); 
	// --------------------------------------------------------------------
	myButton.setPreferredSize( new Dimension(170, 26) );
	// --------------------------------------------------------------------
	myButton.setIcon(GlobalInfo.getInternalImageIcon("Refresh.png"));
	myButton.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent arg0) {
			System.out.println("This event came from your customized toolbar-button !");
		}
	});
	return myButton;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:26,代码来源:PlugInExample.java

示例8: makeNavigationButton

import javax.swing.JButton; //导入方法依赖的package包/类
protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {
    // Look for the image.
    String imgLocation = "images/" + imageName + ".gif";
    URL imageURL = ToolBarDemo2.class.getResource(imgLocation);

    // Create and initialize the button.
    JButton button = new JButton();
    button.setActionCommand(actionCommand);
    button.setToolTipText(toolTipText);
    button.addActionListener(this);

    if (imageURL != null) { // image found
        button.setIcon(new ImageIcon(imageURL, altText));
    } else { // no image found
        button.setText(altText);
        System.err.println("Resource not found: " + imgLocation);
    }

    return button;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:ToolBarDemo2.java

示例9: createButtons

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * @return a {@link JPanel} with {@link JButton}s to manipulate the network
 *         table: Move up, move down, add, remove.
 */
private JPanel createButtons() {
	JPanel bpanel = new JPanel();
	bpanel.setLayout(new BoxLayout(bpanel, BoxLayout.PAGE_AXIS));

	ActionListener listener = new ButtonHandler();
	JButton[] jbuttons = new JButton[4];
	String[] buttons = {
			UP_LBL,		UP_TIP, 	UP_ACTN,
			DOWN_LBL,	DOWN_TIP,	DOWN_ACTN,
			ADD_LBL,	ADD_TIP,	ADD_ACTN,
			REMOVE_LBL,	REMOVE_TIP,	REMOVE_ACTN
	};

	for (int i = 0; i < jbuttons.length; i++) {
		JButton button = new JButton();

		button.setText(buttons[i*3]);
		button.setToolTipText(buttons[i*3+1]);
		button.setActionCommand(buttons[i*3+2]);

		button.addActionListener(listener);
		button.setMaximumSize(new Dimension(
				Short.MAX_VALUE, button.getPreferredSize().height));

		bpanel.add(button);
		jbuttons[i] = button;

		if (i != jbuttons.length - 1) {
			bpanel.add(Box.createVerticalStrut(PADDING));
		}
	}

	this.moveUp = jbuttons[0];
	this.moveDown = jbuttons[1];
	this.add = jbuttons[2];
	this.remove = jbuttons[3];

	return bpanel;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:44,代码来源:MultiAlgoScenarioWizard.java

示例10: initToolbar

import javax.swing.JButton; //导入方法依赖的package包/类
private void initToolbar() {
    Insets ins = actionsBar.getMargin();
    JButton dummy = new JButton();
    dummy.setBorderPainted(false);
    dummy.setOpaque(false);
    dummy.setText(null);
    dummy.setIcon(new Icon() {

        @Override
        public int getIconHeight() {
            return 16;
        }

        @Override
        public int getIconWidth() {
            return 16;
        }

        @SuppressWarnings(value = "empty-statement")
        @Override
        public void paintIcon(Component c, Graphics g, int x, int y) {
            ;
        }
    });
    actionsBar.add(dummy);
    Dimension buttonPref = dummy.getPreferredSize();
    Dimension minDim = new Dimension(buttonPref.width + ins.left + ins.right, buttonPref.height + ins.top + ins.bottom);
    actionsBar.setMinimumSize(minDim);
    actionsBar.setPreferredSize(minDim);
    actionsBar.remove(dummy);
    actionsBar.setBorder(new RightBorder());
    actionsBar.setBorderPainted(true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:TerminalContainerTopComponent.java

示例11: fill

import javax.swing.JButton; //导入方法依赖的package包/类
private static BeanContext fill(BeanContext context) {
    context.add(new JLabel("label"));
    context.add(new JButton("button"));

    JButton button = new JButton();
    button.setText("another button");
    context.add(button);

    return context;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:Test4652928.java

示例12: TextNotification

import javax.swing.JButton; //导入方法依赖的package包/类
public TextNotification() {
	m_fromLabel = new JLabel();
	m_titleLabel = new JLabel();
	m_titleLabel.addMouseListener(new NotificationMouseAdapter(m_titleLabel));
	
	m_subtitleArea = new JTextArea();
	m_subtitleArea.addMouseListener(new NotificationMouseAdapter(m_titleLabel));
	
	JPanel panelHeader = new JPanel();
	panelHeader.setLayout(new BoxLayout(panelHeader, BoxLayout.PAGE_AXIS));
	JButton dimissButton = new JButton();
	dimissButton.setText("X");
	final TextNotification me = this;
	dimissButton.addActionListener(new ActionListener() {

		@Override
		public void actionPerformed(ActionEvent arg0) {
			// TODO Auto-generated method stub
			me.removeFromManager();
		}
		
	});
	dimissButton.setOpaque(false);
	dimissButton.setContentAreaFilled(false);
	dimissButton.setBorderPainted(false);
	dimissButton.setBounds((int) (this.getWidth() - dimissButton.getPreferredSize().getWidth()), 0, (int) dimissButton.getPreferredSize().getWidth(), (int) dimissButton.getPreferredSize().getHeight());
	m_panel.add(dimissButton);
	
	
	panelHeader.add(m_fromLabel);
	panelHeader.add(m_titleLabel);
	this.addComponent(panelHeader, BorderLayout.NORTH);
	this.addComponent(m_subtitleArea, BorderLayout.CENTER);
}
 
开发者ID:OwaNotifier,项目名称:owa-notifier,代码行数:35,代码来源:TextNotification.java

示例13: addButton

import javax.swing.JButton; //导入方法依赖的package包/类
private void addButton(JPanel panel, String label, Command command)
{
    JButton button = new JButton();

    button.setText(label);
    button.setActionCommand(command.name());
    button.addActionListener(_actionListener);
    panel.add(button);
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:10,代码来源:Demo.java

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

示例15: activateButton

import javax.swing.JButton; //导入方法依赖的package包/类
public static void activateButton(JButton button, String text, ActionListener newListener) {
	button.setText(text);
	button.setEnabled(true);
	for (ActionListener listener : Arrays.asList(button.getActionListeners())) {
		button.removeActionListener(listener);
	}
	button.addActionListener(newListener);
}
 
开发者ID:cccssw,项目名称:enigma-vk,代码行数:9,代码来源:GuiTricks.java


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