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


Java JToggleButton.ToggleButtonModel方法代码示例

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


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

示例1: createToggleButtonModel

import javax.swing.JToggleButton; //导入方法依赖的package包/类
private static JToggleButton.ToggleButtonModel createToggleButtonModel (
        @NonNull final PropertyEvaluator evaluator,
        @NonNull final String propName,
        final boolean defaultValue,
        @NonNull final Integer[] kind) {
    assert evaluator != null;
    assert propName != null;
    assert kind != null && kind.length == 1;
    String value = evaluator.getProperty( propName );
    boolean isSelected = false;
    if (value == null) {
        isSelected = defaultValue;
    }
    else {
       String lowercaseValue = value.toLowerCase();
       if ( lowercaseValue.equals( "yes" ) || lowercaseValue.equals( "no" ) ) { // NOI18N
           kind[0] = BOOLEAN_KIND_YN;
       }
       else if ( lowercaseValue.equals( "on" ) || lowercaseValue.equals( "off" ) ) { // NOI18N
           kind[0] = BOOLEAN_KIND_ED;
       }
       else {
           kind[0] = BOOLEAN_KIND_TF;
       }

       if ( lowercaseValue.equals( "true") || // NOI18N
            lowercaseValue.equals( "yes") ||  // NOI18N
            lowercaseValue.equals( "on") ) {  // NOI18N
           isSelected = true;                   
       } 
    }
    JToggleButton.ToggleButtonModel bm = new JToggleButton.ToggleButtonModel();
    bm.setSelected(isSelected );
    return bm;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:J2SEModularProjectProperties.java

示例2: performAction

import javax.swing.JToggleButton; //导入方法依赖的package包/类
private static void performAction(StayOpen item, int modifiers) {
    JMenuItem i = item.getItem();
    
    // Skip disabled items
    if (!item.getItem().isEnabled()) return;
    
    // Handle toggle items
    if (i.getModel() instanceof JToggleButton.ToggleButtonModel)
        i.setSelected(!i.isSelected());
    
    // Invoke item action
    item.actionPerformed(new ActionEvent(item, ActionEvent.ACTION_PERFORMED,
                         item.getItem().getActionCommand(),
                         EventQueue.getMostRecentEventTime(), modifiers));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:StayOpenPopupMenu.java

示例3: createBooleanButtonModel

import javax.swing.JToggleButton; //导入方法依赖的package包/类
private final JToggleButton.ToggleButtonModel createBooleanButtonModel( PropertyEvaluator evaluator, String propName, boolean invert ) {

        checkModelDoesNotExist( propName );
        
        String value = evaluator.getProperty( propName );

        boolean isSelected = false;

        Integer kind = BOOLEAN_KIND_TF;

        if ( value != null ) {
           String lowercaseValue = value.toLowerCase();

           if ( lowercaseValue.equals( "yes" ) || lowercaseValue.equals( "no" ) ) { // NOI18N
               kind = BOOLEAN_KIND_YN;
           }
           else if ( lowercaseValue.equals( "on" ) || lowercaseValue.equals( "off" ) ) { // NOI18N
               kind = BOOLEAN_KIND_ED;
           }

           if ( lowercaseValue.equals( "true") || // NOI18N
                lowercaseValue.equals( "yes") || // NOI18N
                lowercaseValue.equals( "on") ) {// NOI18N
               isSelected = true;                   
           } 
        }

        JToggleButton.ToggleButtonModel bm = new JToggleButton.ToggleButtonModel();
        bm.setSelected( invert ? !isSelected : isSelected );
        models.put(propName, new Object[] {bm, kind, invert});
        return bm;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:StoreGroup.java

示例4: getBinaryEncodeCSSModel

import javax.swing.JToggleButton; //导入方法依赖的package包/类
public JToggleButton.ToggleButtonModel getBinaryEncodeCSSModel() {
    return binaryEncodeCSS;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:JFXProjectProperties.java

示例5: getAllowOfflineModel

import javax.swing.JToggleButton; //导入方法依赖的package包/类
public JToggleButton.ToggleButtonModel getAllowOfflineModel() {
    return allowOfflineModel;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:JFXProjectProperties.java

示例6: getBackgroundUpdateCheckModel

import javax.swing.JToggleButton; //导入方法依赖的package包/类
public JToggleButton.ToggleButtonModel getBackgroundUpdateCheckModel() {
    return backgroundUpdateCheck;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:JFXProjectProperties.java

示例7: getInstallPermanentlyModel

import javax.swing.JToggleButton; //导入方法依赖的package包/类
public JToggleButton.ToggleButtonModel getInstallPermanentlyModel() {
    return installPermanently;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:JFXProjectProperties.java

示例8: getAddDesktopShortcutModel

import javax.swing.JToggleButton; //导入方法依赖的package包/类
public JToggleButton.ToggleButtonModel getAddDesktopShortcutModel() {
    return addDesktopShortcut;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:JFXProjectProperties.java

示例9: getAddStartMenuShortcutModel

import javax.swing.JToggleButton; //导入方法依赖的package包/类
public JToggleButton.ToggleButtonModel getAddStartMenuShortcutModel() {
    return addStartMenuShortcut;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:JFXProjectProperties.java

示例10: getDisableProxyModel

import javax.swing.JToggleButton; //导入方法依赖的package包/类
public JToggleButton.ToggleButtonModel getDisableProxyModel() {
    return disableProxy;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:JFXProjectProperties.java

示例11: SuiteInstallerProjectProperties

import javax.swing.JToggleButton; //导入方法依赖的package包/类
public SuiteInstallerProjectProperties(Project suiteProject) {
    this.suiteProject = suiteProject;
    Preferences prefs = prefs(suiteProject);
    windowsModel = new JToggleButton.ToggleButtonModel();
    windowsModel.setSelected(prefs.getBoolean(GENERATE_FOR_WINDOWS, Utilities.isWindows()));
    linuxModel = new JToggleButton.ToggleButtonModel();
    linuxModel.setSelected(prefs.getBoolean(GENERATE_FOR_LINUX, Utilities.getOperatingSystem() == Utilities.OS_LINUX));
    solarisModel = new JToggleButton.ToggleButtonModel();
    solarisModel.setSelected(prefs.getBoolean(GENERATE_FOR_SOLARIS, Utilities.getOperatingSystem() == Utilities.OS_SOLARIS));
    macModel = new JToggleButton.ToggleButtonModel();
    macModel.setSelected(prefs.getBoolean(GENERATE_FOR_MAC, Utilities.isMac()));
    pack200Model = new JToggleButton.ToggleButtonModel();
    pack200Model.setSelected(prefs.getBoolean(USE_PACK200_COMPRESSION, false));

    // license model:
    ResourceBundle rb = NbBundle.getBundle(SuiteInstallerProjectProperties.class);
    Enumeration<String> keys = rb.getKeys();
    String prefix = "SuiteInstallerProjectProperties.license.type.";
    List<String> names = new ArrayList<String>();
    List<String> types = new ArrayList<String>();

    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        if (key.startsWith(prefix)) {
            String type = key.substring(prefix.length());
            String value = NbBundle.getMessage(SuiteInstallerProjectProperties.class, key);
            if (type.equals(LICENSE_TYPE_NO)) {
                //No License is the first option
                names.add(0, value);
                types.add(0, type);
            } else {
                names.add(value);
                types.add(type);
            }
        }
    }
    licenseModel = new LicenseComboBoxModel(suiteProject, names, types);

    String licenseFileName = prefs.get(LICENSE_FILE, null);
    String licenseType = prefs.get(LICENSE_TYPE, null);
    if (licenseFileName != null) {
        File licenseFile = new File(licenseFileName);
        if (!licenseFile.isAbsolute()) {
            licenseFile = PropertyUtils.resolveFile(FileUtil.toFile(suiteProject.getProjectDirectory()), licenseFileName);
        }
        
        licenseModel.getNames().add(licenseFile.getAbsolutePath());
        licenseModel.getTypes().add(LICENSE_TYPE_FILE);
        String name = licenseModel.getNames().get(licenseModel.getNames().size() - 1);
        licenseModel.setSelectedItem(name);             
    }
    
    else if (licenseType != null) {
        int index = licenseModel.getTypes().indexOf(licenseType);
        if (index != -1) {
            licenseModel.setSelectedItem(licenseModel.getNames().get(index));
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:60,代码来源:SuiteInstallerProjectProperties.java

示例12: getModel1

import javax.swing.JToggleButton; //导入方法依赖的package包/类
public JToggleButton.ToggleButtonModel getModel1() {
    return model1;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:J2SECustomPropertySaverTest.java

示例13: getModel2

import javax.swing.JToggleButton; //导入方法依赖的package包/类
public JToggleButton.ToggleButtonModel getModel2() {
    return model2;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:J2SECustomPropertySaverTest.java

示例14: testBooleans

import javax.swing.JToggleButton; //导入方法依赖的package包/类
public void testBooleans() throws Exception {
    
    // Test values
    
    String[][] TEST_PROPERTIES = new String[][] {
        new String[] { "propTrue", "true", "false", "true" },
        new String[] { "propFalse", "false", "true", "false" },
        new String[] { "propYes", "yes", "no", "true" },
        new String[] { "propNo", "no", "yes", "false"},
        new String[] { "propOn", "on", "off", "true" },
        new String[] { "propOff", "off", "on", "false" },
    };
    
    JToggleButton.ToggleButtonModel[] models = new JToggleButton.ToggleButtonModel[ TEST_PROPERTIES.length ];
    JToggleButton.ToggleButtonModel[] inverseModels = new JToggleButton.ToggleButtonModel[ TEST_PROPERTIES.length ];        
    JToggleButton buttons[] = new JToggleButton[ TEST_PROPERTIES.length ];
    JToggleButton inverseButtons[] = new JToggleButton[ TEST_PROPERTIES.length ];
    
    // Needed objects
    EditableProperties ep = new EditableProperties(false);
    PropertyEvaluator evaluator = new PlainPropertyEvaluator( ep );
    StoreGroup sg = new StoreGroup();
    StoreGroup inverseSg = new StoreGroup();
    
    // Test correct value of the model
    for( int i = 0; i < TEST_PROPERTIES.length; i++ ) {
        ep.setProperty( TEST_PROPERTIES[i][0], TEST_PROPERTIES[i][1] );
    }        
    for( int i = 0; i < TEST_PROPERTIES.length; i++ ) {
        models[i] = sg.createToggleButtonModel( evaluator, TEST_PROPERTIES[i][0] );
        inverseModels[i] = inverseSg.createInverseToggleButtonModel( evaluator, TEST_PROPERTIES[i][0] );
        buttons[i] = new JToggleButton();
        buttons[i].setModel( models[i] );
        inverseButtons[i] = new JToggleButton();
        inverseButtons[i].setModel( inverseModels[i] );
    }
    for( int i = 0; i < TEST_PROPERTIES.length; i++ ) {
        assertEquals( "Button [" + i + "] has to have correct value.", Boolean.valueOf( TEST_PROPERTIES[i][3] ).booleanValue(), buttons[i].isSelected() );
        assertEquals( "InverseButton [" + i + "] has to have correct value.", !Boolean.valueOf( TEST_PROPERTIES[i][3] ).booleanValue(), inverseButtons[i].isSelected() );
    }
    
    // Change value of all the buttons and test the correct property values
    for( int i = 0; i < TEST_PROPERTIES.length; i++ ) {
        buttons[i].setSelected( !buttons[i].isSelected() );
        inverseButtons[i].setSelected( !inverseButtons[i].isSelected() );            
    }
    
    EditableProperties inverseEp = new EditableProperties(false);
    sg.store( ep );
    inverseSg.store( inverseEp );
    for( int i = 0; i < TEST_PROPERTIES.length; i++ ) {
        assertEquals( "Property [" + i + "] has to have correct value.", TEST_PROPERTIES[i][2], ep.getProperty( TEST_PROPERTIES[i][0] ) );
        assertEquals( "Property [" + i + "] has to have correct value.", TEST_PROPERTIES[i][2], inverseEp.getProperty( TEST_PROPERTIES[i][0] ) );
    }        
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:57,代码来源:StoreGroupTest.java

示例15: createToggleButtonModel

import javax.swing.JToggleButton; //导入方法依赖的package包/类
/** Creates toggle button model representing a boolean in the StoreGroup. <BR>
 * In case the value is one of "true", "yes" "on" the button model 
 * will be "selected". If the property does not exist or is set
 * to some other value the result of isPressed will be false.<BR>
 * Call to the store() method stores the model in appropriate form
 * e.g "true/false", "yes/no", "on/off".<BR>
 * Method will throw <CODE>IllegalArgumentException</CODE> if you try to get more
 * than one model for one property.
 * @param evaluator The PropertyEvaluator to be used to evaluate given 
 *        property
 * @param propertyName Name of the ANT property
 * @return ButtonModel representing the value
 */
public final JToggleButton.ToggleButtonModel createToggleButtonModel( PropertyEvaluator evaluator, String propertyName ) {
    return createBooleanButtonModel( evaluator, propertyName, false );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:StoreGroup.java


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