Using checkboxes with JOption Pane

Hi, I having abit of trouble trying to implement a search utility into my swing based program. What I want is something also the lines of the "Find" feature available in MS Word and IE. Hence I want a message, input dialog box but also a checkbox to check does the user what to search for case sensitive material. So far I've been using JOptionPane and my code is as follows...
String userInput = (String) JOptionPane.showInputDialog(null,"Enter Search Criteria:\n",     "Search Dialog",JOptionPane.QUESTION_MESSAGE,null,null,"");
However it seems I cannot use checkboxes with this. Any idea how I could go about doing this using JOptionPane or if not would someone care to shed some light on how I might accomplish it?
Thanks in advance,
Simon

JOptionPanes can be extended, but you would rather want to make a JDialog.
Because you might also offer regular expression search (free in java 1.4),
or search-and-replace.
A google search will give examples like at the koders site.
In general it pays to have all those little dialogs really user-friendly, say saving the last N sought terms + whether case-sensitive or not.
Joop

Similar Messages

  • Is it possible to use Checkboxes with Table Views?

    Hi,
    I need help with adding checkbox. Here is the detail of what I have.
    In my application page, I have the Region Definition:
    Type - SQL Query (PL/SQL Function body Returning SQL Query)
    Region Source -
    DECLARE
    l_sql VARCHAR2(50);
    BEGIN
    Call Function_One(arg1, arg2 ..) ;
    IF ( :P11_REQ = Value1 ) THEN
    l_sql := ' SELECT Col1, Col2, Col3 FROM View1 ' ;
    ELSE
    l_sql := ' SELECT Col1, Col2, Col3 FROM View2 ' ;
    END IF;
    RETURN l_sql;
    END;
    Please note:
    1. ' View1 ' and ' View2 ' are views on two tables.
    2. The checkboxes are needed to select rows from these views to be inserted into another table for further processing.
    Questions:
    1. Can Checkboxes be added to views also, or, to tables only?
    2. If checkboxes can be added to views, How can I do that to each of the rows that will be returned?
    3. Is there a way to use ' Select * FROM View1 ', and be able to add the checkbox to each of the rows ?
    Would appreciate your help.
    Vasan

    Vasan,
    I usually call a plsql function to generate the HTML when I need a custom component like that. ie: create a procedure in a package. this should give you the idea. I usually create a dynamic plsql region to call the below procedure like this
    begin
    printTableWithCheckboxes();
    endl;
    procedure printTableWithCheckboxes is
    begin
    htp.p('<table>');
    for rec in (select id, name from test) loop
    htp.p('<tr>');
    htp.p('<td><input type="checkbox" name="' || rec.name || '" value="' || rec.id || '" /> </td>');
    htp.p('</tr>');
    end loop;
    end printTableWithCheckBoxes;

  • Use checkboxes with drop down and submit button to pas values

    I have a form with six checkboxes, one drop down, and one submit button. I want the check box ON values to be appended to the hyperlinks stored in the drop down. The onclick event of the submit button sends the form results to a url with the checkbox values appended to the end of the hyperlink in the drop down. Need code please. Several programmers have bailed out on this when they got down to the event in the submit button. Can you Sun experts do better??? Here is the code for the form WITHOUT a properly programmed submit button and no javascript.
    <form name="jump">
    <select name="menu">
    <option value="http://www.whateversite.com/CP/View2Ref.php">Option 1 View 2 Test</option>
    <option value="http://www.whateversite.com/CP/AllNew.php?BK=Tap&CH=10&VR=20">option 2</option>
    <option value="http://www.whateversite.com/CP/AllNew.php?BK=Tap&CH=10&VR=20">option 3</option>
    <option value="http://www.whateversite.com/CP/AllNew.php?BK=Tap&CH=10&VR=20">option 4</option>
    </select>
    <input type="button" onClick="window.location.href=document.jump.menu.options[document.jump.menu.selectedIndex].value;
    " value="GO">
        <input type="checkbox" id="chkbx_TR_id1" name="TR" value="ON" alt="TRCheckbox" title="Search 1" tabindex="4">TR
        <input type="checkbox" id="chkbx_ES_id2" name="ES" value="ON" alt="ESCheckbox" title="Search 2" tabindex="4">ES
        <input type="checkbox" id="chkbx_NV_id3" name="NV" value="ON" alt="NVCheckbox" title="Search 3" tabindex="4">NV
        <input type="checkbox" id="chkbx_BT_id4" name="BT" value="ON" alt="BTCheckbox" title="Search 4" tabindex="4">BT
        <input type="checkbox" id="chkbx_SM_id5" name="SM" value="ON" alt="SMCheckbox" title="Search 5" tabindex="4">SM
        <input type="checkbox" id="chkbx_EN_id6" name="EN" value="ON" alt="ENCheckbox" title="Search Bible Encyclopedia" tabindex="4">ENThe resulting URL when the submit button is hit should be like this if all check boxes are checked.
    http://www.whateversite.com/CP/AllNew.php?BK=Tap&CH=10&VR=20&EN=ON&TR=ON&ES=ON&NV=ON&BT=ON&SM=ON&TR=ON"
    Thank you in advance for any replies.

    This forum is concerned with Java and not Javascript (they are not the same) . Though there are forum members who could help you on this you would probably do better to go to a Javascript forum.

  • Issu with multiselection using Checkbox in adf 11.1.1.7

    Hi Experts,
    in my  application i m using table with pagination property and i also add multiselection using boolean check box , i created boolean transient variable in VO  , and multiselection work fine but in one scenario its fail ,
    Scenario is :-
    suppose i check 3 row in table then i click next for pagination then i also check 2 row in table the i go back to first pagination where i have already check 3 values i uncheck 1 value and go next pagination where i check 2 values then i go back to first pagination (now problem is there) here i find 3 check rows  that is problem here i must found 2 check rows .uncheck is not showing in scenario.
             plz help.......................

    Hi
    if your VO  is absed on entity add the transient attribute in EO and use that atribute in VO
    if your VO is not based on EO ,then add one tarnsient attribute in EO use that attribute in VO.
    I had this issue while implemnting checkbox selection adf table.My VO is not based on EO so i have used one Entity in which i have added one transient attribute .

  • I am going to make a ADG with around 7 columns 6 of which I am going to use checkboxes as Item renderer

    I am going to make a ADG with around 7 columns 6 of which I am going to use checkboxes as Item renderers. Each of these 6 checkboxes renderers will be define in separate actionscript files as they will be updating different parts of the ADG data provider. Does this sound like the best option?

    Well the only difference is that each checkbox effects a different attribute of the  dataprovider of the ADG:
    for example this renderer effects the isSelected attribute. I may want to set a different one , hope this explains it better
    package
    import flash.display.DisplayObject;
    import flash.events.KeyboardEvent;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import mx.controls.CheckBox;
    import mx.controls.advancedDataGridClasses.AdvancedDataGridListData;
    import mx.controls.listClasses.ListBase;
    *  The Renderer.
    public class CheckBoxRenderer extends CheckBox
        public function CheckBoxRenderer()
            focusEnabled = false;
         override public function set data(value:Object):void
            super.data = value;
            if(super.data.isSelected == null){
                data.isSelected = false;
            data.isSelected = this.selected;
            invalidateProperties();
        override protected function commitProperties():void
            super.commitProperties();
            if (owner is ListBase)
                selected = ListBase(owner).isItemSelected(data);
        override protected function keyDownHandler(event:KeyboardEvent):void
        override protected function keyUpHandler(event:KeyboardEvent):void
        override protected function clickHandler(event:MouseEvent):void
              super.clickHandler(event);
            if(!data.isSelected){
                data.isSelected = true;
            }else{
                data.isSelected = false;
        override protected function updateDisplayList(w:Number, h:Number):void
            super.updateDisplayList(w, h);
            if (listData is AdvancedDataGridListData)
                var n:int = numChildren;
                for (var i:int = 0; i < n; i++)
                    var c:DisplayObject = getChildAt(i);
                    if (!(c is TextField))
                        c.x = (w - c.width) / 2;
                        c.y = 0;

  • HOWTO: Use BC4J With or Without DB Triggers

    This HowTo describes how to use BC4J, database sequences and triggers
    and what are the ramifications.
    INTRODUCTION
    BC4J has the ability to work with database sequences in order to obtain a
    unique value when inserting records. BC4J also has the ability to
    work either with a 'before insert' trigger which automatically creates
    a new unique value for the primary key or without a trigger. When not using
    a database trigger, BC4J also has the ability to obtain the sequence value
    and set the primary key value.
    Before discussing the ramifications of using one approach or the other, let's
    show examples of how to use both approaches:
    BC4J & sequences WITH a database trigger
    and
    BC4J & sequences WITHOUT a database trigger
    HOWTO DEMONSTRATION STEPS
    To illustrate both scenarios a simple database setup script is provided which
    creates two tables:
    CUSTOMER_NT which DOES NOT have a before insert trigger and
    CUSTOMER_WT which DOES have a trigger.
    Database Install Script:
    <code>
    drop trigger customer_insert_trigger;
    drop table customer_wt;
    drop table customer_nt;
    drop sequence customer_wt_seq;
    drop sequence customer_nt_seq;
    create sequence customer_wt_seq start with 1;
    create sequence customer_nt_seq start with 101;
    create table customer_wt(
    id number,
    name varchar2(30),
    constraint
    customer_wt_pk
    primary key (id)
    create table customer_nt(
    id number,
    name varchar2(30),
    constraint
    customer_nt_pk
    primary key (id)
    prompt Inserting data...
    insert into customer_wt (id, name)
    values (customer_wt_seq.nextval, 'Mickey');
    insert into customer_wt (id, name)
    values (customer_wt_seq.nextval, 'Goofy');
    insert into customer_nt (id, name)
    values (customer_nt_seq.nextval, 'Daffy');
    insert into customer_nt (id, name)
    values (customer_nt_seq.nextval, 'Porky');
    commit
    prompt Creating trigger
    create trigger customer_insert_trigger
    before insert on customer_wt for each row
    begin
    select customer_wt_seq.nextval into :new.id from dual ;
    end;
    </code>
    The next step is to create the DEFAULT Entity Objects and View Objects using
    the Business Components Wizard.
    USING BC4J WITH A DATABASE TRIGGER
    Let's modify the entity object CustomerWt so it can use the database trigger.
    Edit the entity object CustomerWt by right-clicking in the navigator.
    Click on the 'Attribute Settings' tab and edit the ID attribute.
    - Uncheck 'Mandatory'checkbox. This allows you to insert without a value for the primary key
    - Check 'Refresh after Insert'. This obtains the value from the database generated by the trigger.
    - Check 'Updateable While New'. Id is only updateable when inserting.
    Click finish to complete the wizard. Save all and recompile the project.
    Now let's test our work.
    In the navigator right-click the application module and select 'Test..'. This will launch
    BC4J's built in tester. Connect to the application.
    In the tester double-click the CustomerWtView view object to run a test edit form.
    After the edit form renders, navigate through the existing records using the navigate
    buttons on the edit form. Now let's insert a record to execute the trigger.
    click on the '+' button to insert a record. Enter a value in the 'Name' field and commit the change.
    Observe that a new value has automatically been inserted into the Id field.
    That's it! You have successfully used BC4J and a database trigger.
    Now let's try it without a trigger..
    USING BC4J WITHOUT A DATABASE TRIGGER
    Now edit the entity object CustomerNT so it doesn't need a database trigger.
    Similar to before, edit the entity object CustomerNt by right-clicking in the navigator.
    Click on the 'Attribute Settings' tab and edit the ID attribute.
    - Uncheck 'Mandatory'checkbox.
    - Check 'Updateable While New'.
    An additional step is also required. The Create method will have to be modified to extract
    the value of the sequence.
    In the Edit EntityObject Wizard click the Java tab and select Create method and click Finish.
    The create method is generated in your Java fil e. In the Workspace view of the Navigator,
    expand the CustomerNt entity object in the navigator. Double-click
    CustomerNtImpl.java to open it in the Source Editor. In the Structure pane, double-click
    create(AttributeList). Modify the Create method so it looks like this:
    <code>
    public void create(AttributeList attributeList) {
    super.create(attributeList);
    SequenceImpl s = new SequenceImpl("customer_nt_seq", getDBTransaction());
    Integer next = (Integer)s.getData();
    setId(new Number(next.intValue())); }
    </code>
    Save and compile the project.
    Now test the ViewObject CustomerNtView using the tester as before.
    In the edit form of CustomerNTView click on the '+' to insert a record. Observe that
    just as before a new value has automatically been inserted in the ID field!
    TO USE A DB TRIGGER OR NOT TO USE A DB TRIGGER.
    Using a Database trigger sometimes preferable if you have non BC4J applications
    also sharing the database. In this case it is still safest to just let the database
    update it's own primary keys.
    If you don't have any other non-BC4J applications sharing the database, then not using
    a database trigger is perfectly acceptable and can have slightly better performance.
    The important thing to remember is that the option is yours to use either approach!
    null

    Thank you for the reply Jonathon. I am using a ViewObject which
    consist of several tables. I haven't tried the DB trigger
    approach but just using the BC4 approach in overriding the
    create method.
    Here is the parent class create as a part of the
    FasNameImpl.java file which does the job correctly.
    public void create(AttributeList attributeList) {
    super.create(attributeList);
    SequenceImpl l_seq = new SequenceImpl
    ("SEQ_CUSTOMER_ID",getDBTransaction());
    Integer l_next = (Integer)l_seq.getData();
    setCustomerId(new Number(l_next.intValue()));
    This is when I triedpassing the value to the child table. But I
    can't figure it out. I think the link is working fine if I had a
    ViewLink deployed but it doesn't look like it's doing the job
    for ViewObject.
    I am trying to call the childclass.method
    (FasCustomer.setCustomerId(l_next);
    But I am getting error.
    Thanks a lot for your suggestions,
    Kamran
    703 696 1121

  • Checkbox with JTree

    hai,
    i added checkbox to each tree node and my coding is
    import java.awt.BasicStroke;
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.ComponentOrientation;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.GridLayout;
    import java.awt.Insets;
    import java.awt.Point;
    import java.awt.Rectangle;
    import java.awt.RenderingHints;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.FocusEvent;
    import java.awt.event.FocusListener;
    import java.awt.event.InputEvent;
    import java.awt.event.KeyEvent;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseMotionListener;
    import java.util.Arrays;
    import java.util.HashSet;
    import java.util.Iterator;
    import java.util.Set;
    import javax.swing.AbstractAction;
    import javax.swing.AbstractButton;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JCheckBox;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTree;
    import javax.swing.KeyStroke;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    import javax.swing.UnsupportedLookAndFeelException;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeCellRenderer;
    import javax.swing.tree.TreeCellRenderer;
    import javax.swing.tree.TreePath;
    /** Provides checkbox-based selection of tree nodes. Override the protected
    * methods to adapt this renderer's behavior to your local tree table flavor.
    * No change listener notifications are provided.
    public class CheckBoxTreeCellRenderer implements TreeCellRenderer {
    public static final int UNSELECTABLE = 0;
    public static final int FULLSELECTED = 1;
    public static final int NOTSELECTED = 2;
    public static final int PARTIALSELECTED = 3;
    private TreeCellRenderer renderer;
    public static JCheckBox checkBox;
    private Point mouseLocation;
    private int mouseRow = -1;
    private int pressedRow = -1;
    private boolean mouseInCheck;
    private int state = NOTSELECTED;
    private Set checkedPaths;
    private JTree tree;
    private MouseHandler handler;
    /** Create a per-tree instance of the checkbox renderer. */
    public CheckBoxTreeCellRenderer(JTree tree, TreeCellRenderer original) {
    this.tree = tree;
    this.renderer = original;
    checkedPaths = new HashSet();
    checkBox = new JCheckBox();
    checkBox.setOpaque(false);
    System.out.println(checkBox.isSelected());
    checkBox.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
              trace(checkBox);
    // ActionListener actionListener = new ActionListener() {
    // public void actionPerformed(ActionEvent actionEvent) {
    // AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
    // boolean selected = abstractButton.getModel().isSelected();
    // System.out.println(selected);
    // // abstractButton.setText(newLabel);
    // checkBox.addActionListener(new ActionListener(){
    //               public void actionPerformed(ActionEvent actionEvent) {
    //                    Checkbox cb = actionEvent.getSource();
    //     boolean selected = abstractButton.getModel().isSelected();
    //     System.out.println(selected);
    checkBox.setSize(checkBox.getPreferredSize());
    private static void trace(JCheckBox cb) {
         if (cb.isSelected())
              System.out.println(cb.getText()+" is " + cb.isSelected());
         else
              System.out.println(cb.getText()+" is " + cb.isSelected());
    protected void installMouseHandler() {
    if (handler == null) {
    handler = new MouseHandler();
    addMouseHandler(handler);
    protected void addMouseHandler(MouseHandler handler) {
    tree.addMouseListener(handler);
    tree.addMouseMotionListener(handler);
    private void updateMouseLocation(Point newLoc) {
    if (mouseRow != -1) {
    repaint(mouseRow);
    mouseLocation = newLoc;
    if (mouseLocation != null) {
    mouseRow = getRow(newLoc);
    repaint(mouseRow);
    else {
    mouseRow = -1;
    if (mouseRow != -1 && mouseLocation != null) {
    Point mouseLoc = new Point(mouseLocation);
    Rectangle r = getRowBounds(mouseRow);
    if (r != null)
    mouseLoc.x -= r.x;
    mouseInCheck = isInCheckBox(mouseLoc);
    else {
    mouseInCheck = false;
    protected int getRow(Point p) {
    return tree.getRowForLocation(p.x, p.y);
    protected Rectangle getRowBounds(int row) {
    return tree.getRowBounds(row);
    protected TreePath getPathForRow(int row) {
    return tree.getPathForRow(row);
    protected int getRowForPath(TreePath path) {
    return tree.getRowForPath(path);
    public void repaint(Rectangle r) {
    tree.repaint(r);
    public void repaint() {
    tree.repaint();
    private void repaint(int row) {
    Rectangle r = getRowBounds(row);
    if (r != null)
    repaint(r);
    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    installMouseHandler();
    TreePath path = getPathForRow(row);
    state = UNSELECTABLE;
    if (path != null) {
    if (isChecked(path)) {
    state = FULLSELECTED;
    else if (isPartiallyChecked(path)) {
    state = PARTIALSELECTED;
    else if (isSelectable(path)) {
    state = NOTSELECTED;
    checkBox.setSelected(state == FULLSELECTED);
    checkBox.getModel().setArmed(mouseRow == row && pressedRow == row && mouseInCheck);
    checkBox.getModel().setPressed(pressedRow == row && mouseInCheck);
    checkBox.getModel().setRollover(mouseRow == row && mouseInCheck);
    Component c = renderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
    checkBox.setForeground(c.getForeground());
    if (c instanceof JLabel) {
    JLabel label = (JLabel)c;
    // Augment the icon to include the checkbox
    Icon customOpenIcon = new ImageIcon("browse.gif");
    label.setIcon(new CompoundIcon(label.getIcon()));
    return c;
    private boolean isInCheckBox(Point where) {
    Insets insets = tree.getInsets();
    int right = checkBox.getWidth();
    int left = 0;
    if (insets != null) {
    left += insets.left;
    right += insets.left;
    return where.x >= left && where.x < right;
    public boolean isExplicitlyChecked(TreePath path) {
    return checkedPaths.contains(path);
    /** Returns whether selecting the given path is allowed. The default
    * returns true. You should return false if the given path represents
    * a placeholder for a node that has not yet loaded, or anything else
    * that doesn't represent a normal, operable object in the tree.
    public boolean isSelectable(TreePath path) {
    return true;
    /** Returns whether the given path is currently checked. */
    public boolean isChecked(TreePath path) {
    if (isExplicitlyChecked(path)) {
    return true;
    else {
    if (path.getParentPath() != null) {
    return isChecked(path.getParentPath());
    else {
    return false;
    public boolean isPartiallyChecked(TreePath path) {
    Object node = path.getLastPathComponent();
    for (int i = 0; i < tree.getModel().getChildCount(node); i++) {
    Object child = tree.getModel().getChild(node, i);
    TreePath childPath = path.pathByAddingChild(child);
    if (isChecked(childPath) || isPartiallyChecked(childPath)) {
    return true;
    return false;
    private boolean isFullyChecked(TreePath parent) {
    Object node = parent.getLastPathComponent();
    for (int i = 0; i < tree.getModel().getChildCount(node); i++) {
    Object child = tree.getModel().getChild(node, i);
    TreePath childPath = parent.pathByAddingChild(child);
    if (!isExplicitlyChecked(childPath)) {
    return false;
    return true;
    public void toggleChecked(int row) {
    TreePath path = getPathForRow(row);
    boolean isChecked = isChecked(path);
    removeDescendants(path);
    if (!isChecked) {
    checkedPaths.add(path);
    setParent(path);
    repaint();
    private void setParent(TreePath path) {
    TreePath parent = path.getParentPath();
    if (parent != null) {
    if (isFullyChecked(parent)) {
    removeChildren(parent);
    checkedPaths.add(parent);
    } else {
    if (isChecked(parent)) {
    checkedPaths.remove(parent);
    addChildren(parent);
    checkedPaths.remove(path);
    setParent(parent);
    private void addChildren(TreePath parent) {
    Object node = parent.getLastPathComponent();
    for (int i = 0; i < tree.getModel().getChildCount(node); i++) {
    Object child = tree.getModel().getChild(node, i);
    TreePath path = parent.pathByAddingChild(child);
    checkedPaths.add(path);
    private void removeChildren(TreePath parent) {
    for (Iterator i = checkedPaths.iterator(); i.hasNext();) {
    TreePath p = (TreePath) i.next();
    if (p.getParentPath() != null && parent.equals(p.getParentPath())) {
    i.remove();
    private void removeDescendants(TreePath ancestor) {
    for (Iterator i = checkedPaths.iterator(); i.hasNext();) {
    TreePath path = (TreePath) i.next();
    if (ancestor.isDescendant(path)) {
    i.remove();
    /** Returns all checked rows. */
    public int[] getCheckedRows() {
    TreePath[] paths = getCheckedPaths();
    int[] rows = new int[checkedPaths.size()];
    for (int i = 0; i < checkedPaths.size(); i++) {
    rows[i] = getRowForPath(paths);
    Arrays.sort(rows);
    return rows;
    /** Returns all checked paths. */
    public TreePath[] getCheckedPaths() {
    return (TreePath[]) checkedPaths.toArray(new TreePath[checkedPaths.size()]);
    protected class MouseHandler extends MouseAdapter implements MouseMotionListener {
    public void mouseEntered(MouseEvent e) {
    updateMouseLocation(e.getPoint());
    public void mouseExited(MouseEvent e) {
    updateMouseLocation(null);
    public void mouseMoved(MouseEvent e) {
    updateMouseLocation(e.getPoint());
    public void mouseDragged(MouseEvent e) {
    updateMouseLocation(e.getPoint());
    public void mousePressed(MouseEvent e) {
    pressedRow = e.getModifiersEx() == InputEvent.BUTTON1_DOWN_MASK
    ? getRow(e.getPoint()) : -1;
    updateMouseLocation(e.getPoint());
    public void mouseReleased(MouseEvent e) {
    if (pressedRow != -1) {
    int row = getRow(e.getPoint());
    if (row == pressedRow) {
    Point p = e.getPoint();
    Rectangle r = getRowBounds(row);
    p.x -= r.x;
    if (isInCheckBox(p)) {
    toggleChecked(row);
    pressedRow = -1;
    updateMouseLocation(e.getPoint());
    public void mouseClicked(MouseEvent e){
         if(checkBox.isSelected()){
              System.out.println(checkBox.getName());
    /** Combine a JCheckBox's checkbox with another icon. */
    private final class CompoundIcon implements Icon {
    private final Icon icon;
    private final int w;
    private final int h;
    private CompoundIcon(Icon icon) {
    if (icon == null) {
    icon = new Icon() {
    public int getIconHeight() { return 0; }
    public int getIconWidth() { return 0; }
    public void paintIcon(Component c, Graphics g, int x, int y) { }
    this.icon = icon;
    this.w = icon.getIconWidth();
    this.h = icon.getIconHeight();
    public int getIconWidth() {
    return checkBox.getPreferredSize().width + w;
    public int getIconHeight() {
    return Math.max(checkBox.getPreferredSize().height, h);
    public void paintIcon(Component c, Graphics g, int x, int y) {
    if (c.getComponentOrientation().isLeftToRight()) {
    int xoffset = checkBox.getPreferredSize().width;
    int yoffset = (getIconHeight()-icon.getIconHeight())/2;
    icon.paintIcon(c, g, x + xoffset, y + yoffset);
    if (state != UNSELECTABLE) {
    paintCheckBox(g, x, y);
    else {
    int yoffset = (getIconHeight()-icon.getIconHeight())/2;
    icon.paintIcon(c, g, x, y + yoffset);
    if (state != UNSELECTABLE) {
    paintCheckBox(g, x + icon.getIconWidth(), y);
    private void paintCheckBox(Graphics g, int x, int y) {
    int yoffset;
    boolean db = checkBox.isDoubleBuffered();
    checkBox.setDoubleBuffered(false);
    try {
    yoffset = (getIconHeight()-checkBox.getPreferredSize().height)/2;
    g = g.create(x, y+yoffset, getIconWidth(), getIconHeight());
    checkBox.paint(g);
    if (state == PARTIALSELECTED) {
    final int WIDTH = 2;
    g.setColor(UIManager.getColor("CheckBox.foreground"));
    Graphics2D g2d = (Graphics2D)g;
    g2d.setStroke(new BasicStroke(WIDTH, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    int w = checkBox.getWidth();
    int h = checkBox.getHeight();
    g.drawLine(w/4+2, h/2-WIDTH/2+1, w/4+w/2-3, h/2-WIDTH/2+1);
    g.dispose();
    finally {
    checkBox.setDoubleBuffered(db);
    private static String createText(TreePath[] paths) {
    if (paths.length == 0) {
    return "Nothing checked";
    String checked = "Checked:\n";
    for (int i=0;i < paths.length;i++) {
    checked += paths[i] + "\n";
    return checked;
    public static void main(String[] args) {
    try {
    final String SWITCH = "toggle-componentOrientation";
    try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              } catch (ClassNotFoundException e1) {
                   e1.printStackTrace();
              } catch (InstantiationException e1) {
                   e1.printStackTrace();
              } catch (IllegalAccessException e1) {
                   e1.printStackTrace();
              } catch (UnsupportedLookAndFeelException e1) {
                   e1.printStackTrace();
    JFrame frame = new JFrame("Tree with Check Boxes");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final DefaultMutableTreeNode a = new DefaultMutableTreeNode("Node 1");
    for(int i =0 ; i<3; i++ ){
         DefaultMutableTreeNode b = new DefaultMutableTreeNode("ChildNode "+i);
         a.add(b);
    DefaultMutableTreeNode e = new DefaultMutableTreeNode("Node 2");
    for(int i =0 ; i<3; i++ ){
         DefaultMutableTreeNode f = new DefaultMutableTreeNode("ChildNode "+i);
         e.add(f);
    DefaultMutableTreeNode al = new DefaultMutableTreeNode("Sample");
    al.add(a);
    al.add(e);
    final JTree tree = new JTree(al);
    final CheckBoxTreeCellRenderer r =
    new CheckBoxTreeCellRenderer(tree, tree.getCellRenderer());
    tree.setCellRenderer(r);
    int rc = tree.getRowCount();
    tree.getActionMap().put(SWITCH, new AbstractAction(SWITCH) {
    public void actionPerformed(ActionEvent e) {
    ComponentOrientation o = tree.getComponentOrientation();
    if (o.isLeftToRight()) {
    o = ComponentOrientation.RIGHT_TO_LEFT;
    else {
    o = ComponentOrientation.LEFT_TO_RIGHT;
    tree.setComponentOrientation(o);
    tree.repaint();
    int mask = InputEvent.SHIFT_MASK|Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    tree.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_O, mask), SWITCH);
    final JTextArea text = new JTextArea(createText(r.getCheckedPaths()));
    text.setPreferredSize(new Dimension(200, 100));
    tree.addMouseListener(new MouseAdapter() {
    public void mouseReleased(MouseEvent e) {
    // Invoke later to ensure all mouse handling is completed
    SwingUtilities.invokeLater(new Runnable() { public void run() {
    text.setText(createText(r.getCheckedPaths()));
    JScrollPane pane = new JScrollPane(tree);
    frame.getContentPane().add(pane);
    // frame.getContentPane().add(new JScrollPane(text), BorderLayout.SOUTH);
    frame.pack();
    frame.setSize(600,400);
    frame.setVisible(true);
    catch(Exception e) {
    e.printStackTrace();
    System.exit(1);
    now i need to get nodes names which has been selected, how can i do this
    can anyone help me ...
    regards,
    shobi

    Also, use code tags and post a SSCCE -- I'm sure more of your posted code is irrelevant to your question and few people are going to look at a code listing that long.
    [http://mindprod.com/jgloss/sscce.html]

  • HT201210 I'm trying to update my iOS to 6.0, using iTunes (with my 4s connected via USB and WiFi is on also). I get a message that 'there are purchased items on my iPhone that have not been transferred to my iTunes library. Yet, I can't find those items!

    I'm trying to update my iOS to 6.0, using iTunes (with my 4s connected via USB and WiFi is on also). I get a message that 'there are purchased items on my iPhone that have not been transferred to my iTunes library. Yet, I can't find those items! Help!  There is not error message number just the text message. I've searched for an answer but have found nothing on "transfering items purchased to your iTunes library".

    Right click on your device icon on the left pane of iTunes and click on transfer pur....

  • How to modify a lookup field-type to use checkbox instead of radiobutton?

    How to modify a lookup field-type to use checkbox instead of radiobutton?
    I would like to modify the behavior for the lookup field.
    Normally you get a screen where it is possible to search through a lookup. The items resulted from the search are listed as radiobutton items. Therefore you can select only one at the time to be added.
    Is it possible to have the items to be listed as checkbox instead? So that you can check multiple items and therefore be able to add multiple items at the time?
    For example:
    To add the user to 10 different groups on MS-AD.
    It is desired to have the ability to check multiple groups to be added instead only one at the time.
    My client would like to use this feature in many other situations.

    Displaying will not be a big deal but with that you have to customize the action class and its working as well.

  • "Enable Disk Use" checkbox is grayed out, can't untick.

    Hi,
    I just got my new iPod 30 GB video today! I've been reading these discussions, but haven't found an answer for this tiny problem of mine.
    "Do Not Disconnect" constantly shows on the iPod screen when it's connected on the computer. Many have suggested ticking off "Enable Disk Use", but here's the problem: it's grayed out, and I can't change it, no matter what. I've gone through iTunes prefs, by right-clicking on the iPod in iTunes and selecting "iPod Options". My system seems to show iPod as a movable disk, but iTunes recognises it and I can easily put music into it, so I guess that isn't a problem (or is it?).
    But how could I get my hands on the "Enable Disk Use" checkbox? It just isn't "tickable" now.
    Thanks!
      Windows XP  

    If you have your iPod set to manual update, the "Enable Disk Use" box will be greyed out and ticked by default, in that case use Safely remove Hardware icon or check this link: "Disconnecting iPod from your computer
    " http://docs.info.apple.com/article.html?artnum=61135
    For Info:
    The iPod offers three ways to transfer music from your computer. You can select one of the following update modes from the iPod Preferences menu in iTunes (Edit=>Preferences=>'iPod' tab):
    1) Automatically update all songs and playlists. This is the default mode, in which your entire music library, including playlists, is automatically synced to your iPod. If the music library on your computer exceeds the iPod storage capacity, you are prompted to select a different update method.
    2) Automatically update selected playlists only. With this option, iTunes automatically copies the playlists you have selected to the iPod when you connect it to the computer.
    3) Manually manage songs and playlists. You can also choose to transfer music to the iPod manually. This allows you to drag and drop individual songs and playlists from iTunes to the iPod.

  • I have a Mac Pro using Lion, with a SSD for system.  Restored drive from backup.  Now logon password doesn't work.  Account password still works.  Changing password in user group preferences no longer works to change logon password.

    I have a Mac Pro using Lion, with SSD for system drive.  Drive stopped booting, but otherwise appeared healthy.  Restored from system backup.  Now drive seems to work properly, BUT my logon password no longer works.  Password OK for account; can access system preferences, and change user password there BUT logon still refuses to accept password.  No luck changing password for that account after adding new administrator account and logging on from that account.  Suggestions?  Thanks.

    If you redirect Accounts to another location (not on the Boot Drive) you need to direct them back there again after a restore.
    SystemPreferences > Accounts/User&Groups > ...
    ... Unlock the lock, then hold down Control as you click on an Account to get access to the Advanced Options pane.

  • Reader 9.3.2 crashes when using search & closing bookmarks pane

    I have some PDFs that were created with the Bookmarks pane left open -- i.e. the Bookmarks pane is open every time I open the file. That means the actual page display is too small to read.  I can close the Bookmarks pane and all is OK.
    However, I use the search-index feature a lot -- I have a .idx file indexing a bunch of PDFs, and I search through the PDFs with that index.
    If I search for something, then select a search link, the file opens with Bookmarks pane open.  If I close the Bookmarks pane after having searched for something, *kaboom*.  Reader crashes.
    BTW it also crashes if I resize the window -- so I can't even increase the page size without closing the Bookmarks pane.
    I'm going to see if a co-worker can use her copy of Acrobat Pro to edit the files, close the Bookmarks pane, and re-save the files.  But in the meantime this is a very annoying bug.
    Running on Vista Home Premium SP2 32bit.

    Open Reader, go to Edit-->Preferences-->Documents and select "Restore last view settings when reopening documents".
    So now when you reopen a pdf file whose bookmarks bar you have closed earlier after checking this option, you will see that the bookmark bar will be closed.

  • Using checkboxes as datasource of TileList - how do I then receive selected checkboxes?

    I've been googling and searching for this and it should be simple I'd imagine... (I'm new to Flex so that probably doesn't help:)...
    I have an array that I create using CheckBox components. I then use this array as the dataprovider for a TileList and then also create a CheckBox itemrenderer.
    The issue I'm having is that, I thought if I went over the underlying checkbox array at a later point (say a button click) - that I'd be able to see some selected items yet none of them show up selected as I iterate over them (even though I've checked some of the checkboxes.)
    I have an event on the checkbox rendererer itself and when it fires I do see the selected property set - It's just going over the whole array that I'm not seeing them set. It's as if the underlying dataset is not being modified. What do I need to do so that I can capture the selected checkbox items?  (Is the issue something to do with the renderer being reused?)  I'm thinking getting a handle to checkbox items from from a TileList would be somewhat common so any help/examples appreciated.
    Below is the pertinent code:
    [CODE]
    dataArray is an array of type [B]CheckBox[/B]
    <mx:TileList id="reportMetricsBox"
            borderStyle="solid" height="100%" width="100%" maxColumns="3"
            columnWidth="110" paddingLeft="0" textAlign="left" borderThickness="0"
            dataProvider="{dataArray}">
       <mx:itemRenderer>
           <mx:Component>
               <mx:CheckBox click="handleClick(event)">
                   <mx:Script>
                       <![CDATA[
                           import com.foo.event.CheckBoxEvent;
                           private function handleClick(event:Event):void {
                               dispatchEvent(new CheckBoxEvent(CheckBoxEvent.CLICKED, CheckBox(this)));
                       ]]>
                   </mx:Script>
               </mx:CheckBox>
           </mx:Component>
       </mx:itemRenderer>
    </mx:TileList>
    [/CODE]

    Here's what I did to fix it...
    in my item renderer click handler I set the data selected item:
    private function onChange(event:Event):void {
         dispatchEvent(new CheckBoxEvent(CheckBoxEvent.CLICKED, CheckBox(this)));
        data.selected = !data.selected;
    I'm assuming that's what I should be doing?

  • I want to Use iChat with Skype to Videoconference several people

    I want to video conference in my niece in New Zealand (PC using Skype) with iChat and the rest of my Mac family stateside.
    I have Skype for Mac running and I have the iChat AV running. Any chance to hook in the Skype User with the iChat multi-pane video conference?
    It looks like iChat only accepts iChat and AIM but not Skype. My niece apparently cannot get AIM in New Zealand.
    Any clever help would be appreciated.

    I want to use iChat for Skype as well. I want one chat client for all my communications. That was the point of iChat in the beginning, wasn't it? Hopefully, Apple will jump on the ball and support the best way for us common folk to communicate internationally. The supported Aim when they were king, why not the new king?
    I stinks that I can not use the great app, because one no Skype but two I don't know anyone else that uses .mac.

  • Removing of standard java image in JOption Pane

    anyone can help to remove image(standard java image in JOption Pane).
    Looking forward for early response :)
    i tried to use (setIcon) method but i ecountered this error:
    Exception occurred during event dispatching:
    java.lang.NullPointerException
    at Sample.errorMsg(Sample.java:209)
    at Sample.check(Sample.java:177)
    at Sample.actionPerformed(Sample.java:124)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

    just use JOptionPane.PLAIN_MESSAGE as a message type.

Maybe you are looking for

  • Why did I get an Emergency Alert for the Nemo Blizzard at 4 am?

    This @^%^!*#*!&!@ system just sent a blaring alert to my iPhone at 4 am EST warning me about a blizzard I already knew about, literally scaring me out of bed. Now, after some middle-of-the-night research, I understand it's the FEMA IPAWS system (http

  • Do you recommend the Yoga 13 to your friends and coworkers?

    I teaching training courses at about 20+ tech companies each year. This week was my first time using my new Yoga 13 as my presentation machine. After class, 2 out of 13 students approached me and asked about the Yoga. They were in the market for a Wi

  • Background image in BSC-Launchpad

    Hello Freaks, we are using SEM-BSC 6.0 and no our user want to bring a picture in the background of the definition from the Scorecard. Is there a possibility to bring a background picture in teh definition? thanks a lot Sigi

  • IPad backup with Time Capsule

    Anyone heard if the iPad will be able to wirelessly backup?

  • What is the best way to transfer from one computer to another?

    In the next couple weeks, I'm going to be buying a MacBook Pro. I want to transfer my whole library (with all rolls, albums, slideshows, etc) intact. What is the best way to do this? I assume it's as easy as copying the whole iPhoto Library Folder, c