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


Java DefaultButtonModel类代码示例

本文整理汇总了Java中javax.swing.DefaultButtonModel的典型用法代码示例。如果您正苦于以下问题:Java DefaultButtonModel类的具体用法?Java DefaultButtonModel怎么用?Java DefaultButtonModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createCloseButton

import javax.swing.DefaultButtonModel; //导入依赖的package包/类
private JButton createCloseButton() {
    JButton res = CloseButtonFactory.createBigCloseButton();
    res.setModel( new DefaultButtonModel() {
        @Override
        public boolean isRollover() {
            return inCloseButtonRect;
        }
    });
    //allow third party look and feels to provide their own icons
    Icon defaultIcon = UIManager.getIcon( "nb.popupswitcher.closebutton.defaultIcon" ); //NOI18N
    if( null != defaultIcon )
        res.setIcon( defaultIcon );
    Icon rolloverIcon = UIManager.getIcon( "nb.popupswitcher.closebutton.rolloverIcon" ); //NOI18N
    if( null != rolloverIcon )
        res.setRolloverIcon( rolloverIcon );
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DocumentSwitcherTable.java

示例2: Button

import javax.swing.DefaultButtonModel; //导入依赖的package包/类
Button(String text, Icon icon) {
    super(text, icon);
    
    // See GenericToolbar.addImpl()
    putClientProperty("MetalListener", new Object()); // NOI18N
    
    if (UIUtils.isAquaLookAndFeel())
        putClientProperty("JComponent.sizeVariant", "regular"); // NOI18N
    
    setModel(new DefaultButtonModel() {
        public boolean isRollover() {
            return super.isRollover() || (isEnabled() && (popup != null && popup.getModel().isRollover()));
        }
        public boolean isPressed() {
            return pushed || super.isPressed();
        }
        public boolean isArmed() {
            return pushed || super.isArmed();
        }
    });
    
    setHorizontalAlignment(LEADING);
    setDefaultCapable(false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:DropdownButton.java

示例3: Popup

import javax.swing.DefaultButtonModel; //导入依赖的package包/类
Popup() {
    super(" "); // NOI18N
    
    // See GenericToolbar.addImpl()
    putClientProperty("MetalListener", new Object()); // NOI18N
    
    setModel(new DefaultButtonModel() {
        public boolean isRollover() {
            return super.isRollover() || pushed;
        }
    });
    
    setHorizontalAlignment(LEADING);
    setDefaultCapable(false);
    
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, false), NO_ACTION);
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true), NO_ACTION);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:DropdownButton.java

示例4: getDefaultComponent

import javax.swing.DefaultButtonModel; //导入依赖的package包/类
public Component getDefaultComponent(Container aContainer) {
    Component c = getFirstComponent(aContainer);
    
    if (c instanceof AbstractButton) {
        ButtonModel bm = ((AbstractButton)c).getModel();
        if (bm instanceof DefaultButtonModel) {
            ButtonGroup bg = ((DefaultButtonModel)bm).getGroup();
            Enumeration<AbstractButton> en = bg == null ? null : bg.getElements();
            while (en != null && en.hasMoreElements()) {
                AbstractButton ab = en.nextElement();
                if (ab.isSelected()) return ab;
            }
        }
    }
    
    return c;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ProfilerPopup.java

示例5: testSetLocalizedTextWithModel

import javax.swing.DefaultButtonModel; //导入依赖的package包/类
public void testSetLocalizedTextWithModel() throws Exception {
    ButtonModel m = new DefaultButtonModel();
    JButton b = new JButton();
    Mnemonics.setLocalizedText(b, "Hello &There");
    assertEquals("Hello There", b.getText());
    if( Mnemonics.isAquaLF() ) {
        assertEquals(0, b.getMnemonic());
        assertEquals(-1, b.getDisplayedMnemonicIndex());
    } else {
        assertEquals('T', b.getMnemonic());
        assertEquals(6, b.getDisplayedMnemonicIndex());
    }
    b.setModel(m);
    assertEquals("Hello There", b.getText());
    if( Mnemonics.isAquaLF() ) {
        assertEquals(0, b.getMnemonic());
        assertEquals(-1, b.getDisplayedMnemonicIndex());
    } else {
        assertEquals('T', b.getMnemonic());
        assertEquals(6, b.getDisplayedMnemonicIndex());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:MnemonicsTest.java

示例6: go

import javax.swing.DefaultButtonModel; //导入依赖的package包/类
private void go() {

        frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container contentPane = frame.getContentPane();
        ButtonModel model = new DefaultButtonModel();

        JCheckBox check = new JCheckBox("a bit broken");
        check.setModel(model);
        panel = new JPanel(new BorderLayout());
        panel.add(new JTextField("Press Tab (twice?)"), BorderLayout.NORTH);
        panel.add(check);
        contentPane.add(panel);
        frame.setLocationRelativeTo(null);
        frame.pack();
        frame.setVisible(true);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:DefaultButtonModelCrashTest.java

示例7: WhylineButton

import javax.swing.DefaultButtonModel; //导入依赖的package包/类
public WhylineButton(Action abstractAction, String tooltip) {
	
	super(abstractAction);

	setFont(UI.getMediumFont());
	setFocusable(false);
	setOpaque(false);
	setToolTipText(tooltip);
	setContentAreaFilled(true);
	setRolloverEnabled(true);
	
	// Hack so that toolbar buttons in MetalLookAndFeel always show their background.
	setModel(new DefaultButtonModel() {
		public boolean isRollover() { return true; }
	});
	
}
 
开发者ID:andyjko,项目名称:whyline,代码行数:18,代码来源:WhylineButton.java

示例8: PlasticComboBoxButton

import javax.swing.DefaultButtonModel; //导入依赖的package包/类
PlasticComboBoxButton(JComboBox comboBox, Icon comboIcon, boolean iconOnly, CellRendererPane rendererPane, JList listBox)
/*  36:    */   {
/*  37: 80 */     super("");
/*  38: 81 */     setModel(new DefaultButtonModel()
/*  39:    */     {
/*  40:    */       public void setArmed(boolean armed)
/*  41:    */       {
/*  42: 83 */         super.setArmed((isPressed()) || (armed));
/*  43:    */       }
/*  44: 85 */     });
/*  45: 86 */     this.comboBox = comboBox;
/*  46: 87 */     this.comboIcon = comboIcon;
/*  47: 88 */     this.iconOnly = iconOnly;
/*  48: 89 */     this.rendererPane = rendererPane;
/*  49: 90 */     this.listBox = listBox;
/*  50: 91 */     setEnabled(comboBox.isEnabled());
/*  51: 92 */     setFocusable(false);
/*  52: 93 */     setRequestFocusEnabled(comboBox.isEnabled());
/*  53: 94 */     setBorder(UIManager.getBorder("ComboBox.arrowButtonBorder"));
/*  54: 95 */     setMargin(new Insets(0, 2, 0, 2));
/*  55: 96 */     this.borderPaintsFocus = UIManager.getBoolean("ComboBox.borderPaintsFocus");
/*  56:    */   }
 
开发者ID:xiwc,项目名称:confluence.keygen,代码行数:23,代码来源:PlasticComboBoxButton.java

示例9: testConstructor

import javax.swing.DefaultButtonModel; //导入依赖的package包/类
public Result testConstructor() {
    InstrumentedUILog.clear();
    DefaultButtonModel dbm = new InstrumentedButtonModel();
    Util.waitQueueEventsProcess();

    if (!InstrumentedUILog.equals(new Object[][] {
    /* 1 */{ "ButtonModel.setEnabled", "true" },
    /* 2 */{ "ButtonModel.isEnabled" },
    /* 3 */{ "ButtonModel.fireStateChanged" }, })
            && !InstrumentedUILog.equals(new Object[0][0])) {
        InstrumentedUILog.printLog();
        return failed("expected constructor to call another sequence of methods");
    }

    return passed();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:17,代码来源:DefaultButtonModelTest.java

示例10: init

import javax.swing.DefaultButtonModel; //导入依赖的package包/类
public void init() {

		// create objects
		ButtonModel model = new DefaultButtonModel();
		JButton button = new JButton(this);
		button.setModel(model);
		button.setText(null);

		// store objects
		putValue(BUTTON, button);
		putValue(MODEL, model);
		putValue(ITEM, new JMenuItem(this));

		// add listener and init text
		Status.LANGUAGE.addListener(new StatusListener() {

			@Override
			public void statusChanged(Status status, Object newValue) {
				// language changed. update action values and hide text
				updateText();
			}
		});
		updateText();
	}
 
开发者ID:kinnla,项目名称:eniac,代码行数:25,代码来源:EAction.java

示例11: CustomizerLibraries

import javax.swing.DefaultButtonModel; //导入依赖的package包/类
@Messages("CTL_AddSimple=&Add...")
public CustomizerLibraries(SingleModuleProperties props, ProjectCustomizer.Category category, @NonNull NbModuleProject p) {
    super(props, CustomizerLibraries.class, category);
    initComponents();
    if (!getProperties().isSuiteComponent()) {
        addLibrary.setVisible(false);
        Mnemonics.setLocalizedText(addDepButton, CTL_AddSimple());
    }
    refresh();
    dependencyList.setCellRenderer(CustomizerComponentFactory.getDependencyCellRenderer(false));
    javaPlatformCombo.setRenderer(JavaPlatformComponentFactory.javaPlatformListCellRenderer());
    removeTokenButton.setEnabled(false);
    wrappedJarsList.setCellRenderer(ClassPathListCellRenderer.createClassPathListRenderer(
            getProperties().getEvaluator(),
            FileUtil.toFileObject(getProperties().getProjectDirectoryFile())));
    DefaultButtonModel dummy = new DefaultButtonModel();
    EditMediator.register(
            p,
            getProperties().getHelper(),
            getProperties().getRefHelper(),
            emListComp,
            dummy,
            dummy,
            dummy,
            removeButton.getModel(),
            dummy,
            dummy,
            editButton.getModel(),
            null,
            null);
    attachListeners();
    pxml = new ProjectXMLManager(p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:CustomizerLibraries.java

示例12: setupInstance

import javax.swing.DefaultButtonModel; //导入依赖的package包/类
protected void setupInstance(DefaultButtonModel instance) {
    super.setupInstance(instance);
    
    instance.setArmed((stateMask & DefaultButtonModel.ARMED) != 0);
    instance.setSelected((stateMask & DefaultButtonModel.SELECTED) != 0);
    instance.setEnabled((stateMask & DefaultButtonModel.ENABLED) != 0);
    instance.setPressed((stateMask & DefaultButtonModel.PRESSED) != 0);
    instance.setRollover((stateMask & DefaultButtonModel.ROLLOVER) != 0);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ButtonBuilders.java

示例13: verifySingleDefaultButtonModelListener

import javax.swing.DefaultButtonModel; //导入依赖的package包/类
private static void verifySingleDefaultButtonModelListener() {
    HTMLEditorKit htmlEditorKit = (HTMLEditorKit) html.getEditorKit();
    StyleContext.NamedStyle style = ((StyleContext.NamedStyle) htmlEditorKit
            .getInputAttributes());
    DefaultButtonModel model = ((DefaultButtonModel) style
            .getAttribute(StyleConstants.ModelAttribute));
    ActionListener[] listeners = model.getActionListeners();
    int actionListenerNum = listeners.length;
    if (actionListenerNum != 1) {
        throw new RuntimeException(
                "Expected single ActionListener object registered with "
                + "DefaultButtonModel; found " + actionListenerNum
                + " listeners registered.");
    }

    int changeListenerNum = model.getChangeListeners().length;
    if (changeListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ChangeListener object registered "
                + "with DefaultButtonModel; found " + changeListenerNum
                + " listeners registered.");
    }
    int itemListenerNum = model.getItemListeners().length;
    if (itemListenerNum != 1) {
        throw new RuntimeException(
                "Expected at most one ItemListener object registered "
                + "with DefaultButtonModel; found " + itemListenerNum
                + " listeners registered.");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:31,代码来源:bug7189299.java

示例14: JButtonPad

import javax.swing.DefaultButtonModel; //导入依赖的package包/类
public JButtonPad(String text, Icon icon) {
	// Create the model
	this.setCursor(new Cursor(Cursor.HAND_CURSOR));
	setModel(new DefaultButtonModel());
	// initialize
	init(text, icon);
	
}
 
开发者ID:cams7,项目名称:erp,代码行数:9,代码来源:JButtonPad.java

示例15: track

import javax.swing.DefaultButtonModel; //导入依赖的package包/类
public static void track(final JRadioButton button) {
    final Preferences prefs = node().node("Buttons");
    boolean selected = prefs.getBoolean(button.getName() + ".selected", button
            .isSelected());
    ((DefaultButtonModel) button.getModel()).getGroup().setSelected(
            button.getModel(), selected);// .setSelected(selected);
    button.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            prefs.putBoolean(button.getName() + ".selected", button.isSelected());
        }
    });
}
 
开发者ID:ZenHarbinger,项目名称:l2fprod-properties-editor,代码行数:14,代码来源:UserPreferences.java


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