Java Code Examples for java.awt.event.ItemEvent#getSource()

The following examples show how to use java.awt.event.ItemEvent#getSource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Font2DTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void itemStateChanged( ItemEvent e ) {
    Object source = e.getSource();

    if ( source instanceof JCheckBoxMenuItem ) {
        JCheckBoxMenuItem cbmi = (JCheckBoxMenuItem) source;
        if ( cbmi == displayGridCBMI )
          fp.setGridDisplay( displayGridCBMI.getState() );
        else if ( cbmi == force16ColsCBMI )
          fp.setForce16Columns( force16ColsCBMI.getState() );
        else if ( cbmi == showFontInfoCBMI ) {
            if ( showFontInfoCBMI.getState() ) {
                fireUpdateFontInfo();
                fontInfoDialog.show();
            }
            else
              fontInfoDialog.hide();
        }
    }
}
 
Example 2
Source File: Font2DTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void itemStateChanged( ItemEvent e ) {
    Object source = e.getSource();

    if ( source instanceof JCheckBoxMenuItem ) {
        JCheckBoxMenuItem cbmi = (JCheckBoxMenuItem) source;
        if ( cbmi == displayGridCBMI )
          fp.setGridDisplay( displayGridCBMI.getState() );
        else if ( cbmi == force16ColsCBMI )
          fp.setForce16Columns( force16ColsCBMI.getState() );
        else if ( cbmi == showFontInfoCBMI ) {
            if ( showFontInfoCBMI.getState() ) {
                fireUpdateFontInfo();
                fontInfoDialog.show();
            }
            else
              fontInfoDialog.hide();
        }
    }
}
 
Example 3
Source File: SelectFamilyNameListener.java    From HBaseClient with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e)
{
    JComboBox v_FamilyNameObj = (JComboBox)e.getSource();
    JComboBox v_ColumnNameObj = null;
    
    if ( v_FamilyNameObj.getName().equals("Edit_FamilyName") )
    {
        v_ColumnNameObj = (JComboBox)XJava.getObject("Edit_ColumnName");
    }
    else
    {
        v_ColumnNameObj = (JComboBox)XJava.getObject("ColumnName");
        ((JComponent)XJava.getObject("xbSubmitFilter")).setEnabled(false);
    }
    
    this.getAppFrame().initColumnNames(e.getItem().toString() ,v_ColumnNameObj);
}
 
Example 4
Source File: Font2DTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void itemStateChanged( ItemEvent e ) {
    Object source = e.getSource();

    if ( source instanceof JCheckBoxMenuItem ) {
        JCheckBoxMenuItem cbmi = (JCheckBoxMenuItem) source;
        if ( cbmi == displayGridCBMI )
          fp.setGridDisplay( displayGridCBMI.getState() );
        else if ( cbmi == force16ColsCBMI )
          fp.setForce16Columns( force16ColsCBMI.getState() );
        else if ( cbmi == showFontInfoCBMI ) {
            if ( showFontInfoCBMI.getState() ) {
                fireUpdateFontInfo();
                fontInfoDialog.show();
            }
            else
              fontInfoDialog.hide();
        }
    }
}
 
Example 5
Source File: FreeColMenuTest.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e) {
    JMenuItem source = (JMenuItem)(e.getSource());
    String s = "Item event detected."
               + newline
               + "    Event source: " + source.getText()
               + " (an instance of " + getClassName(source) + ")"
               + newline
               + "    New state: "
               + ((e.getStateChange() == ItemEvent.SELECTED) ?
                 "selected":"unselected");
    output.append(s + newline);
    output.setCaretPosition(output.getDocument().getLength());
}
 
Example 6
Source File: ABCPanel.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e) {
    View.checkAccess();

    if (e.getSource() == constantTypeList) {
        int index = ((JComboBox) e.getSource()).getSelectedIndex();
        if (index == -1) {
            return;
        }
        updateConstList();
    }
}
 
Example 7
Source File: CExceptionSettingsPanel.java    From binnavi with Apache License 2.0 5 votes vote down vote up
@Override
public void itemStateChanged(final ItemEvent event) {
  @SuppressWarnings("unchecked")
  final JComboBox<String> combobox = (JComboBox<String>) event.getSource();

  final DebuggerException oldException = m_comboboxMap.get(combobox);
  final DebuggerExceptionHandlingAction exceptionAction =
      DebuggerExceptionHandlingAction.convertToHandlingAction(combobox.getSelectedIndex());

  m_comboboxMap.put(combobox, new DebuggerException(oldException.getExceptionName(),
      oldException.getExceptionCode(), exceptionAction));
}
 
Example 8
Source File: DrawTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e) {
    if (e.getSource() instanceof Checkbox) {
        target.setForeground(((Component) e.getSource()).getForeground());
    } else if (e.getSource() instanceof Choice) {
        String choice = (String) e.getItem();
        if (choice.equals("Lines")) {
            target.setDrawMode(DrawPanel.LINES);
        } else if (choice.equals("Points")) {
            target.setDrawMode(DrawPanel.POINTS);
        }
    }
}
 
Example 9
Source File: GraphFrame.java    From FoxTelem with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e) {
	if (e.getSource() == cbRoundLabels) {
		if (e.getStateChange() == ItemEvent.DESELECTED) {
			roundLabels = false;
		} else {
			roundLabels = true;
		}
		if (textDisplay)
			diagnosticTable.updateData();
		else
			panel.updateGraphData("GraphFrame:stateChange:altLabels");
	}
	if (e.getSource() == cbShowSun) {
		if (e.getStateChange() == ItemEvent.DESELECTED) {
			showSun = false;
		} else {
			showSun = true;
		}
		if (textDisplay)
			diagnosticTable.updateData();
		else
			panel.updateGraphData("GraphFrame:stateChange:altLabels");
	}
	if (e.getSource() == cbUptime) {
		if (e.getStateChange() == ItemEvent.DESELECTED) {
			hideUptime = true;
		} else {
			hideUptime = false;
		}
		if (textDisplay)
			diagnosticTable.updateData();
		else
			panel.updateGraphData("GraphFrame:stateChange:Uptime");
	}		
	toggleSunCheckBox();
}
 
Example 10
Source File: MarkOccurencesPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent evt) {
    if (evt.getSource() == onOffCheckBox) {
        componentsSetEnabled();
    }
    controller.changed();
}
 
Example 11
Source File: LayoutControlPanel.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
public void itemStateChanged(ItemEvent e) {
    JRadioButton rb = (JRadioButton) e.getSource();
    if(rb.getText().equals("Absolute") && rb.isSelected()) {
	absolutePositions = true;
    } else if(rb.getText().equals("Relative") && rb.isSelected()) {
	absolutePositions = false;
    } 
           
    for(int i = 0; i < demo.getCurrentControls().size(); i++) {
	Component c = (Component) demo.getCurrentControls().elementAt(i);
               int hPos, vPos, hAlign, vAlign;
               if( c instanceof AbstractButton ) {
                  hPos = ((AbstractButton)c).getHorizontalTextPosition();
                  vPos = ((AbstractButton)c).getVerticalTextPosition();
                  hAlign = ((AbstractButton)c).getHorizontalAlignment();
                  vAlign = ((AbstractButton)c).getVerticalAlignment();
               } else if( c instanceof JLabel ) {
                  hPos = ((JLabel)c).getHorizontalTextPosition();
                  vPos = ((JLabel)c).getVerticalTextPosition();
                  hAlign = ((JLabel)c).getHorizontalAlignment();
                  vAlign = ((JLabel)c).getVerticalAlignment();
               } else {
                   continue;
               }                
               setPosition(c, hPos, vPos);
               setAlignment(c, hAlign, vAlign);
    }
           
    demo.invalidate();
    demo.validate();
    demo.repaint();            
}
 
Example 12
Source File: DrawTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e) {
    if (e.getSource() instanceof Checkbox) {
        target.setForeground(((Component) e.getSource()).getForeground());
    } else if (e.getSource() instanceof Choice) {
        String choice = (String) e.getItem();
        if (choice.equals("Lines")) {
            target.setDrawMode(DrawPanel.LINES);
        } else if (choice.equals("Points")) {
            target.setDrawMode(DrawPanel.POINTS);
        }
    }
}
 
Example 13
Source File: FcdProPanel.java    From FoxTelem with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e) {
	if (e.getSource() == cbMixerGain) {
		setMixerGain(cbMixerGain.getSelectedIndex());			
	}
	if (e.getSource() == cbLnaGain) {
		setLnaGain(cbLnaGain.getSelectedIndex());
	}
}
 
Example 14
Source File: SWCImportOptionsDialog.java    From SNT with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void itemStateChanged(final ItemEvent e) {

	final Object source = e.getSource();

	if (source == applyScaleCheckbox || source == applyOffsetCheckbox)
		updateEnabled();
}
 
Example 15
Source File: CPSComplexFilterDialog.java    From cropplanning with GNU General Public License v3.0 5 votes vote down vote up
public void itemStateChanged( ItemEvent arg0 ) {
    Object source = arg0.getSource();

    if ( source == rdoAllDates || source == rdoLimitDates ) {
        setDateRangeSet( rdoLimitDates.isSelected() );
        setComponentsEnabled( rdoLimitDates.isSelected() );
    }

}
 
Example 16
Source File: CodeAssigner.java    From MARA with Apache License 2.0 5 votes vote down vote up
public void itemStateChanged(ItemEvent evt)
{
	JComboBox classes = (JComboBox)evt.getSource();
	
	if (evt.getStateChange() == ItemEvent.SELECTED) 
	{
		refined.removeAllItems();
		String [] codes = fs.loadCodes(classes.getSelectedItem().toString());
		for (String s: codes)
			refined.addItem(s);
       }

}
 
Example 17
Source File: QueryController.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e) {
    if(e.getSource() == panel.filterComboBox) {
        onFilterChange((Filter)e.getItem());
    }
}
 
Example 18
Source File: SettingsFrame.java    From FoxTelem with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e) {
	Object source = e.getItemSelectable();

	if (source == cbUploadToServer) { 
		if (e.getStateChange() == ItemEvent.DESELECTED) {
			setServerPanelEnabled(false);
		} else {
			setServerPanelEnabled(true);
		}
	}
	
	if (source == cbUseDDEAzEl) { 
		if (e.getStateChange() == ItemEvent.SELECTED) {
			cbFoxTelemCalcsPosition.setSelected(false);
			cbFoxTelemCalcsDoppler.setSelected(false);
		}
	}
	
	if (source == cbFoxTelemCalcsPosition) { 
		if (e.getStateChange() == ItemEvent.SELECTED) {
			cbUseDDEAzEl.setSelected(false);
			cbFoxTelemCalcsDoppler.setEnabled(true);
		} else {
			if (cbWhenAboveHorizon.isSelected())
				cbWhenAboveHorizon.setSelected(false);
			if (cbFoxTelemCalcsDoppler.isSelected())
				cbFoxTelemCalcsDoppler.setSelected(false);
			cbFoxTelemCalcsDoppler.setEnabled(false);
		}
	}
	if (source == cbFoxTelemCalcsDoppler) { 
		if (e.getStateChange() == ItemEvent.SELECTED) {
			rdbtnTrackSignal.setSelected(false);
		} else {
		}
	}
	if (source == cbWhenAboveHorizon) { 
		if (e.getStateChange() == ItemEvent.SELECTED) {
			if (!cbFoxTelemCalcsPosition.isSelected() && !cbUseDDEAzEl.isSelected())
				cbFoxTelemCalcsPosition.setSelected(true);
			MainWindow.inputTab.rdbtnFindSignal.setSelected(true);
		}
		
	}
	if (e.getSource() == rdbtnTrackSignal) {
		if (e.getStateChange() == ItemEvent.DESELECTED) {
            Config.findSignal=false;
            //Config.save();
        } else {
        	Config.findSignal=true;
        	cbFoxTelemCalcsDoppler.setSelected(false);
        	//Config.save();
        }
	}
}
 
Example 19
Source File: CPSRadioButton.java    From cropplanning with GNU General Public License v3.0 4 votes vote down vote up
public void itemStateChanged( ItemEvent arg0 ) {
    if ( arg0.getSource() == this )
        setHasChanged(true);
}
 
Example 20
Source File: TODOLists.java    From cropplanning with GNU General Public License v3.0 4 votes vote down vote up
public void itemStateChanged(ItemEvent arg0) {

        Object source = arg0.getSource();
        GregorianCalendar temp = new GregorianCalendar();
        GregorianCalendar now = new GregorianCalendar();
        now.setTime(new Date());
        temp.setTime(now.getTime());


        if (source == rdoDateThisWeek || source == rdoDateNextWeek || source == rdoDateThisNextWeek) {

            if (source == rdoDateNextWeek) {
                temp.add(Calendar.WEEK_OF_YEAR, 1);
            }

            temp.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
            dtcDateOtherStart.setDate(temp.getTime());

            if (source == rdoDateThisNextWeek) {
                temp.add(Calendar.WEEK_OF_YEAR, 1);
            }

            temp.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
            dtcDateOtherEnd.setDate(temp.getTime());

            dtcDateOtherEnd.setEnabled(false);
            dtcDateOtherStart.setEnabled(false);

        } else if (source == rdoDateOther) {
            dtcDateOtherEnd.setEnabled(true);
            dtcDateOtherStart.setEnabled(true);
        } else if ( source == cmbWhatToExport ) {

          String s = (String) cmbWhatToExport.getSelectedItem();
          String t = "";
          if ( s.equals( TL_GH_SEEDING ) )
            t = DSC_GH_SEEDING;
          else if ( s.equals( TL_FIELD_PLANTING ) )
            t = DSC_FIELD_PLANTING;
          else if ( s.equals( TL_ALL_PLANTING_LISTS ) )
            t = DSC_ALL_PLANTING_LISTS;
          else if ( s.equals( TL_ALL_PLANTINGS ) )
            t = DSC_ALL_PLANTINGS;
          else if ( s.equals( TL_SEED_ORDER_WORKSHEET ) )
            t = DSC_SEED_ORDER_WORKSHEET;
          else if ( s.equals( TL_HARVEST_AVAILABILITY ) )
            t = DSC_HARVEST_AVAILABILITY;
          else if ( s.equals( TL_GOOGLE_CAL ) )
            t = DSC_GOOGLE_CAL;

          // OR together a list of things which should have date components enabled
          setDateComponentsEnabled( s.equals( TL_GH_SEEDING ) ||
                                    s.equals( TL_FIELD_PLANTING ) );

          setExportButtonsForGCal( s.equals( TL_GOOGLE_CAL ) );

          lblExportDesc.setText( DSC_START + t + DSC_END );

        }

    }