[Advanced-java] Readonly property for JCheckBox and JRadioButton

Steve Roy sroy at mac.com
Tue Apr 15 14:31:15 2003


To follow up on my post about this, here's a simple example:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Test
{
    public static void main(String[] args)
    {
        JFrame f = new JFrame();
        JPanel c = (JPanel)f.getContentPane();
        c.setLayout(new FlowLayout());
        c.add(new MyCheckBox("Hello"));
        f.show();
    }
}

class MyCheckBox extends JCheckBox
{
    public MyCheckBox(String text)
    {
        super(text);
    }
    
    protected void processMouseEvent(MouseEvent e)
    {
        // Just don't do anything
    }
}

Steve

-- 
Steve Roy <sroy@mac.com>
Personal homepage: <http://homepage.mac.com/sroy>
Projects homepage: <http://www.roydesign.net>