當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。