Help on JRadioButton event

While i was searching for a code sample for getting the selected radio button, I have found following method
I have following method that returns selected radio button of a group.
    public static JRadioButton getSelection(ButtonGroup group) {
        for (java.util.Enumeration e=group.getElements(); e.hasMoreElements(); ) {
            JRadioButton b = (JRadioButton)e.nextElement();
            if (b.getModel() == group.getSelection()) {
                return b;
        return null;
    }Now if radio button is not selected this method returns null. When i call this method to get the selected radiobutton and if radio button is not selected then it throwing nullpointerexception. How can i fix this.

if no selection you are returning null, so test the return value
JRadioButton rb = getSelection(...);
if(rb == null) doSomething();
else doSomethingElse();

Similar Messages

  • Help with Keyboard Event

    Hi, I am designing a drum machine in flash pro Cs6 actionscript 3.0  and I am trying to add a keyboard event that will trigger a button event that I have all ready created, I can create the event to play the sound but this is not what I want, can I call the click event so the button will move on the key event triggering the sound, here is an example of one of my buttons code... btn, thank you if anyone can help.
    import flash.events.KeyboardEvent;
    playsound2.fla
    playsound with extra functionality:
    textbox added.
    Displays ID3 info of the sound
    btn.addEventListener(MouseEvent.CLICK, playSomeSound);
    function playSomeSound(e:MouseEvent)
              var req:URLRequest = new URLRequest("Savage.mp3");
              var s:Sound = new Sound(req);
              s.addEventListener(Event.COMPLETE, onSoundLoaded);
              s.addEventListener(Event.ID3, onID3Info);
    function onSoundLoaded(event:Event):void
              var localSound:Sound = event.target as Sound;
              localSound.play();
    function onID3Info(e:Event):void
              var id3Props:ID3Info = e.target.id3;
              var sOut:String = txt.text = "";
              for (var propName:String in id3Props)
                        sOut = propName + "=" + id3Props[propName] + "\n";
                        trace(sOut);
                        txt.appendText(sOut);
              txt.text = id3Props.comment;
    var ba:ByteArray = new ByteArray();
    var gr:Sprite = new Sprite();
    gr.x = 5;
    gr.y = 50;
    addChild(gr);
    var time:Timer = new Timer(50);
    time.addEventListener(TimerEvent.TIMER, timerHandler);
    time.start();
    function timerHandler(event:TimerEvent):void
              SoundMixer.computeSpectrum(ba, false);
              var i:int;
              gr.graphics.clear();
              gr.graphics.lineStyle(2, 0xFF0000);
              gr.graphics.beginFill(0x00ff00);
              gr.graphics.moveTo(10, 10);
              //  draw a circle.;
              var w:uint = 15;
              for (i=0; i<512; i+=w)
                        var t:Number = ba.readFloat();
                        var n:Number = (t * 200);
                        gr.graphics.drawCircle(i, 0, -n);

    Thanks, this was the code I added in the end and it works nicely, It covers my sound and id3 aswell as Im displaying lcd text in a dynamic text box.
    stage.addEventListener(KeyboardEvent.KEY_DOWN, btndownKey);
    function btndownKey(event:KeyboardEvent)
              if (event.keyCode == 83)
                        var url:String = "Savage.mp3";
                        var request:URLRequest = new URLRequest(url);
                        var s:Sound = new Sound();
                        s.addEventListener(Event.COMPLETE, completeHandler);
                        s.addEventListener(Event.ID3, onID3Info);
                        s.load(request);

  • Help with combobox event handling

    hey techies
    does knw any1 tutorial or where any URL which helps me adding event handling to combobox
    iam new at event handling
    i tried
    jc1.addItemListener(this);
    public void itemStateChanged(ItemEvent event)
              if(event.getSource()==jc1)
              System.out.println("hello");
         }is this way correct to specify event handling in combobox
    i tired this iam getting NPE like this
    Exception in thread "main" java.lang.NullPointerException
    at FinalMobile.<init>(FinalMobile.java:213)
    at FinalMobile.main(FinalMobile.java:740)
    plz jst let me knw and dnt tell me to refer swing tutorial i have been reffering it
    any help is appreciated

    does knw any1 tutorial or where any URL which helps me adding event handling to comboboxExcuse me, I've told you at least 4 times now to download and read the Swing tutorial which has all this information with working examples. I even provided you with the download link.
    How do you have the nerve to say you can't find any tutorial?

  • JRadioButton Event

    Hi! I have a problem with the JRadioButton events. In my application I have a Jpanel in which I add new components when my program is run depend of the information of my dataBase. The code is the next:
    void new_jPanel_attrib(...){
    if(caso.equals("Query")){
    ButtonGroup buttonGroup1 = new ButtonGroup();
    JRadioButton jRadioButton1 = new JRadioButton();
    JRadioButton jRadioButton2 = new JRadioButton();
    jRadioButton1.setText("Exacto");
    jRadioButton2.setText("Impreciso");
    jRadioButton1.setActionCommand("Exacto");
    jRadioButton2.setActionCommand("Impreciso");
    this.jPanel9.add(jRadioButton1);
    this.jPanel9.add(jRadioButton2);
    buttonGroup1.add(jRadioButton2);
    buttonGroup1.add(jRadioButton1);
    JComboBox jComboBox = new JComboBox();
    JTextField jTextField = new JTextField();
    jTextField.setName("");
    jTextField.setColumns(4);
    this.jPanel4.add(jTextField);
    this.jPanel4.add(jComboBox);
    and I want that when the jRadioButton1 is pressed the jComboBox1 becames unEditable, and when I press the jRadioButton2 is pressed the jTextField1 becames unEditable.
    I have write this function but I don�t know how to access to the components in the jPanel4 because I have created it in another function.
    /** Listens to the radio buttons. */
    public void actionPerformed(ActionEvent e) {
    if(e.getActionCommand().equals("Exacto"))
    //here I want to change the jComboBox to set it not Editable
    else if (e.getActionCommand().equals("Impreciso"))
    //here I want to change the jTextField to set it not Editable
    }

    Declare the combo box and text field as globals:class ABC implements ActionListener, ... {
        private JComboBox box;
        private JTextField field;
        public ABC () {
        public void actionPerformed (ActionEvent event) {
            if (...) {
                box.setEnabled (false);
                field.setEnabled (true);
            } else if (...) {
                box.setEnabled (true);
                field.setEnabled (false);
    }Kind regards,
      Levi

  • I deleted my events in iPhoto Help?  The "events" are not in the trash.  I did download stellar phoenix recovery but not sure what to do

    i deleted my events in iPhoto Help?  The "events" are not in the trash.  I did download stellar phoenix recovery but not sure what to do

    i deleted my events in iPhoto Help?
    You deleted them in iPhoto on your Mac?
    If you do not have a backup of your iPhoto library, run the recovery program you downloaded, then reimport the folder with recovered photos into iPhoto.
    You will probably have to weed out plenty of seemingly duplicates (thumbnails, previews, and original files), since the program will not be able to reconstruct your events, only find image files.

  • JRadioButton Event Handling Help???

    Hello everyone. I have been working on this program for a while now and it is just bugging me. It is a stoplight in which the lights are turned on by radio buttons. I have all the code but for some reason my radio buttons do not work. I have a listener and the actionperformed class defined and I just cannot figure out what is going on. Any help would be greatly appreciated.
    Thanks,
    Austin
    import java.awt.*;*
    *import java.awt.event.*;
    import javax.swing.*;*
    *class Lights extends JPanel*
    *public JRadioButton btnR;*
    *public JRadioButton btnY;*
    *public JRadioButton btnG;*
    *public JRadioButton btnO;*
    *public Color rColor;*
    *public Color yColor;*
    *public Color gColor;*
    *public Color general;*
    *public void paintComponent ( Graphics g)*
    *super.paintComponent ( g );*
    *general= getBackground();*
    *// Set foreground color*
    *g.setColor (Color.black);*
    *// get the size of the drawing area*
    *Dimension size = this.getSize();*
    *// Bounding rectangle for the traffic lights*
    *int rectWidth = (int) (0.4* size.width);
    int rectHeight = (int) (0.8 *size.height);*
    *// Location where the rectangle is to be drawn*
    *int xint = (int) (0.3* size.width);
    int yint = (int) (0.1 *size.height);*
    *// Draw bounding rectangle*
    *g.drawRect (xint, yint, rectWidth, rectHeight);*
    *// Draw three circles inside the rectangle*
    *int circleHeight = (int) (0.9* rectHeight / 3);
    int circleWidth = (int) (0.8 *rectWidth);*
    *int circleDia = (circleHeight < circleWidth)? circleHeight : circleWidth;*
    *int xOffset = (rectWidth - circleDia) / 2;*
    *int yOffset = (rectHeight - 3* circleDia) / 4;
    xint = xint +xOffset;+
    +yint = yint+ yOffset;
    // Draw the red light
    g.setColor(getBackground());
    g.setColor(rColor);
    g.fillOval (xint, yint, circleDia, circleDia);
    g.setColor(Color.black);
    g.drawOval (xint, yint, circleDia, circleDia);
    g.setColor(getBackground());
    rColor= general;
    // Draw the yellow light
    yint = yint +circleDia+ yOffset;
    g.setColor(yColor);
    g.fillOval (xint, yint, circleDia, circleDia);
    g.setColor(Color.black);
    g.drawOval (xint, yint, circleDia, circleDia);
    g.setColor(getBackground());
    yColor= general;
    // Draw the green light
    yint = yint +circleDia+ yOffset;
    g.setColor(gColor);
    g.fillOval (xint, yint, circleDia, circleDia);
    g.setColor(Color.black);
    g.drawOval (xint, yint, circleDia, circleDia);
    g.setColor(getBackground());
    gColor= general;
    public class TrafficLights
    public static void main (String[] args)
    Lights lightPanel = new Lights();
    lightPanel.setBorder ( BorderFactory.createEmptyBorder (10, 20, 10, 20 ));
    // Create buttons to simulate switches
    lightPanel.btnR = new JRadioButton ("Red");
    lightPanel.btnY = new JRadioButton ("Yellow");
    lightPanel.btnG = new JRadioButton ("Green");
    lightPanel.btnO = new JRadioButton ("Off");
    ButtonGroup switches = new ButtonGroup ();
    switches.add (lightPanel.btnR);
    switches.add (lightPanel.btnY);
    switches.add (lightPanel.btnG);
    switches.add (lightPanel.btnO);
    JPanel switchPanel = new JPanel();
    switchPanel.setBorder ( BorderFactory.createEmptyBorder (10, 20, 10, 20 ));
    switchPanel.setLayout (new GridLayout (1, 4));
    switchPanel.add (lightPanel.btnR);
    switchPanel.add (lightPanel.btnY);
    switchPanel.add (lightPanel.btnG);
    switchPanel.add (lightPanel.btnO);
    JFrame frame = new JFrame ("Traffic Lights");
    frame.getContentPane().add( lightPanel, BorderLayout.CENTER);
    frame.getContentPane().add( switchPanel, BorderLayout.SOUTH);
    frame.setSize (400, 600);
    frame.setVisible (true);
    frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
    class LightButtonListener implements ActionListener
    private Lights theLight;
    //public Color c;
    public LightButtonListener ( Lights aLight )
    theLight = aLight;
    //create listener and add buttons to it
    theLight.btnR.addActionListener ( this );
    theLight.btnY.addActionListener ( this );
    theLight.btnG.addActionListener ( this );
    theLight.btnO.addActionListener ( this );
    public void actionPerformed ( ActionEvent evt )
    if ( evt.getSource() == theLight.btnR)
    theLight.rColor= Color.red;
    theLight.repaint();
    else if (evt.getSource() == theLight.btnY)
    theLight.yColor= Color.yellow;
    theLight.repaint();
    else if (evt.getSource() == theLight.btnG)
    theLight.rColor= Color.green;
    theLight.repaint();
    else if (evt.getSource() == theLight.btnO)
    theLight.repaint();
    }

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class Lights extends JPanel
      public JRadioButton btnR;
      public JRadioButton btnY;
      public JRadioButton btnG;
      public JRadioButton btnO;
      public Color rColor;
      public Color yColor;
      public Color gColor;
      public Color general;
      public void paintComponent ( Graphics g)
        super.paintComponent ( g );
        general= getBackground();
        // Set foreground color
        g.setColor (Color.black);
        // get the size of the drawing area          
        Dimension size = this.getSize();
        // Bounding rectangle for the traffic lights
        int rectWidth = (int) (0.4 * size.width);
        int rectHeight = (int) (0.8 * size.height);
        // Location where the rectangle is to be drawn
        int xint = (int) (0.3 * size.width);
        int yint = (int) (0.1 * size.height);
        // Draw bounding rectangle
        g.drawRect (xint, yint, rectWidth, rectHeight);
        // Draw three circles inside the rectangle
        int circleHeight = (int) (0.9 * rectHeight / 3);
        int circleWidth = (int) (0.8 * rectWidth);
        int circleDia = (circleHeight < circleWidth)? circleHeight : circleWidth;
        int xOffset = (rectWidth - circleDia) / 2;
        int yOffset = (rectHeight - 3 * circleDia) / 4;
        xint = xint + xOffset;
        yint = yint + yOffset;
        // Draw the red light
        g.setColor(getBackground());
        g.setColor(rColor);
        g.fillOval (xint, yint, circleDia, circleDia);
        g.setColor(Color.black);
        g.drawOval (xint, yint, circleDia, circleDia);
        g.setColor(getBackground());
        rColor= general;
        // Draw the yellow light
        yint = yint + circleDia + yOffset;
        g.setColor(yColor);
        g.fillOval (xint, yint, circleDia, circleDia);
        g.setColor(Color.black);
        g.drawOval (xint, yint, circleDia, circleDia);
        g.setColor(getBackground());
        yColor= general;
        // Draw the green light
        yint = yint + circleDia + yOffset;
        g.setColor(gColor);
        g.fillOval (xint, yint, circleDia, circleDia);
        g.setColor(Color.black);
        g.drawOval (xint, yint, circleDia, circleDia);
        g.setColor(getBackground());
        gColor= general;
    public class TrafficLights
      public static void main (String[] args)
         Lights lightPanel = new Lights();
         lightPanel.setBorder ( BorderFactory.createEmptyBorder (10, 20, 10, 20 ));
        // Create buttons to simulate switches
        lightPanel.btnR = new JRadioButton ("Red");
        lightPanel.btnY = new JRadioButton ("Yellow");
        lightPanel.btnG = new JRadioButton ("Green");
        lightPanel.btnO = new JRadioButton ("Off");
        ButtonGroup switches = new ButtonGroup ();
        switches.add (lightPanel.btnR);
        switches.add (lightPanel.btnY);
        switches.add (lightPanel.btnG);
        switches.add (lightPanel.btnO);
        JPanel switchPanel = new JPanel();
        switchPanel.setBorder ( BorderFactory.createEmptyBorder (10, 20, 10, 20 ));
        switchPanel.setLayout (new GridLayout (1, 4));
        switchPanel.add (lightPanel.btnR);
        switchPanel.add (lightPanel.btnY);
        switchPanel.add (lightPanel.btnG);
        switchPanel.add (lightPanel.btnO);
        JFrame frame = new JFrame ("Traffic Lights");
        frame.getContentPane().add( lightPanel, BorderLayout.CENTER);
        frame.getContentPane().add( switchPanel, BorderLayout.SOUTH);
        frame.setSize (400, 600);
        frame.setVisible (true);
        frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
    class LightButtonListener implements ActionListener
      private Lights theLight;
      //public Color c;
      public LightButtonListener ( Lights aLight )
        theLight = aLight;
        //create listener and add buttons to it
        theLight.btnR.addActionListener ( this );
        theLight.btnY.addActionListener ( this );
        theLight.btnG.addActionListener ( this );
        theLight.btnO.addActionListener ( this );
      public void actionPerformed ( ActionEvent evt )
        if ( evt.getSource() == theLight.btnR)
          theLight.rColor= Color.red;
          theLight.repaint();
        else if (evt.getSource() == theLight.btnY)
             theLight.yColor= Color.yellow;
            theLight.repaint();
        else if (evt.getSource() == theLight.btnG)
             theLight.rColor= Color.green;
            theLight.repaint();
        else if (evt.getSource() == theLight.btnO)
            theLight.repaint();
    }Edited by: CS313e on Mar 27, 2010 1:21 AM
    Edited by: CS313e on Mar 27, 2010 9:59 AM

  • Help on Multiple Event Listeners

    Hi:
    How do you implement both ItemListener and ListSelectionListener in the same interface? In another word, how do I put JRadioButton, JList, JComboBox...etc,each one with its own listener in init() method? I came up with the following program. Anyone have any idea fixing the problem?
    import javax.swing.*;
    import java.awt.*; //for border layout
    import javax.swing.event.*; //for ListSelectionListener
    import java.awt.event.*;
    public class TextFormatter03 extends JApplet implements ActionListener
    private Container masterPane, slavePane, bottomPane;
    private JTextArea textPanel;
    private JScrollPane textScrollPane;
    private JRadioButton courierButton, serifButton, arialButton;
    private JList sizeList;
    private JCheckBox boldStyle,italicStyle;
    private JComboBox fontColor;
    private String colorItems[]={"Cyan","Green","Red","Blue","Magenta"};
    private String sizeItems[]={"30","28","26","24","22"};
    private String custFont;
    private int custStyle, custSize;
    public void init()
    //get the content pane to add component on to
    masterPane = this.getContentPane();
    //deal with font
    serifButton = new JRadioButton("Serif");
    serifButton.setSelected(true);
    courierButton = new JRadioButton("Courier");
    courierButton.setSelected(false);
    arialButton = new JRadioButton("Arial");
    arialButton.setSelected(false);
    //group the radio buttons
    ButtonGroup group= new ButtonGroup();
    group.add(serifButton);
    group.add(courierButton);
    group.add(arialButton);
    //register a listener for the radio buttons
    serifButton.addActionListener(this);
    courierButton.addActionListener(this);
    arialButton.addActionListener(this);
    masterPane.add(group, BorderLayout.NORTH);
    //deal with font size
    sizeList = new JList (sizeItems);
    sizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    sizeList.addListSelectionListener(this);
    slavePane = new JScrollPane(sizeList,
    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    masterPane.add(slavePane, BorderLayout.WEST);
    //display text
    textPanel= new JTextArea();
    textPanel.setText("Select options to modify this text.");
    textPanel.setBackground(Color.WHITE);
    textPanel.setLineWrap(true);
    textScrollPane = new JScrollPane(textPanel);
    masterPane.add(textScrollPane, BorderLayout.CENTER);
    textPanel.setFont(new Font("Serif",3,15));
    //deal with font color
    fontColor= new JComboBox(colorItems);
    masterPane.add(fontColor);
    //deal with font style
    boldStyle = new JCheckBox("Bold");
    boldStyle.setSelected(false);
    boldStyle.addItemListener(this);
    bottomPane.add(boldStyle);
    italicStyle = new JCheckBox("Italic");
    italicStyle.setSelected(false);
    italicStyle.addItemListener(this);
    bottomPane.add(italicStyle);
    add(bottomPane, BorderLayout.SOUTH);      
    public void actionPerformed(ActionEvent e)
         String Selected = "result";
         //set the font
         if(serifButton.isSelected())
              custFont="Serif";
         if(arialButton.isSelected())
              custFont="Arial";
         if(courierButton.isSelected())
              custFont="Courier";
         //set font style
         if(boldStyle.isSelected())
              custStyle = Font.BOLD;
         if(italicStyle.isSelected())
              custStyle = Font.ITALIC;
         if(boldStyle.isSelected()&&italicStyle.isSelected())
              custStyle = Font.BOLD + Font.ITALIC;
    public void valueChanged(ListSelectionEvent event)
         String response = "";
         //set the font size
         if(sizeList.getSelectedIndex()!=-1)
              switch (sizeList.getSelectedIndex())
                   case 0:
                        custSize = 30;
                        break;
                   case 1:
                        custSize = 28;
                        break;
                   case 2:
                   custSize = 26;
                   break;     
                   case 3:
                   custSize = 24;
                   break;     
                   case 4:
                   custSize = 22;
                   break;     
                   textPanel.setFont(new Font (custFont, custStyle,custSize));
         //set font color
         if(fontColor.getSelectedItem()=="Cyan")
              textPanel.setForeground(Color.CYAN);
         if(fontColor.getSelectedItem()=="Cyan")
              textPanel.setForeground(Color.CYAN);
         if(fontColor.getSelectedItem()=="Cyan")
              textPanel.setForeground(Color.CYAN);
         if(fontColor.getSelectedItem()=="Green")
              textPanel.setForeground(Color.GREEN);
         if(fontColor.getSelectedItem()=="Red")
              textPanel.setForeground(Color.RED);
         if(fontColor.getSelectedItem()=="Blue")
              textPanel.setForeground(Color.BLUE);
         if(fontColor.getSelectedItem()=="Magenta")
              textPanel.setForeground(Color.MAGENTA);
    }

    Help. The program didn't compile. I followed what you suggested. Here are the program and the error message.
    import javax.swing.*;
    import java.awt.*; //for border layout
    import javax.swing.event.*; //for ListSelectionListener
    import java.awt.event.*;
    public class TextFormatter03 extends JApplet implements ActionListener, ItemListener,ListSelectionListener
    private Container masterPane, slavePane, bottomPane;
    private JTextArea textPanel;
    private JScrollPane textScrollPane;
    private JRadioButton courierButton, serifButton, arialButton;
    private JList sizeList;
    private JCheckBox boldStyle,italicStyle;
    private JComboBox fontColor;
    private String colorItems[]={"Cyan","Green","Red","Blue","Magenta"};
    private String sizeItems[]={"30","28","26","24","22"};
    private String custFont;
    private int custStyle, custSize;
    public void init()
    //get the content pane to add component on to
    masterPane = this.getContentPane();
    //deal with font
    serifButton = new JRadioButton("Serif");
    serifButton.setSelected(true);
    courierButton = new JRadioButton("Courier");
    courierButton.setSelected(false);
    arialButton = new JRadioButton("Arial");
    arialButton.setSelected(false);
    //group the radio buttons
    ButtonGroup group= new ButtonGroup();
    group.add(serifButton);
    group.add(courierButton);
    group.add(arialButton);
    //register a listener for the radio buttons
    serifButton.addActionListener(this);
    courierButton.addActionListener(this);
    arialButton.addActionListener(this);
    masterPane.add(group, BorderLayout.NORTH);
    //deal with font size
    sizeList = new JList (sizeItems);
    sizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    sizeList.addListSelectionListener(this);
    slavePane = new JScrollPane(sizeList,
    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    masterPane.add(slavePane, BorderLayout.WEST);
    //display text
    textPanel= new JTextArea();
    textPanel.setText("Select options to modify this text.");
    textPanel.setBackground(Color.WHITE);
    textPanel.setLineWrap(true);
    textScrollPane = new JScrollPane(textPanel);
    masterPane.add(textScrollPane, BorderLayout.CENTER);
    textPanel.setFont(new Font("Serif",3,15));
    //deal with font color
    fontColor= new JComboBox(colorItems);
    masterPane.add(fontColor);
    //deal with font style
    boldStyle = new JCheckBox("Bold");
    boldStyle.setSelected(false);
    boldStyle.addItemListener(this);
    bottomPane.add(boldStyle);
    italicStyle = new JCheckBox("Italic");
    italicStyle.setSelected(false);
    italicStyle.addItemListener(this);
    bottomPane.add(italicStyle);
    add(bottomPane, BorderLayout.SOUTH);      
    public void actionPerformed(ActionEvent e)
         String Selected = "result";
         //set the font
         if(serifButton.isSelected())
              custFont="Serif";
         if(arialButton.isSelected())
              custFont="Arial";
         if(courierButton.isSelected())
              custFont="Courier";
         //set font style
         if(boldStyle.isSelected())
              custStyle = Font.BOLD;
         if(italicStyle.isSelected())
              custStyle = Font.ITALIC;
         if(boldStyle.isSelected()&&italicStyle.isSelected())
              custStyle = Font.BOLD + Font.ITALIC;
    public void valueChanged(ListSelectionEvent event)
         String response = "";
         //set the font size
         if(sizeList.getSelectedIndex()!=-1)
              switch (sizeList.getSelectedIndex())
                   case 0:
                        custSize = 30;
                        break;
                   case 1:
                        custSize = 28;
                        break;
                   case 2:
                   custSize = 26;
                   break;     
                   case 3:
                   custSize = 24;
                   break;     
                   case 4:
                   custSize = 22;
                   break;     
                   textPanel.setFont(new Font (custFont, custStyle,custSize));
         //set font color
         if(fontColor.getSelectedItem()=="Cyan")
              textPanel.setForeground(Color.CYAN);
         if(fontColor.getSelectedItem()=="Cyan")
              textPanel.setForeground(Color.CYAN);
         if(fontColor.getSelectedItem()=="Cyan")
              textPanel.setForeground(Color.CYAN);
         if(fontColor.getSelectedItem()=="Green")
              textPanel.setForeground(Color.GREEN);
         if(fontColor.getSelectedItem()=="Red")
              textPanel.setForeground(Color.RED);
         if(fontColor.getSelectedItem()=="Blue")
              textPanel.setForeground(Color.BLUE);
         if(fontColor.getSelectedItem()=="Magenta")
              textPanel.setForeground(Color.MAGENTA);
    TextFormatter03.java:6: TextFormatter03 should be declared abstract; it does not define itemStateChanged(java.awt.event.ItemEvent) in TextFormatter03
    public class TextFormatter03 extends JApplet implements ActionListener, ItemListener,ListSelectionListener
    ^
    java:44: cannot resolve symbol
    symbol : method add (javax.swing.ButtonGroup,java.lang.String)
    location: class java.awt.Container
    masterPane.add(group, BorderLayout.NORTH);
    ^
    2 errors
    Process completed.

  • Help with JRadioButton

    Could someone help me with trying to have an image rather than text on a radio button. I can make a radio button with text, but when I try to use an Icon rather than text for a label there is no button created. My code is below. Thanks.
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    public class appTag extends JApplet
         JLabel     serviceInfoL,
              welcomeLabel,
              nameLabel,
              addressLabel,
              cityLabel,
              stateLabel,
              zipLabel,
              emailLabel,
              phoneNoLabel,
              cctypeLabel1,
              cctypeLabel2,
              cctypeLabel3,
              cctypeLabel4,
              ccNoLabel,
              ccExpLabel,
         ConnectL,
                   sIconL1,
                   sIconL2,
         sIconL3;
    JTextField nameTf,
                   addressTf,
                        cityTf,
                        stateTf,
                        zipTf,
                        emailTf,
                        phoneNoTf;
         JPasswordField ccNo,
                        expDate;
         JButton orderButton,
                        clearButton;
         JCheckBox service1,
                        service2,
                        service3;
         ButtonGroup radioGroup;
         JRadioButton Discovertype,
                        Visatype,
                        MCtype,
                        AEtype;
         JComboBox compTypePC,
                        compTypeApple,
                        compTypeLinux;
    Icon          EagleNet,
                   service1Icon,
                   service2Icon,
                   service3Icon,
                   ccIcon1,
                   ccIcon2,
                   ccIcon3,
                   ccIcon4;
    //Icon Connect;
    public void init ()
         // define GUI components
         JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM);
         JPanel pane = new JPanel ();
         JPanel secondPane = new JPanel();
         JPanel thirdPane = new JPanel();
         JPanel fourthPane = new JPanel();
         EagleNet = new ImageIcon("hosting2.jpg");
         service1Icon = new ImageIcon("connect.gif");
         service2Icon = new ImageIcon("2_computers.gif");
         service3Icon = new ImageIcon("WWW.gif");
         ccIcon1 = new ImageIcon("visa.jpg");
         ccIcon2 = new ImageIcon("mastercard.jpg");
         ccIcon3 = new ImageIcon("americanexpress.jpg");
         ccIcon4 = new ImageIcon("discovernovus.jpg");
         //needs to be resized to fit applet
         nameTf = new JTextField(12);
         addressTf = new JTextField(12);
         cityTf = new JTextField(12);
         stateTf = new JTextField(2);
         zipTf = new JTextField(5);
         emailTf = new JTextField(15);
         phoneNoTf = new JTextField(10);
         ccNo = new JPasswordField(16);
         expDate = new JPasswordField(4);
         ccNo.setEchoChar('#');
         expDate.setEchoChar('#');
         Discovertype = new JRadioButton(ccIcon1,false);
         Visatype = new JRadioButton(ccIcon2,false);
         MCtype = new JRadioButton(ccIcon3,false);
         AEtype = new JRadioButton(ccIcon4,false);
         radioGroup = new ButtonGroup ();
         radioGroup.add(Discovertype);
         radioGroup.add(Visatype);
         radioGroup.add(MCtype);
         radioGroup.add(AEtype);
         cctypeLabel1 = new JLabel(ccIcon1);
         cctypeLabel2 = new JLabel(ccIcon2 );
         cctypeLabel3 = new JLabel(ccIcon3);
         cctypeLabel4 = new JLabel(ccIcon4);
         sIconL1 = new JLabel(service1Icon);
         sIconL2 = new JLabel(service2Icon);
         sIconL3 = new JLabel(service3Icon);
         ConnectL = new JLabel(EagleNet);
         welcomeLabel = new JLabel("We are located @ 9A N. Zetterowe Avenue Statesboro, GA 30458");
         serviceInfoL = new JLabel("Please pick the service(s) you are interested in purchasing.");
         // build the GUI layout
         pane.add(ConnectL);
         pane.add(welcomeLabel);
         //pane.add (Connect);
         //build second Pane
         tabbedPane.add("Welcome to EagleNet",pane);
         tabbedPane.add("Services", secondPane);
         tabbedPane.add("Customer Info", thirdPane);
         tabbedPane.add("Receipt", fourthPane);
         this.setContentPane (tabbedPane);
         //adding menubar
         JMenuBar menuBar = new JMenuBar();
         JMenu fileMenu = new JMenu("File");
         JMenu editMenu = new JMenu("Edit");
         JMenu toolMenu = new JMenu("Tool");
         JMenu helpMenu = new JMenu("Help");
         JMenuItem openItem = new JMenuItem("Open");
         JMenuItem saveItem = new JMenuItem("Save");
         JMenuItem quitItem = new JMenuItem("Quit");
         JMenuItem clearItem = new JMenuItem("Clear");
         JMenuItem versionItem = new JMenuItem("Version");
         fileMenu.add(openItem);
         fileMenu.add(saveItem);
         fileMenu.add(quitItem);
         editMenu.add(clearItem);
         helpMenu.add(versionItem);
         menuBar.add(fileMenu);
         menuBar.add(editMenu);
         menuBar.add(toolMenu);
         menuBar.add(helpMenu);
         setJMenuBar(menuBar);
         //make secondPane
         secondPane.setLayout(new FlowLayout(FlowLayout.LEFT, 20, 20));
         secondPane.add(serviceInfoL);
         //secondPane.
         secondPane.add(sIconL1);
         secondPane.add(service1 = new JCheckBox("Internet Access @ $18.95/month"));
         secondPane.add(sIconL2);
         secondPane.add(service2 = new JCheckBox("Wireless Network @ $150.00"));
    secondPane.add(sIconL3);
         secondPane.add(service3 = new JCheckBox("Web_Hosting @ $50.00/month"));
         //make third pane
         thirdPane.setLayout(new FlowLayout(FlowLayout.LEFT, 20, 20));
         //thirdPane.setLayout(new BorderLayout(5,10));
         thirdPane.add(welcomeLabel);
         thirdPane.add(addressTf);
         thirdPane.add(cityTf);
         thirdPane.add(stateTf);
         thirdPane.add(zipTf);
         thirdPane.add(emailTf);
         thirdPane.add(phoneNoTf);
         thirdPane.add(ccNo);
         thirdPane.add(expDate);
         thirdPane.add(Discovertype);
         thirdPane.add(Visatype);
         thirdPane.add(MCtype);
         thirdPane.add(AEtype);
    }

    A button is actually getting created, just not the way you would assume. The documentation isn't very clear on this matter. A JRadioButton (and JCheckBox too) actually consist of two (optional) parts: an icon and text. The icon is the little cirle that is either selected or unselected, depending on the state of the button and the text is whatever text you wish to accompany the button describing its purpose. So, when you specify an Icon, you are actually replacing the default unselected icon (the little unselected circle). If you do this, you also need to call setSelectedIcon() and specify an icon to replace the default selected icon (the little selected circle). This is a bit silly, but that's the API.
    To accomplish what you want, I'd suggest placing a JRadioButton and a JLabel (containing the Icon) next to one another.
    HTHs,
    Jamie

  • Help with getting Events into a Project please

    I apologize if this topics been covered here or somewhere else on the Apple website(s), but I cannot get my Events into a Project in iMovie. I've read the directions, watched the videos, and looked at these pages but can't seem to find an answer. At this point, all I want to do is download video from my camcorder to save it and edit later (when I have more time). I managed to download video from several events from the flash drive on my Canon Vixia HF11 and it appears in the Events library. I can play it and select clips without difficulty. I tried to select all the Events (all together and separately) to move to a project (after opening a new project), but the cursor bounces back. It will allow me to select clips but this is very cumbersome and time consuming and I don't want to edit now - I want to save all the video. The "add to project" button doesn't work. Am I missing something? There must be some way to select ALL the video in all the Events I've downloaded to put into one project. BTW, we're only talking about 40 minutes of video. If possible, please post screen shots so that I can see exactly what to do. Any help is much appreciated.

    DocRock54 wrote:
    .. to select ALL the video in all the Events I've downloaded to put into one project. ..
    no, not avail.
    and 'off'-concept of that tiny edit-app:
    when you import, you create a Library of all footage.
    iM will split these videos (by date) into seperate 'Folders' = Events.
    the idea of iM is, to offer you this Library to create a SELECTION of it for any given Project. there are very rare cases I can imagine, you add ALL material of one Event into one Project (in the Event Window hit apple-a), even a Lecture allows to edit here&there.
    but adding all material from any imports into one Project? no. no need = no feature.

  • First Mac-need help with an "event"

    Hi:
       After 3 days of busy activity with no freeze ups, I was feeling pretty confident.  However, late last night I ran into an "event" that eventually required me to reload Tiger.
       (1) I was working along and for some reason, clicking my mouse did not have any effect on any of the programs--either those running or attempting to start new ones.  
       (2) I was able to tab through those programs running and with a command-Q quit out of those running...still no effect on any mouse clicks....no problem moving the mouse and it would highlight top left corner buttons, but no effect if I attempted to minimize or exit.
       (3) I shut the computer off and restarted a number of times....came up to the same screen each time.    Held the off button both in shutting down and starting up and this time it would go to the log on screen where I was able to type in my password.  Would come up to the same screen as I left it.
       (4) Was able to use the remote control just fine to look at pictures, etc.
       (5) After some reading, did a PRAM reset....same story as above.
       (6) Finally reloaded a new copy of Tiger and was back in business.
    Questions:
      (1) Is this the typical freeze people are getting....with PCs, when it freezes, nothing moves and when you reboot, you have a fresh start?
      (2) Short of reloading Tiger, if this happens again, what remedy (other than sending my new iMac back!) would you suggest?
    Thanks for your help!

    Many thanks for the suggestion and the giving me some hope that this is not the dreaded freeze issue!
    I forgot to mention perhaps one important bit of information: There were two Finder "windows" that were present when my "event" occurred and each time I rebooted, these same two Finder windows reappeared and my mouse was unable to move them or close them or execute any command line operations.
    Not sure if this changes the story about it being a mouse software related error or not, but I found it strange that on hard reboots the machine came back with the same two windows of information.

  • Help using app_standard.event(when-tab-page-changed')

    Hello ,
    I need to create a form with the following requirements . There is one content canvas which contains a tabbed canvas and on this there are two stacked canvases .
    The problem is that when I compile my form and ftp to oebs , I cannot view the tab pages on the canvas .
    I see only my the fields displayed in the first tab page without the 'tab pages'.
    How do I solve this issue please ?
    My when-page-page-trigger contains the following :
    BEGIN
         APP_STANDARD.EVENT('WHEN-TAB-PAGE-CHANGED');
    if name_in('system.cursor_block') = 'XX_ERROR_MANAGEMENT' then
    if not form_success then
    -- Revert tab to prior value and exit
    set_canvas_property('CAN_INT',topmost_tab_page,name_in('system.tab_previous_page'));
    return;
    end if;
    -- Move to first item on each tab
    if target_canvas_name = 'CAN_INT' then
         SHOW_VIEW('CAN_ONG1');
    go_item('XX_ERROR_MANAGEMENT.INTERFACE_TYPE');
    else
    show_view(target_canvas_name);
    end if;
    END IF;
    END;
    Any help will be much appreciated . Thanks .

    bump

  • Need help with Buttons/Events

    HI
    Here is what I am doing. I am creating an "operations"
    calendar for my workplace. So far I have been successful with
    creating the page, inserting links, tags, images etc.....
    But now I want to add an Event button - where once the button
    is clicked - it will launch a script on my UNIX server.
    Cant quite figure this one out
    Any help would be greatly appreciated

    Hey man, I 've done some correction, and it seems work, why don't you try the code to see if it is what you want.
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    public class ComplexMenu11 extends Applet implements ActionListener {
    Button open, close;
    MenuFrame f;
    public void init() {
    open = new Button("Open");
    add(open);
    open.addActionListener(this);
    close = new Button("Close");
    add(close);
    close.addActionListener(this);
    f = new MenuFrame("A Complex menu");
    f.setSize(200, 200);
    f.show();
    public void actionPerformed(ActionEvent evt) {
    if(evt.getSource() == open) {
    if(f.isShowing())
    f.show();
    }else{
    if(!f.isShowing())
    f.hide();
    class MenuFrame extends Frame implements ActionListener{  //and implements here too
    Font font;
    Label l;
    int fontsize;
    //MessageDialog md;
    MenuBar mb = new MenuBar();
    Menu m1 = new Menu("Colours");
    MenuFrame(String name) {
    super(name);
    m1.add(new MenuItem("White"));
    m1.add(new MenuItem("Light grey"));
    m1.add(new MenuItem("Yellow"));
    Menu m2 = new Menu("Font");
    m2.add(new MenuItem("10"));
    m2.add(new MenuItem("12"));
    m2.add(new MenuItem("14"));
    m2.add(new MenuItem("16"));
    m2.add(new MenuItem("18"));
    m2.add(new MenuItem("Message"));
    mb.add(m1);
    mb.add(m2);
    setMenuBar(mb);
    m1.addActionListener(this); //Add listener here
    l = new Label("A frame demonstration", Label.CENTER);
    add("South", l);
    //md = new MessageDialog(this,"Name",true);
    public void actionPerformed(ActionEvent evt) {
    if(evt.getSource() instanceof MenuItem) {
    //fontsize = 18;
    String label = evt.getActionCommand();
    if(label.equals("White")) {
    //setBackground(Color.white);
    System.out.println("This is the white point");
    }

  • Help on workflow event container creation.

    Can any one tell me how to create event containers in workflow? If the steps will be given in details it will be very help.Pls

    Hi,
    Events are part of business objects, events are linked to workflows, in the linkage you can link the standard container elements, like initiator to workflow containers and you can link the attributes of the (then) instantiated business object to containers in the workflow.
    You can create additional attributes on business objects in SWO1 (make sure you don't change the sap standard, rather create a subtype and uses delegation (also doable in SWO1) to "override" the sap standard.
    You can create additional containers in pftc, type is WS and task is your workflow number after pressing change you can tick the tab container to create additional containers and in the tab starting events you can change the event-->wf linkage.
    Kind regards, Rob Dielemans

  • Need help with custom event from Main class to an unrelated class.

    Hey guys,
    I'm new to Flash and not great with OOP.  I've made it pretty far with google and lurking, but I've been pulling my hair out on this problem for a day and everything I try throws an error or simply doesn't hit the listener.
    I'm trying to get my Main class to send a custom event to an unrelated class called BigIcon.  The rest of the code works fine, it's just the addEventListener and dispatchEvent that isn't working.
    I've put in the relevant code in below.  Let me know if anything else is needed to troubleshoot.  Thank you!
    Main.as
    package
        import flash.display.MovieClip;
        import flash.events.MouseEvent;
        public class Main extends MovieClip
            var iconLayer_mc:MovieClip = new MovieClip();
            public function Main()
                Spin_btn.addEventListener(MouseEvent.CLICK,fl_MouseClickHandler);
                addChildAt(iconLayer_mc,0);
                placeIcons();
            function placeIcons():void
                var i:int;
                var j:int;
                for (i = 0; i < 4; i++)
                    for (j = 0; j < 5; j++)
                        //iconString_array has the names of illustrator objects that have been converted to MovieClips and are in the library.
                        var placedIcon_mc:BigIcon = new BigIcon(iconString_array[i][j],i,j);
                        iconLayer_mc.addChild(placedIcon_mc);
            function fl_MouseClickHandler(event:MouseEvent):void
                dispatchEvent(new Event("twitchupEvent",true));
    BigIcon.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.utils.getDefinitionByName;
        public class BigIcon extends MovieClip
            private var iconImage_str:String;
            private var iconRow_int:int;
            private var iconColumn_int:int;
            public function BigIcon(iconImage_arg:String, iconRow_arg:int, iconColumn_arg:int)
                iconImage_str = iconImage_arg;
                iconRow_int = iconRow_arg;
                iconColumn_int = iconColumn_arg;
                this.addEventListener(Event.ADDED_TO_STAGE, Setup);
            function Setup(e:Event)
                this.y = iconRow_int;
                this.x = iconColumn_int;
                var ClassReference:Class = getDefinitionByName(iconImage_str) as Class;
                var thisIcon_mc:MovieClip = new ClassReference;
                this.addChild(thisIcon_mc);
                addEventListener("twitchupEvent", twitchUp);
            function twitchUp(e:Event)
                this.y +=  10;

    Ned Murphy wrote:
    You should be getting an error for the Main.as class due to missing a line to import the Event class...
    import flash.events.Event;
    My apologies, I should attempt to compile my example code before I ask for help...
    Alright, this compiles, gives me no errors, shows my 'book' and 'flowers' icons perfectly when ran, and prints 'addEventListener' to the output window as expected.  I get no errors when I press the button, 'dispatchEvent' is output (good), but the 'twitchUp' function is never called and 'EventTriggered' is never output. 
    How do I get the 'twitchUp' event to trigger?
    Main.as
    package
        import flash.display.MovieClip;
        import flash.events.MouseEvent;
        import flash.events.*;
        public class Main extends MovieClip
            var iconLayer_mc:MovieClip = new MovieClip();
            var iconString_array:Array = new Array(2);
            public function Main()
                Spin_btn.addEventListener(MouseEvent.CLICK,fl_MouseClickHandler);
                addChildAt(iconLayer_mc,0);
                buildStringArray();
                placeIcons();
            function buildStringArray():void
                var i:int;
                var j:int;
                for (i = 0; i < 2; i++)
                    iconString_array[i] = new Array(3);
                    for (j = 0; j < 3; j++)
                        if (Math.random() > .5)
                            //'flowers' is the name of an illustrator object that has been converted to a MovieClip and is in the library
                            iconString_array[i][j] = "flowers";
                        else
                            //'book' is the name of an illustrator object that has been converted to a MovieClip and is in the library
                            iconString_array[i][j] = "book";
            function placeIcons():void
                var i:int;
                var j:int;
                for (i = 0; i < 2; i++)
                    for (j = 0; j < 3; j++)
                        //iconString_array has the names of illustrator objects that have been converted to MovieClips and are in the library.
                        var placedIcon_mc:BigIcon = new BigIcon(iconString_array[i][j],i*50,j*50);
                        iconLayer_mc.addChild(placedIcon_mc);
            function fl_MouseClickHandler(event:MouseEvent):void
                dispatchEvent(new Event("twitchupEvent",true));
                trace("dispatchEvent");
    BigIcon.as
    package
        import flash.display.MovieClip;
        import flash.events.*;
        import flash.utils.getDefinitionByName;
        public class BigIcon extends MovieClip
            private var iconImage_str:String;
            private var iconRow_int:int;
            private var iconColumn_int:int;
            public function BigIcon(iconImage_arg:String, iconRow_arg:int, iconColumn_arg:int)
                iconImage_str = iconImage_arg;
                iconRow_int = iconRow_arg;
                iconColumn_int = iconColumn_arg;
                this.addEventListener(Event.ADDED_TO_STAGE, Setup);
            function Setup(e:Event)
                this.y = iconRow_int;
                this.x = iconColumn_int;
                var ClassReference:Class = getDefinitionByName(iconImage_str) as Class;
                var thisIcon_mc:MovieClip = new ClassReference;
                this.addChild(thisIcon_mc);
                addEventListener("twitchupEvent", twitchUp);
                trace("addEventListener");
            function twitchUp(e:Event)
                this.y +=  10;
                trace("EventTriggered");
    Output:
    [SWF] Untitled-1.swf - 40457 bytes after decompression
    addEventListener
    addEventListener
    addEventListener
    addEventListener
    addEventListener
    addEventListener
    dispatchEvent
    [UnloadSWF] Untitled-1.swf
    Test Movie terminated.

  • Help with organizing events in iPhoto

    I'd like to create individual, personalized events in my iPhoto but I cannot figure out how to do this. create.  It seems that the events are currently organized by way of when they were downloaded.  I'd like to essentially pick these disorganized events apart and make my own folders.  It's probably a simple fix but I can not seem to figure it out.   

    Are you wanting to create Albums instead? Events are created by options you have set up in your Preferences. You can rename them, but I'm thinking that what you are describing are Albums. If so then this link should help:
    iPhoto 9.5: Create or change a standard photo album
    Cheers,
    GB

Maybe you are looking for

  • PDF files not displayed on View Output via Citrix

    Running OraFin via Citrix, we are generating custom AR invoices as XML converted to PDFs via XML Publisher then are attemping to view the invoices as PDFs in Adobe Reader. The process works fine for the most part, but some users find that the ability

  • Need help: Unable to handle kernel paging request at virtual address; javac

    Hi we're working with apache tomcat under linux mandrake 10. (x86) when our webapp get recompiled the server stop responding (web server, telnet, etc... are down, but the server is pingable) after a hard reboot , we get this message in var/log/messag

  • Create quotation based on notification

    Hello All, Can any one tell me hwo to create quotation based on notification. I know the BAPI's BAPI_QUOTATION_CREATEFROMDATA2 has to be used to create quotation i get diffrent errors like 1) in sufficient parameters 2) Sales document  was not change

  • While Starting the Managed server using node manager

    The system is vulnerable to security attacks, since it trusts certificates signed by the demo trusted CA.> ####<Nov 24, 2010 11:12:08 AM IST> <Notice> <Security> <HYDHTC99264D> <AdminServer> <[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.De

  • (Sub) formula not found error produced by BEx query

    Hi I have upgraded my BEx Query Designer and Analyzer to the new BI7 version.  Some of my BEx queries created prior to this upgrade do not work anymore in this latest Query Designer.  I received error messages 'The (sub) formula is not available' and