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


Java JToggleButton.setIcon方法代碼示例

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


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

示例1: createAndShowGUI

import javax.swing.JToggleButton; //導入方法依賴的package包/類
private static void createAndShowGUI() {
    frame = new JFrame();
    frame.setSize(IMAGE_SIZE, IMAGE_SIZE);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel panel = new JPanel(new BorderLayout());

    BufferedImage img1x = generateImage(1, COLOR_1X);

    BufferedImage img2x = generateImage(2, COLOR_2X);
    BaseMultiResolutionImage mri = new BaseMultiResolutionImage(
            new BufferedImage[]{img1x, img2x});
    Icon mrIcon = new ImageIcon(mri);

    JToggleButton button = new JToggleButton();
    button.setIcon(mrIcon);
    panel.add(button, BorderLayout.CENTER);

    frame.getContentPane().add(panel);
    frame.setVisible(true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:PressedIconTest.java

示例2: getToolbarPresenter

import javax.swing.JToggleButton; //導入方法依賴的package包/類
@Override
public Component getToolbarPresenter() {
    JToggleButton toggleButton = new JToggleButton();
    toggleButtonRef = new WeakReference<>(toggleButton);
    toggleButton.putClientProperty("hideActionText", Boolean.TRUE); //NOI18N
    toggleButton.setIcon((Icon) getValue(SMALL_ICON));
    toggleButton.setAction(this); // this will make hard ref to button => check GC
    return toggleButton;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:ActionFactory.java

示例3: getToolbarPresenter

import javax.swing.JToggleButton; //導入方法依賴的package包/類
@Override
public Component getToolbarPresenter() {
    toggleButton = new JToggleButton();
    toggleButton.putClientProperty("hideActionText", Boolean.TRUE); //NOI18N
    toggleButton.setIcon((Icon) getValue(SMALL_ICON));
    toggleButton.setAction(this); // this will make hard ref to button => check GC
    return toggleButton;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:ToggleDebuggingAction.java

示例4: create

import javax.swing.JToggleButton; //導入方法依賴的package包/類
private JToggleButton create(String text) {
    JToggleButton togg = new JToggleButton();
    togg.setIcon(Utils.getIconByResourceName("/ui/resources/or/" + text.toLowerCase()));
    togg.setToolTipText(text);
    togg.setActionCommand(text);
    togg.addItemListener(ObjectRepo.this);
    bgroup.add(togg);
    return togg;
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:10,代碼來源:ObjectRepo.java

示例5: FilesPanel

import javax.swing.JToggleButton; //導入方法依賴的package包/類
public FilesPanel(VCSCommitPanel master, Map<String, VCSCommitFilter> filters, int preferedHeight)  {
    super(master, master.getModifier().getMessage(VCSCommitPanelModifier.BundleMessage.FILE_PANEL_TITLE), DEFAULT_DISPLAY_FILES);
    this.filters = filters;
    
    master.getCommitTable().labelFor(filesLabel);
    
    JComponent table = master.getCommitTable().getComponent();
    
    Mnemonics.setLocalizedText(filesLabel, getMessage("CTL_CommitForm_FilesToCommit"));         // NOI18N
    filesLabel.setMaximumSize(new Dimension(Integer.MAX_VALUE, filesLabel.getMaximumSize().height));
    
    table.setPreferredSize(new Dimension(0, preferedHeight));
    
    ButtonGroup bg = new ButtonGroup();
    toolbar = new JToolBar();
    toolbar.setFloatable(false);
    
    for (VCSCommitFilter filter : filters.values()) {
        
        JToggleButton tgb = new JToggleButton();
        tgb.setIcon(filter.getIcon()); 
        tgb.setToolTipText(filter.getTooltip()); 
        tgb.setFocusable(false);
        tgb.setSelected(filter.isSelected());
        tgb.addActionListener(this);                
        tgb.putClientProperty(TOOLBAR_FILTER, filter);
        bg.add(tgb);
        toolbar.add(tgb);
        
    }
    toolbar.setAlignmentX(LEFT_ALIGNMENT);        
    
    sectionPanel.add(toolbar);
    sectionPanel.add(table);
    sectionPanel.add(VCSCommitPanel.makeVerticalStrut(filesLabel, table, RELATED, sectionPanel));
    sectionPanel.add(filesLabel);
    
    sectionPanel.setAlignmentX(LEFT_ALIGNMENT);
    filesLabel.setAlignmentX(LEFT_ALIGNMENT);
    table.setAlignmentX(LEFT_ALIGNMENT);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:42,代碼來源:CollapsiblePanel.java


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