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


Java JButton.setIcon方法代码示例

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


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

import javax.swing.JButton; //导入方法依赖的package包/类
private JToolBar createToolbar() {
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    toolBar.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    toolBar.setLayout(new javax.swing.BoxLayout(toolBar, javax.swing.BoxLayout.X_AXIS));

    JButton pull = Utils.createButton("Pull", TestExecutionUI.this);
    pull.setToolTipText("Pull Selected TestCases to TestSet");
    pull.setIcon(Utils.getIconByResourceName("/ui/resources/testExecution/pull"));
    JButton export = Utils.createButton("Export", TestExecutionUI.this);
    export.setToolTipText("Export Selected TestCases into Manual TestCases");
    export.setIcon(Utils.getIconByResourceName("/ui/resources/testExecution/export"));
    filterButton = Utils.createButton("Filter", TestExecutionUI.this);
    filterButton.setToolTipText("Filter TestCases By Tags");
    filterButton.setIcon(Utils.getIconByResourceName("/ui/resources/toolbar/tag"));
    toolBar.add(pull);
    toolBar.add(export);
    toolBar.add(filterButton);
    return toolBar;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:21,代码来源:TestExecutionUI.java

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

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

示例5: InformationFrame

import javax.swing.JButton; //导入方法依赖的package包/类
public InformationFrame() {
	
	setType(Type.POPUP);
	setResizable(false);
	
	setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
	this.setTitle("Approving question");
	this.setPreferredSize(new Dimension(350, 170));
	this.setAlwaysOnTop(isAlwaysOnTopSupported());
	this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	getContentPane().setLayout(new BorderLayout());
	
	final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	
	this.setLocation(screenSize.width / 2 - 150, screenSize.height / 2 - 75);
	
	this.setIconImage(Toolkit.getDefaultToolkit().getImage(InformationFrame.class.getResource(LOGOPATH)));
	
	final JPanel panel = new JPanel();
	getContentPane().add(panel, BorderLayout.CENTER);
	panel.setLayout(null);
	
	okBtn = new JButton("OK");
	okBtn.setIcon(new ImageIcon(InformationFrame.class.getResource("/com/coder/hms/icons/info_ok.png")));
	okBtn.setFont(new Font("Lucida Grande", Font.PLAIN, 15));
	okBtn.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
	okBtn.setBounds(119, 102, 132, 35);
	okBtn.addActionListener(getAction());
	panel.add(okBtn);
	
	lblMessage = new JLabel("");
	lblMessage.setHorizontalTextPosition(SwingConstants.CENTER);
	lblMessage.setHorizontalAlignment(SwingConstants.LEFT);
	lblMessage.setBounds(87, 21, 246, 74);
	panel.add(lblMessage);
	
	lblIcon = new JLabel("");
	lblIcon.setIcon(new ImageIcon(InformationFrame.class.getResource("/com/coder/hms/icons/dialogPane_question.png")));
	lblIcon.setBounds(6, 36, 69, 70);
	panel.add(lblIcon);
	
	this.pack();
}
 
开发者ID:Coder-ACJHP,项目名称:Hotel-Properties-Management-System,代码行数:44,代码来源:InformationFrame.java

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

示例7: createEditButton

import javax.swing.JButton; //导入方法依赖的package包/类
private JButton createEditButton() {
    JButton edit = new JButton();
    edit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            edit();
        }
    });
    edit.setIcon(new ImageIcon(getClass().getResource(
            "/com/ramussoft/gui/edit.png")));
    edit.setToolTipText(GlobalResourcesManager.getString("edit"));
    edit.setFocusable(false);
    edit.setPreferredSize(new Dimension(16, 16));
    return edit;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:16,代码来源:DialogedTableCellEditor.java

示例8: createUnitNameButton

import javax.swing.JButton; //导入方法依赖的package包/类
private JButton createUnitNameButton(String name,
                                     LabourData.UnitData unitData) {
    JButton button = createButton(name, (ActionEvent ae) -> {
            getGUI().showCompactLabourReport(unitData);
        });

    if (!unitData.isSummary()) {
        button.setIcon(new ImageIcon(
            getImageLibrary().getUnitImage(unitData.getUnitType())));
    }

    return button;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:14,代码来源:CompactLabourReport.java

示例9: createMaximizeButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Creates button to maximize currently selected document in the given tab displayer.
 * @param controller Tab displayer's controller.
 * @return Button to maximize selected document tab.
 */
public static JButton createMaximizeButton( final Controller controller ) {
    final JButton btn = new JButton();
    btn.setIcon( ImageUtilities.loadImageIcon( "org/netbeans/core/multitabs/resources/maximize.png", true) ); //NOI18N
    btn.setToolTipText( NbBundle.getMessage(ButtonFactory.class, "Hint_MaximizeRestore") );
    btn.addActionListener( new ActionListener() {

        @Override
        public void actionPerformed( ActionEvent e ) {
            controller.postActionEvent( new TabActionEvent( btn, TabbedContainer.COMMAND_MAXIMIZE, -1 ) );
        }
    });
    btn.setFocusable( false );
    return btn;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ButtonFactory.java

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

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

示例12: createCloseButton

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Creates a small 'close' JButton with close icon, rollover icon and pressed icon according to Look and Feel
 *
 * @return JButton with close icons.
 */
public static JButton createCloseButton() {
    JButton closeButton = new JButton();
    int size = 16;
    closeButton.setPreferredSize(new Dimension(size, size));
    closeButton.setContentAreaFilled(false);
    closeButton.setFocusable(false);
    closeButton.setBorder(BorderFactory.createEmptyBorder());
    closeButton.setBorderPainted(false);
    closeButton.setRolloverEnabled(true);
    closeButton.setIcon(getCloseTabImage());
    closeButton.setRolloverIcon(getCloseTabRolloverImage());
    closeButton.setPressedIcon(getCloseTabPressedImage());
    return closeButton;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:CloseButtonFactory.java

示例13: initEquipmentButtons

import javax.swing.JButton; //导入方法依赖的package包/类
private synchronized void initEquipmentButtons(JButton[] buttons) {
    if (!initializedEquipmentButtons) {
        for (JButton button : buttons) {
            button.setIcon(new ImageIcon(MainMenuJPanel.this.mil2525CSymbolController.getSymbolImage(button.getText())));
        }
        initializedEquipmentButtons = true;
    }
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:9,代码来源:MainMenuJPanel.java

示例14: createToolBarButton

import javax.swing.JButton; //导入方法依赖的package包/类
private JButton createToolBarButton(String key, ActionListener listener) {
	JButton button = new JButton(getTranslation("toolbar."+key));
	button.setActionCommand(key);
	button.setToolTipText(getTranslation("toolbar."+key, TranslationType.TOOLTIP));
	URL resource = getResource("images/toolbar/"+key+".gif");
	if(resource!=null) {
		button.setText(new String());
		button.setIcon(new ImageIcon(getResource("images/toolbar/"+key+".gif"), getTranslation("toolbar."+key, TranslationType.ALTERNATIVE)));
	}
	button.addActionListener(listener);
	return button;
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:13,代码来源:Application.java

示例15: Login

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Create the frame to login
 */
public Login() {

	this.setTitle("Client IRC");
	this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	this.setResizable(false);
	this.setBounds(100, 100, 460, 261);
	this.setLocationRelativeTo(null);
	setIconImage(Toolkit.getDefaultToolkit().getImage(Login.class.getResource("/image/swag.png")));
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	contentPane.setLayout(null);
	this.setContentPane(contentPane);
	
	JButton btnLogin = new JButton("Login");
	Icon imgOk = new ImageIcon(Toolkit.getDefaultToolkit().getImage(Login.class.getResource("/image/ok.png")));
	btnLogin.setIcon(imgOk);
	btnLogin.setFont(new Font("Tahoma", Font.BOLD, 14));
	btnLogin.addActionListener(new ValidateConnectionListener());
	btnLogin.setBounds(217, 154, 139, 30);
	contentPane.add(btnLogin);
	
	JLabel lblNickname = new JLabel("Nickname");
	lblNickname.setHorizontalAlignment(SwingConstants.LEFT);
	lblNickname.setFont(new Font("Tahoma", Font.BOLD, 14));
	lblNickname.setBounds(179, 37, 86, 30);
	contentPane.add(lblNickname);
	
	JLabel lblIpServer = new JLabel("IP Server");		
	lblIpServer.setFont(new Font("Tahoma", Font.BOLD, 14));
	lblIpServer.setBounds(179, 95, 86, 30);
	contentPane.add(lblIpServer);
	
	textFieldNickname = new JTextField();
	textFieldNickname.setFont(new Font("Tahoma", Font.PLAIN, 14));
	textFieldNickname.setBounds(286, 38, 145, 30);
	contentPane.add(textFieldNickname);
	textFieldNickname.setColumns(10);
	
	textFieldServer = new JTextField();
	textFieldServer.setFont(new Font("Tahoma", Font.PLAIN, 14));
	textFieldServer.setBounds(286, 96, 145, 30);
	contentPane.add(textFieldServer);
	textFieldServer.setColumns(10);
	
	JLabel lblImage = new JLabel("");
	lblImage.setBounds(23, 11, 146, 173);
	Icon imgLogin = new ImageIcon(Toolkit.getDefaultToolkit().getImage(Login.class.getResource("/image/login-msn.png")));
	lblImage.setIcon(imgLogin);
	contentPane.add(lblImage);
	
	this.addWindowListener( new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			closeFrame();
		}
	});
}
 
开发者ID:LittleSnake42,项目名称:java-irc,代码行数:60,代码来源:Login.java


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