當前位置: 首頁>>代碼示例>>Java>>正文


Java JButton.getIcon方法代碼示例

本文整理匯總了Java中javax.swing.JButton.getIcon方法的典型用法代碼示例。如果您正苦於以下問題:Java JButton.getIcon方法的具體用法?Java JButton.getIcon怎麽用?Java JButton.getIcon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JButton的用法示例。


在下文中一共展示了JButton.getIcon方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testIconsSystemAction

import javax.swing.JButton; //導入方法依賴的package包/類
/**
 * Test whether pressed, rollover and disabled icons
 * work for SystemAction.
 */
public void testIconsSystemAction() throws Exception {
    Action saInstance = SystemAction.get(TestSystemAction.class);
    
    JButton jb = new JButton();
    Actions.connect(jb, saInstance);
    
    Icon icon = jb.getIcon();
    assertNotNull(icon);
    checkIfLoadedCorrectIcon(icon, jb, 0, "Enabled icon");
    
    Icon rolloverIcon = jb.getRolloverIcon();
    assertNotNull(rolloverIcon);
    checkIfLoadedCorrectIcon(rolloverIcon, jb, 1, "Rollover icon");
    
    Icon pressedIcon = jb.getPressedIcon();
    assertNotNull(pressedIcon);
    checkIfLoadedCorrectIcon(pressedIcon, jb, 2, "Pressed icon");
    
    Icon disabledIcon = jb.getDisabledIcon();
    assertNotNull(disabledIcon);
    checkIfLoadedCorrectIcon(disabledIcon, jb, 3, "Disabled icon");
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:ActionsTest.java

示例2: testIconsSystemAction24

import javax.swing.JButton; //導入方法依賴的package包/類
/**
 * Test whether pressed, rollover and disabled 24x24 icons
 * work for SystemAction.
 */
public void testIconsSystemAction24() throws Exception {
    Action saInstance = SystemAction.get(TestSystemAction.class);
    
    JButton jb = new JButton();
    jb.putClientProperty("PreferredIconSize",new Integer(24));
    Actions.connect(jb, saInstance);
    
    Icon icon = jb.getIcon();
    assertNotNull(icon);
    checkIfLoadedCorrectIcon(icon, jb, 4, "Enabled icon");
    
    Icon rolloverIcon = jb.getRolloverIcon();
    assertNotNull(rolloverIcon);
    checkIfLoadedCorrectIcon(rolloverIcon, jb, 5, "Rollover icon");
    
    Icon pressedIcon = jb.getPressedIcon();
    assertNotNull(pressedIcon);
    checkIfLoadedCorrectIcon(pressedIcon, jb, 6, "Pressed icon");
    
    Icon disabledIcon = jb.getDisabledIcon();
    assertNotNull(disabledIcon);
    checkIfLoadedCorrectIcon(disabledIcon, jb, 7, "Disabled icon");
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:ActionsTest.java

示例3: testIconsAction

import javax.swing.JButton; //導入方法依賴的package包/類
/**
 * Test whether pressed, rollover and disabled icons
 * work for javax.swing.Action.
 */
public void testIconsAction() throws Exception {
    JButton jb = new JButton();
    Actions.connect(jb, new TestAction());

    Icon icon = jb.getIcon();
    assertNotNull(icon);
    checkIfLoadedCorrectIcon(icon, jb, 0, "Enabled icon");

    Icon rolloverIcon = jb.getRolloverIcon();
    assertNotNull(rolloverIcon);
    checkIfLoadedCorrectIcon(rolloverIcon, jb, 1, "Rollover icon");

    Icon pressedIcon = jb.getPressedIcon();
    assertNotNull(pressedIcon);
    checkIfLoadedCorrectIcon(pressedIcon, jb, 2, "Pressed icon");

    Icon disabledIcon = jb.getDisabledIcon();
    assertNotNull(disabledIcon);
    checkIfLoadedCorrectIcon(disabledIcon, jb, 3, "Disabled icon");
    
    Icon selectedIcon = jb.getSelectedIcon();
    assertNotNull(selectedIcon);
    checkIfLoadedCorrectIcon(selectedIcon, jb, 8, "Selected icon");
    
    Icon rolloverSelectedIcon = jb.getRolloverSelectedIcon();
    assertNotNull(rolloverSelectedIcon);
    checkIfLoadedCorrectIcon(rolloverSelectedIcon, jb, 9, "RolloverSelected icon");

    // no pressedSelected
    
    Icon disabledSelectedIcon = jb.getDisabledSelectedIcon();
    assertNotNull(disabledSelectedIcon);
    checkIfLoadedCorrectIcon(disabledSelectedIcon, jb, 11, "DisabledSelected icon");
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:39,代碼來源:ActionsTest.java

示例4: testIconsAction24

import javax.swing.JButton; //導入方法依賴的package包/類
/**
 * Test whether pressed, rollover and disabled 24x24 icons
 * work for javax.swing.Action.
 */
public void testIconsAction24() throws Exception {
    JButton jb = new JButton();
    jb.putClientProperty("PreferredIconSize",new Integer(24));
    Actions.connect(jb, new TestAction());
    
    Icon icon = jb.getIcon();
    assertNotNull(icon);
    checkIfLoadedCorrectIcon(icon, jb, 4, "Enabled icon24");
    
    Icon rolloverIcon = jb.getRolloverIcon();
    assertNotNull(rolloverIcon);
    checkIfLoadedCorrectIcon(rolloverIcon, jb, 5, "Rollover icon24");
    
    Icon pressedIcon = jb.getPressedIcon();
    assertNotNull(pressedIcon);
    checkIfLoadedCorrectIcon(pressedIcon, jb, 6, "Pressed icon24");
    
    Icon disabledIcon = jb.getDisabledIcon();
    assertNotNull(disabledIcon);
    checkIfLoadedCorrectIcon(disabledIcon, jb, 7, "Disabled icon24");

    Icon selectedIcon = jb.getSelectedIcon();
    assertNotNull(selectedIcon);
    checkIfLoadedCorrectIcon(selectedIcon, jb, 12, "Selected icon24");

    Icon rolloverSelectedIcon = jb.getRolloverSelectedIcon();
    assertNotNull(rolloverSelectedIcon);
    checkIfLoadedCorrectIcon(rolloverSelectedIcon, jb, 13, "RolloverSelected icon24");

    // no pressedSelected

    Icon disabledSelectedIcon = jb.getDisabledSelectedIcon();
    assertNotNull(disabledSelectedIcon);
    checkIfLoadedCorrectIcon(disabledSelectedIcon, jb, 15, "DisabledSelected icon24");
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:40,代碼來源:ActionsTest.java

示例5: add

import javax.swing.JButton; //導入方法依賴的package包/類
public void add(Action action) {
	JButton button = new JButton(action);
	if (button.getIcon() != null) {
		button.setText(null);
	}
	add(button);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:8,代碼來源:RapidDockingToolbar.java

示例6: createButton

import javax.swing.JButton; //導入方法依賴的package包/類
public static JButton createButton(String action, String icon, String tooltip, ActionListener actionlistener) {
    JButton btn = new JButton();
    btn.setActionCommand(action);
    btn.setIcon(getIconByResourceName("/ui/resources/toolbar/" + icon));
    if (btn.getIcon() == null) {
        btn.setText(action);
    }
    btn.setToolTipText("<html>" + action + (tooltip != null ? (" [" + tooltip + "]") : "") + "</html>");
    btn.addActionListener(actionlistener);
    return btn;
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:12,代碼來源:Utils.java


注:本文中的javax.swing.JButton.getIcon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。