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]

Similar Messages

  • Problem with JTree converting Node to string

    I have a problem that I cannot slove with JTree. I have a DefaultMutalbeTreeNode and I need its parent and convert to string. I can get its parent OK but cannot convert it to string.
    thisnode.getParent().toString() won't work and gives an exception
    thisnode.getParent() works but how do I convert this to string to be used by a database.
    Thanks
    Peter Loo

    You are using the wrong method to convert it to a String array.
    Try replacing this line:
    String[] tabStr = (String[])strList.toArray();
    With this line:
    String[] tabStr = (String[])strList.toArray( new String[ 0 ] );
    That should work for you.

  • How can I open a picture with Jtree

    hi,
    I want to write a Filemanagerprogramm with JTree, but how can I open it, after I clickt the .jpg or .png file. Thank you for your Tip!

    The java tutorial at http://java.sun.com/docs/books/tutorial/uiswing/misc/icon.html will tell you a lot of what you need to know.

  • Problems with JTree

    Hi,
         I have a few problems while working with JTree. Here is the detail:
    I get the name of the required file from JFileChooser and add it to the root node of JTree using
    root.add(new DefaultMutableTreeNode(fileName));
    The following happens.
    1) If I add it to root, it is not added(or shown,at least) there.
    2) if I add it to a child of root, then if the node is collapsed before the event, after the event when it is expanded fileName is there.
    3) However if it is expanded before adding the fileName,the fileName is not added (or not shown).
    4) Further if I add another file(whether the node is collapsed or expanded) it is also not shown, means that it works only once during the life-time of the application.
    5) I have used JFrame and call repaint() for both the JFrame and JTree but the problem is still there.
         Please help me in solving this problem.
    Thanks in advance,
    Hamid Mukhtar,
    [email protected]
    H@isoft Technologies.

    Try doing this...
    tree.getModel().reload(node)
    node here is the node to which a new node is added

  • How to checking my checkbox with a listbox

    I have a new form where I would like to check automatically my checkbox with a choice from listbox.
    I have a listbox with three values in french "Utilisateur" - "Comptable" and "Membre direction".
    I would like when the user has selected "Utilisateur", my checkbox with value "OJV_OFFICE_UTILISATEURS" has checked or "Comptable" checkbox with value "OJV_OPF Caissiers"
    Can you help me.
    Thanks

    Look at this previous post:
    https://forums.adobe.com/thread/1506686
    To modify the script to your form, you could try this as the custom validation script for your combo box:
    if (event.value=="Utilisateur") {
    this.getField("OJV_OFFICE_UTILISATEURS").value = "Yes"; 
    this.getField("OJV_OPF Caissiers").value = "No";}
    else if (event.value=="Comptable") {
    this.getField("OJV_OFFICE_UTILISATEURS").value = "No"; 
    this.getField("OJV_OPF Caissiers").value = "Yes";}
    Make sure you have the "Commit selected value immediately" option selected.

  • 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

  • Checkbox with 3 states?

    Hi,
    is there any way in jsf to create checkboxes with more than two states?
    Something like
    -true (e.g. value 2)
    -false (e.g. value 0)
    -something in between (e.g. value 1)
    You need those when you select a group of features and deselect one of the features (e.g. installation of software, see installshield). The checkbox usually is still selected, but with a shady gray background. You can see if the whole group of features is selected, if the whole group is deselected or if some features of the group are selected.
    Is there a way to get those components without having to create them manually? I can't believe nobody else needs those.
    Greetings, jimbo

    Hi Paul,
    It adds the value, how would I (add enter) so the text are seperate lines.
    Example 1:
    The dog is in the dog house. The cat is in a tree. (bad)
    Example 2:
    The dog is in the dog house.
    The cat is in the tree
    Viewing the text as in Example 2 is easier to read.
    Thank You,
    Arnold

  • Checkbox with submit

    Hi,
    Is there checkboxes with submit/redirect in APEX 3.2 / 4.0? I'm using 3.0 and there's no option :(
    Is there an alternative I can do? Maybe something like Form Element Option Attributes - onclick=refresh()/reload() except I need it to recognise in the session that the checkbox is selected (it remains selected with some options but item conditions dont occur and it doesnt recognise the checkbox's value in the session section.
    Mike
    Edited by: Dird on May 7, 2010 2:38 PM

    Hi Mike
    onclick=doSubmit('YOUR_REQUEST_VALUE');In the HTML Form Element Attributes should do it.
    I don't know about 4.0 but it's not in 3.2.1.
    Cheers
    Ben

  • Checkbox with vertical label - FB mobil app

    How can I create in Flash Builder a checkbox with a vertical label. Has someone an example code?
    The label should be under the checkbox (but in center):
    CheckBox
    L
    A
    B
    E
    L
    Great thanks, M.

    I think the whole reason that this post was even necesary was because the original Check box wasn't written properly (see my comments on this page http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_4.html ).  Note that mx checkbox implements IDataRenderer, so you should be able to use it as a renderer with this tweak, as long as the Spark DataGrid allows you to set column alignment as MX data grid (or you don't need it centered).
    In Flex 4, ItemRenderer is really just a Group with a couple of extra bells and whistles.  At the simplest level, you can just bind its selected property to some boolean field on the data object if you know its format in advance.  However, that's not going to give you a reusable check box.  To do that, you need to either write code that can translate the string label field into a Boolean, or something that can combine the DefaultDataGridRenderer's data property with the dataField property on DefaultDataGridRenderer's column object and again come up with a Boolean.
    You can either make this Boolean a Bindable variable or, if you're comfortable with the component life cycle, you can do the getter/setter + commitProperties to set it more directly on a custom Check Box skinPart.
    HTH;
    Amy

  • Do I not get the "open file after publishing" checkbox with the trial version?

    I owned the Adobe Acrobat 8 Professional version on my pc, and recently bought a Mac. Do I not have the option to "Open file after publishing" checkbox with the trial version? Do I have to repurchase the whole program to get that?

    uninstall.
    download from prodesigntools.com.
    if you follow all 7 steps you can directly download a trial here:  New Adobe Lightroom 6 (CC) Direct Download Links – Free Trials | ProDesignTools
    and activate with your serial number.
    if you have a problem starting the download, you didn't follow all 7 steps, or your browser does not accept cookies. 
    the most common problem is caused by failing to meticulously follow steps 1,2 and/or 3 (which adds a cookie to your system enabling you to download the correct version from adobe.com). 
    failure to obtain that cookie results in an error page being displayed after clicking a link on prodesigntools.com or initiates the download of an incorrect (eg, current) version.

  • How to retrive data from selected checkboxes with fieldnames

    hi experts,
    how to retrive data from selected checkboxes with fieldnames into another alv grid report.(here the fieldnames selected from  table names is dynamically).
    thankx in advance
    rani.k.

    Hi,
    Use user_command in the alv grid and then
    do the follwoing code
    FORM user_command1 USING lv_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    Declaration of local Variables
      DATA : lv_ref1 TYPE REF TO cl_gui_alv_grid.
      DATA lv_cnt TYPE i.                                    "+INS SUHESH 12.07.2008
    Check function code
      CASE lv_ucomm.
        WHEN 'ONLI'.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              e_grid = lv_ref1.
          CALL METHOD lv_ref1->check_changed_data.
    now loop ur final internal table where check = 'X'.
    now pass data to other internal table..Now the internal table will be having values that the user selcetd on the screen.
    Hope this helps.
    Regards,
    Nagaraj

  • Binding Checkboxes with Data Fields

    hi again , one question, is it possible to link a user-added checkbox with a data field from a table to show a stored state?, i tried using the valon and valoff properties to set whether it must or not be checked (depending on the values of some field) but it's not working, could someone help me with this please? thanks

    Hi Oscar,
    here is my sample, how to connect user's checkbox with DB value.
    Dim oCheckBox As SAPbouiCOM.CheckBox
    Dim oDBds As SAPbouiCOM.DBDataSource
    Set oCheckBox = frm.Items("ckDispp").Specific
    Set oDBds = frm.DataSources.DBDataSources.Add("@ABC_DISP")
    oCheckBox.DataBind.SetBound True, "@ABC_DISP", "U_Display"
    The ValidValues in DB field "U_Display" are 'Y' when checkbox is checked, and 'N' when unchecked.
    Hope, this helps.
    Regads
    Libor.

  • Create Checkbox with Attributes from XML file

    Hi
    I have some problem. I want to create some checkbox with attribute from a XML file
    my Xml file look like this:
    <group type="Content Relation" color="255, 255, 255" active="true">
    so I want to create for example a check box with name as Content Relation, Background color is RGB(255, 255, 255) and it's checked. All of these Attribute I have readed and save them as String. My question, how can I create a Color object with the color Attribute from the XML file?
    Is it better if I define my XML file like this:
    <group>
    <type>Content Relation</type>
    <color>
    <red>255</red>
    <green>255</green>
    <blue>255</blue>
    </color>
    <active>true</active>
    </group>

    IMO attributes are much easier to parse then textnodes
    altho
    <color red='255' green='255' blue='255'/>
    might be easier

  • Mixing multiple checkboxes with grades

    I'm looking for a way to mix checkboxes with grades that these checkboxes have scored.
    To give an example, say a report has the topics "sustainability" and "durability" and have been scored by clients. I would like to have the option to state that these topics are in the report, as well as how high they scored. This would
    enable my to filter for reports that contained the topics "durability" that scored above e.g. "8". Currently I need to create additional fields for every elements, making my database highly unwieldy.
    How can I go about creating this kind of database?
    Kind Regards,
    Nick
    Ps: it should be noted that I have limited rights for programming/importing parts. So I'm looking for a out-of-the-box solution.

    Hi NLeone,
    I don't think you'll be able to achieve what you're looking for in a single column, unfortunately.
    You could create a choice column for every potential topic:
    Give it a single choice of "N/A"
    Display choices using radio buttons
    Allowing 'Fill-in' choices
    Use column validation to make sure the field value is either "N/A" or a number

  • Display File System With JTree

    Greeting,
    Are there any suggestions or example which is about displaying file system with JTree??
    Thx Advanced

    Just create tree model from your filesystem.
    If you like to have fancier look, you may also
    create renderer which would show
    appropriate icons.
    Look to classes
    DefaultMutableTreeNode
    DefaultTreeModel
    ( all in the javax.swing.tree )

Maybe you are looking for

  • Add on Installation Error.

    Hi, I removed Addons in Add and Remove and in C:\Program Files\SAP\SAP Business One\AddOns. After iam  installing Add on it's showing Error LIke Add on TDS:Add on Installation failed bacuse another versione ia already installed.please ensure that the

  • Difference between google analytics and bc report?

    When I compare GA and BC, BC shows me more than double number of visitors and pageviews than google. For example June: Visitors/Pageviews BC: 1386/4087 GA: 492/1647 Thats so much difference, that I don't know which system I should trust. How can I in

  • Vendor transfer from mm to sus and ebp to sus

    Hi, I have two scenarios. 1. Plan driven procurement 2. mm-sus scenario For plan driven procurement I have transferred the vendor from r/3 to ebp using bbpgetvd  and ebp to sus using xi. Now vendor can login to sus and do the biding. But in case of m

  • Standby db monitoring in OEM

    I have 11g oem grid. The standby db's are displayed as down in the OEM as it in Mount. Is there a way to monitor or configure OEM to manage the standby databases.

  • PSE 6 wants to look for reconnections on the wrong hard drive

    I recently installed a new 500 GB hard drive.  I want that to be my new C [main/boot] drive and managed to accomplish this with some changes to the boot.ini file.  My original C is now named J and is a 120 GB hard drive that I wish to use to backup p