Code for complete JTree of mycomputer (dynamic) but need to add checkboxes

//the bug is where i am sending the value to the checkbox.. if somebody can add checkboxes to every node plz reply soon
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.util.EventObject;
import java.util.Vector;
import javax.swing.AbstractCellEditor;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellEditor;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreePath;
public class CheckBoxNodeTreeSample {
public static void main(String args[]) {
JFrame frame = new JFrame("CheckBox Tree");
/* CheckBoxNode accessibilityOptions[] = {
new CheckBoxNode(
"Move system caret with focus/selection changes", false),
new CheckBoxNode("Always expand alt text for images", true) };
CheckBoxNode browsingOptions[] = {
new CheckBoxNode("Notify when downloads complete", true),
new CheckBoxNode("Disable script debugging", true),
new CheckBoxNode("Use AutoComplete", true),
new CheckBoxNode("Browse in a new process", false) };
Vector accessVector = new NamedVector("Accessibility",
accessibilityOptions);
Vector browseVector = new NamedVector("Browsing", browsingOptions);
Object rootNodes[] = { accessVector, browseVector };
Vector rootVector = new NamedVector("Root", rootNodes);
setLayout(new GridLayout(1,1));
//create the top node
MutableTreeNode root = new DefaultMutableTreeNode("Computer");
//get all nodes for top file systems or disks
//On Linux/Unix this will only be '/'
//while on Window there will typically be more: 'A:', 'C:' etc.
File roots[] = File.listRoots();
//loop through all these nodes and add them to the root Computer node
int i = 0;
for(File f : roots) {
DefaultMutableTreeNode node = new DefaultMutableTreeNode(f.getAbsoluteFile().toString());
root.insert(node, i++);
//create a tree model with the Computer node as root
model = new DefaultTreeModel(root);
JTree tree = new JTree(model);
CheckBoxNodeRenderer renderer = new CheckBoxNodeRenderer();
tree.setCellRenderer(renderer);
tree.setCellEditor(new CheckBoxNodeEditor(tree));
tree.setEditable(true);
JScrollPane scrollPane = new JScrollPane(tree);
frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
frame.setSize(300, 150);
frame.setVisible(true);
class CheckBoxNodeRenderer implements TreeCellRenderer {
private JCheckBox leafRenderer = new JCheckBox();
private DefaultTreeCellRenderer nonLeafRenderer = new DefaultTreeCellRenderer();
Color selectionBorderColor, selectionForeground, selectionBackground,
textForeground, textBackground;
protected JCheckBox getLeafRenderer() {
return leafRenderer;
public CheckBoxNodeRenderer() {
Font fontValue;
fontValue = UIManager.getFont("Tree.font");
if (fontValue != null) {
leafRenderer.setFont(fontValue);
Boolean booleanValue = (Boolean) UIManager
.get("Tree.drawsFocusBorderAroundIcon");
leafRenderer.setFocusPainted((booleanValue != null)
&& (booleanValue.booleanValue()));
selectionBorderColor = UIManager.getColor("Tree.selectionBorderColor");
selectionForeground = UIManager.getColor("Tree.selectionForeground");
selectionBackground = UIManager.getColor("Tree.selectionBackground");
textForeground = UIManager.getColor("Tree.textForeground");
textBackground = UIManager.getColor("Tree.textBackground");
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded, boolean leaf, int row,
boolean hasFocus) {
Component returnValue;
if (leaf) {
String stringValue = tree.convertValueToText(value, selected,
expanded, leaf, row, false);
leafRenderer.setText(stringValue);
leafRenderer.setSelected(false);
leafRenderer.setEnabled(tree.isEnabled());
if (selected) {
leafRenderer.setForeground(selectionForeground);
leafRenderer.setBackground(selectionBackground);
} else {
leafRenderer.setForeground(textForeground);
leafRenderer.setBackground(textBackground);
if ((value != null) && (value instanceof DefaultMutableTreeNode)) {
Object userObject = ((DefaultMutableTreeNode) value)
.getUserObject();
if (userObject instanceof CheckBoxNode) {
CheckBoxNode node = (CheckBoxNode) userObject;
leafRenderer.setText(node.getText());
leafRenderer.setSelected(node.isSelected());
returnValue = leafRenderer;
} else {
returnValue = nonLeafRenderer.getTreeCellRendererComponent(tree,
value, selected, expanded, leaf, row, hasFocus);
return returnValue;
class CheckBoxNodeEditor extends AbstractCellEditor implements TreeCellEditor {
CheckBoxNodeRenderer renderer = new CheckBoxNodeRenderer();
ChangeEvent changeEvent = null;
JTree tree;
public CheckBoxNodeEditor(JTree tree) {
this.tree = tree;
public Object getCellEditorValue() {
JCheckBox checkbox = renderer.getLeafRenderer();
CheckBoxNode checkBoxNode = new CheckBoxNode(checkbox.getText(),
checkbox.isSelected());
return checkBoxNode;
public boolean isCellEditable(EventObject event) {
boolean returnValue = false;
if (event instanceof MouseEvent) {
MouseEvent mouseEvent = (MouseEvent) event;
TreePath path = tree.getPathForLocation(mouseEvent.getX(),
mouseEvent.getY());
if (path != null) {
Object node = path.getLastPathComponent();
if ((node != null) && (node instanceof DefaultMutableTreeNode)) {
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) node;
Object userObject = treeNode.getUserObject();
returnValue = ((treeNode.isLeaf()) && (userObject instanceof CheckBoxNode));
return returnValue;
public Component getTreeCellEditorComponent(JTree tree, Object value,
boolean selected, boolean expanded, boolean leaf, int row) {
Component editor = renderer.getTreeCellRendererComponent(tree, value,
true, expanded, leaf, row, true);
// editor always selected / focused
ItemListener itemListener = new ItemListener() {
public void itemStateChanged(ItemEvent itemEvent) {
if (stopCellEditing()) {
fireEditingStopped();
if (editor instanceof JCheckBox) {
((JCheckBox) editor).addItemListener(itemListener);
return editor;
class CheckBoxNode {
String text;
boolean selected;
public CheckBoxNode(String text, boolean selected) {
this.text = text;
this.selected = selected;
public boolean isSelected() {
return selected;
public void setSelected(boolean newValue) {
selected = newValue;
public String getText() {
return text;
public void setText(String newValue) {
text = newValue;
public String toString() {
return getClass().getName() + "[" + text + "/" + selected + "]";
class NamedVector extends Vector {
String name;
public NamedVector(String name) {
this.name = name;
public NamedVector(String name, Object elements[]) {
this.name = name;
for (int i = 0, n = elements.length; i < n; i++) {
add(elements);
public String toString() {
return "[" + name + "]";

Between when you posted the question and the entire 50 minutes you waited for an answer, I tried compiling that code you posted, with a view to help out.
What I found was..
That code did not compile as posted.
- It was missing imports
- There was a direct reference to setLayout that applied to no member
- model was not declared properly
It also shows unchecked add warnings, please fix those before posting.
BTW - please do not remove indenting from posted code, it makes it very hard to read, replace any tabs in the source for 2-4 spaces instead. Also, code is easier to examine when it is enclosed in 'code' tags - this can be achieved by selecting the code and pressing the 'code' button above the form field we type the messages.
On the subject of what you are trying to do, please trim your example down to something that tries to create this tree form any directory structure the user might specify with a JFileChooser, because I am running a slow machine with large drives, and creating a JTree of the entire file system would take far too long.
Fix those things, and I'll take a second look.
As an aside. If you wish to get answers 'within the hour', you will probably need a consultant or a help desk. If you post to these forums, you need to be more patient.

Similar Messages

  • We have a complete CC business membership and currently have the programs installed on 2 computers but need to add them onto a 3rd. Can we add a licence to our membership or do we need to purchase an additional membership?

    We have a complete CC business membership and currently have the programs installed on 2 computers but need to add them onto a 3rd. Can we add a licence to our membership or do we need to purchase an additional membership?

    If you have Creative Cloud for teams, and you bought the licenses through Adobe direct (via Adobe.com), you can add licenses yourself, and they will be invoiced automatically as you get invoiced for the other two licenses.
    Log into adobe.com with your team admin Adobe ID and password.
    Once logged in you should be able to access a Manage Team option from the menu.
    In the top-right corner there should be an Add Licenses button, that lets you purchase any number of additional licenses.
    If you've not purchased through Adobe direct, but through a reseller, you'd need to contact your reseller to add the additional license.
    Hope this helps,
    Cari

  • I forgot my code for my iphone 4 not pin but not my my unlock code

    I forgot my code for my iphone 4 not the pin code but the unlock code PLIIIIIIIIIIIS HELP

    I forgot my code for my iphone 4 not the pin code but the unlock code PLIIIIIIIIIIIS HELP

  • The page with the code for my printer has expired and I need to print a new one but can't figure out

    How do I print out a new sheet with code for wireless setup?

    Are you talking about the IP address or the Mac Address of the printer? If you go into the setup menu you can go to reports or the network for the wireless information depending on what code you are looking for......
    Although I am an HP employee, I am speaking for myself and not for HP.

  • Certification code for Complete SAP APO & SD?

    What certification code that i need to pass for SAP APO and SAP SD? and how long it takes to complete the certification in APO and SD?

    HI
    For SAP SD
    C_TSCM62_65 – SAP Certified Application Associate - Order Fulfillment with SAP ERP 6.0 EHP5
    SAP APO
    C_TSCM44_65 – SAP Certified Application Associate - Planning and GATP in SAP SCM APO 7.0 EhP1
    Regarding completion of certification - it depends on
    1) your basic knowledge in SD and APO.
    2) depends on your interest towards the subject and your experience in different modules.
    pls be thorough with the books provided by SAP since most of the questions for certification comes from them..
    Rgds
    Raja kiran R

  • Hi, I have all codes for Adobe Photoshop Elements 10 (MacOSX), but the product was loosed during the virus cleaning. I need the installation and activation of that. Could you help me please?

    Bonjour,
    J'ai besoin de votre aide pour installer et active mon Adobe Photoshop Elements 10, qui j'ai obtenu de ce site. J'ai un MacBook Air et les codes sont:
    < removed>  Photoshop 10
    < removed> Premières Elements 10 , mais je ne trouve pas  le photoshop lui meme pour le telecharger.
    Pouvez vous me donner un soutiens pour installer  ce produit?
    En remerciant en avance,
    j'attends votre aide.
    Galina Sibiliova
    [email protected]

    Ici:
    Download Photoshop Elements products | 13, 12, 11, 10
    But this is a user to user forum. Please don't ever post your serial numbers here. I've removed them for you.

  • Entering Registration Code for Quicktime acts like it works but doesn't actually

    I've read a lot of these quicktime troubleshooting steps and support Q&A but can't seem to get Pro to unlock.  I have verified that I am typing correctly in both the Registered To and Registration Code fields on the register. 
    When I hit Apply it produces a line of text that says QuickTime 7 Pro, but that's it.
    When I hit okay and try to use some of the QT Pro functionality, say file>New Player it still acts like I don't have Pro. if I click About QuickTime it doesn't says 7.7.1 not pro
    So heres what I have tried so far.  Restarting Quicktime.  Restarting the Computer.  Uninstalling Quicktime Restarting the computer and Reinstalling Quicktime and trying to register again.
    The problem still pursists. I have purchased the Windows Version, am running Windows 7, and have the latest version of quicktime.  I don't mind re-doing any of these steps if it will help troubleshoot this problem. What would you suggest to ensure that I can upgrade to QT Pro successfully?

    When I hit Apply it produces a line of text that says QuickTime 7 Pro, but that's it.
    That's all you get. There is no other confirmation.
    When I hit okay and try to use some of the QT Pro functionality, say file>New Player it still acts like I don't have Pro. if I click About QuickTime it doesn't says 7.7.1 not pro
    It won't say "pro" anywhere other than a small "Pro" tag on the QuickTime "Q" logo. If the Pro labels disappeared from the commands and they're no longer greyed out, the key was correctly registered.
    If "New Player" doesn't work, something else is amiss. First, confirm that the new player isn't just hiding behind an existing one or other window. If that's definitely not the case, do any of the other Pro functions such as Export work? Or are all of the functions not working?
    Regards.

  • Pythagors into java-code (i got the idea, i think,  but need it simplified)

    Goodday all :),
    I have been trying to turn the forumula | a^2 + b^2 = c^2 | into java code.
    To clear it up a little more;
    1. Define unknown variable
    2. Define values of other two variables
    3. Program calculates
    x1. unkown variable is 'a'
    x2. b = 20 , c = 40
    x3. a = [(40^2) - (20^2)] ^0.5 (sorry couldnt figure out superscript)
    What i was thinking as a concept;
    1. Java asks for uknown value -> user defines as 'a' , 'b' or 'c'.
    2. Java If else statement
    2.1 if 'd' -> java asks again
    2.2 else 'e' --> java asks again etc (if else statemenst from d - z)
    import java.io.*;
    public class example {
         public static void main(String[] args) {
              System.out.println("define uknown value");
              BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
              boolean running = true;
              while(running) {
                        String line = reader.readLine();
                        if (line.startsWith("d")) {
                             System.out.println("wrong input, define unknown value");
                             running = true;
                             } else      if (line.startsWith("e")) {
                             System.out.println("wrong input, define unknown value");
                             running = true;
                             } else      if (line.startsWith("f")) {
                             System.out.println("wrong input, define unknown value");
                             running = true;
                             } else      if (line.startsWith("g")) {
                             System.out.println("wrong input, define unknown value");
                             running = true;and furter i was thinking;
    If a, b or c is pressed it will ask for the values of the other two
    and it will be such a code as above, repeating itself;
                        String line = reader.readLine();
                        if (line.startsWith("a")) {
                             System.out.println("please define b");
                             running = true;
                             if (line.startsWith("1")) {
                             int x = 1;
                             System.out.println("b=1");
                             running = true;
                             } else      if (line.startsWith("2")) {
                             int x = 2;
                             System.out.println("b=2");
                             running = true;
                             } else      if (line.startsWith("3")) {
                             int x = 3;
                             System.out.println("b=3");
                             running = true;and so on till, lets say 1000?
    Now my question is;
    Is this the right way to make this program?
    I would have like a .java file of severel megebytes if i wanted the values to get up to 10000 or something >.<

    Aargh! No. This code snippet might be of help.
    try {
       int x = Integer.parseInt("42");
       System.out.println("X = " + x);
    } catch( NumberFormatException e ) {
       System.err.println("Not a number: " + e);
       e.printStackTrace();
    }You would probably also find it useful to read about "regular expressions" if you always expect the formula to have exactly the same form.

  • Have VS Express 2013 for Web but need to add JavaScript .. how to add this Template in the New Project or should I...

    Install Visual Studio Express 2013 for Desktop instead. Is there a way to have both installed on same machine? Or can I install some add ons (if so what) to get that feature in VS Express for the Web? suggestions?

    Thanks for pvge42's help.
    Hi Phillipk,
    I agree with the pvdg42's suggestion, so if possible I suggest you can try the pvdg42's suggestion to install the VS2013 Community check your issue.
    In addition, I suggest you can refer the VS2013 Express MSDN document to understand different project use the different version of VS2013 Express.
    http://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Add new field in the fbl5n dynamic selections/ Need to add dunning clerk fi

    Hi Gurus,
    Currently, you can find the Accounting Clerk field in the dynamic selections.  Would like to be able to use the Dunning Clerk field in the dynamic selections.
    Beyond that, would like to bring both Accounting Clerk and Dunning Clerk as columns when looking at customer detail. 
    Would be willing to use other report that I can access that would give me these two clerks by customer number.
    Thanks in advance.....
    Ramanjaneyulu

    Hi,
    the field dunning clerk is not available in Dynamic Selections because it is in table KNB5.
    The fields which are eligible for dynamic selection can be reviewed for
    the related logical database via trans SE36
    1) Enter logical database DDF, KDF or SDF (for FBL5N, FBL1N, FLB3N)
    2) Menu -> Extras -> selection views
    3) Here you can find 2 origins of the view (SAP and CUS).
       The standard view SAP is used. Create your own using view CUS. First
       copy the view SAP.
       On the left side are the functional groups.
       01  Customer master  => fields from table KNA1
       02  Company code    =>  fields from table KNB1
       03  Documents        => fields from table BSID
      Only those fields from these tables can be used for dynamic selection
    Regards,
    Greta

  • I've got a PHP form working, but need to add "autoRespond", anyone know?

    i've developed a working PHP5 file to submit the form to the
    webmaster (info@). Now, the client wants me to add on a custom
    autoResponder. basically, the user fills out the form, the user
    gets an e-mail saying thank you in the subject line and body copy,
    says it came from info@ website.
    Here's the PHP script that's linked to it:

    I take the simple (though not free) way:
    www.bebosoft.com/formstogo/
    domerdel wrote:
    > i've developed a working PHP5 file to submit the form to
    the
    > webmaster (info@). Now, the client wants me to add on a
    custom
    > autoResponder. basically, the user fills out the form,
    the user gets
    > an e-mail saying thank you in the subject line and body
    copy, says it
    > came from info@ website.
    >
    > Here's the PHP script that's linked to it:
    >
    >
    >
    > <?
    > error_reporting(1);
    > if ( $_POST['tpl'] == "mail_req.tpl" )
    > $mailto = Array("[email protected]");
    > else
    > $mailto = Array("[email protected]","[email protected]");
    >
    > $subject="Celibre Web Inquiry: {$_POST['name']}";
    >
    > if ( $_POST['tpl'] == "mail_req.tpl" ) {
    > $t_data=file_get_contents("mail_req.tpl");
    > $subject="Req Cert Inquiry from Website";
    > }
    > elseif ( $_POST['tpl'] )
    > $t_data=file_get_contents("mail_contact.tpl");
    > else
    > $t_data = file_get_contents("mail_template.tpl");
    > foreach($_POST as $key=>$value)
    > $t_data=str_replace("[".$key."]",$value,$t_data);
    >
    > if ( $_POST['companyname'] )
    > $fromname=$_POST['companyname'];
    > elseif ( $_POST['name'] )
    > $fromname = $_POST['name'];
    > else
    > $fromname = $_POST['firstName'] . " " .
    $_POST['lastName'];
    >
    > $headers = "MIME-Version: 1.0\n".
    > "Content-type: text/html; charset=iso-8859-1\n".
    > "From: \"Website.com\" <[email protected]>\n".
    > "Date: ".date("r")."\n";
    >
    > foreach($mailto as $value) {
    >
    mail($value,$subject,$t_data,str_replace("[to]",$value,$headers));
    > }
    >
    > header("location: thank_you.html");

  • Sky+ Remote Code for Bush LED40127FHDCNTD 40" Full HD LED Smart TV (Rev 9 Remote) [Working]

    Hi, I wanted to pass on a code that I found that worked with the  Bush 40" Full HD LED Smart TV (LED40127FHDCNTD) (Argos item number 128/1684). I tried a few codes from a round the web but found 0065 to work with this model with a Rev.9 Sky+ remote. For the sake of completeness here are some of the other codes that I tried without success: 2060, 1354, 2155 (from the Sky Remote page) , 2242,1613 and 2153. Hopefully this might help someone out there!

    Hi,I'm looking for the Sky+ Remote Code for the same Bush TV  (LED40127FHDCNTD) but I have a Rev 10 Remote. It does not give me a Rev10 option when I try looking for the code on system....day26 wrote:
    Hi, I wanted to pass on a code that I found that worked with the  Bush 40" Full HD LED Smart TV (LED40127FHDCNTD) (Argos item number 128/1684). I tried a few codes from a round the web but found 0065 to work with this model with a Rev.9 Sky+ remote. For the sake of completeness here are some of the other codes that I tried without success: 2060, 1354, 2155 (from the Sky Remote page) , 2242,1613 and 2153. Hopefully this might help someone out there! 

  • Wanted a code for table controls in bdc

    hi,
    i have written code for uploading data into FB60 transaction but i have a serious problem with that code.
    after entering 10 line items and when i am entering 11th item it is saying that the screen doesnot contain 11th line.
    so please modify my program or if you can please send me a program for handling table controls more line details.
    thanks and i will surely provide ten points to it.
    my code is
    LOOP AT I_PREPARE INTO WA_PREPARE.
    V_VALUE = WA_PREPARE-LINE+0(2).
    CASE V_VALUE.
    WHEN 'A'.
      CLEAR:V_DCNT.
    *UPLOAD THE COMPANY CODE TO FB60.
    *PERFORM.......USING WA_PREPARE-LINE+2(4).
    *? filling header data
    *********to initialize the company code and to get the popup**********
    PERFORM SET_BUKRS.
      PERFORM BDC_DYNPRO      USING 'SAPLACHD' '1000'.
      PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                    'BKPF-BUKRS'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                    '=ENTR'.
      BUKRS = WA_PREPARE-LINE+2(4).
      PERFORM BDC_FIELD       USING 'BKPF-BUKRS'
                                          BUKRS.
      PERFORM BDC_DYNPRO      USING 'SAPMF05A' '1100'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                    '/00'.
      PERFORM BDC_FIELD       USING 'RF05A-BUSCS'
                                    'R'.
    *UPLOAD THE VENDOR NUMBER TO FB60
    *PERFORM.......USING WA_PREPARE-LINE+45(10).
      ACCNT = WA_PREPARE-LINE+45(10).
      PERFORM BDC_FIELD       USING 'INVFO-ACCNT'
                                           ACCNT.
    *UPLOAD THE DATE TO FB60
    WRITE WA_PREPARE-LINE+34(8) TO V_DATE USING EDIT MASK '  .  .    .'
    *PERFORM.......USING V_DATE.
      PERFORM BDC_FIELD       USING 'INVFO-BLDAT'
                                    '15.09.2004'.
      PERFORM BDC_FIELD       USING 'INVFO-BUDAT'
                                    '15.09.2004'.
    *UPLOAD THE AMOUNT TO FB60
    *PERFORM.......USING WA_PREPARE-LINE+85(15).
      WRBTR = WA_PREPARE-LINE+85(15).
      PERFORM BDC_FIELD       USING 'INVFO-WRBTR'
                                           WRBTR.
    *UPLOAD THE CURRENCY CODE TO FB60
    *PERFORM.......USING WA_PREPARE-LINE+100(3).
      WAERS = WA_PREPARE-LINE+100(3).
      PERFORM BDC_FIELD       USING 'INVFO-WAERS'
                                    WAERS.
    WHEN 'D'.
      V_DCNT = V_DCNT + 1.
    IF V_DCNT GT 04.
       V_DCNT = 04.
    ENDIF.
    *UPLOAD THE G/L ACC. TO FB60.
    *PERFORM.......USING WA_PREPARE-LINE+51(20).
    *? filling item data
      CONCATENATE 'ACGL_ITEM-WRBTR(' V_DCNT ')' INTO FNAM.
      PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                    FNAM.
      CONCATENATE 'ACGL_ITEM-HKONT(' V_DCNT ')' INTO FNAM.
      HKONT = WA_PREPARE-LINE+51(20).
      PERFORM BDC_FIELD       USING FNAM
                                    HKONT.
    *UPLOAD THE AMOUNT TO FB60(ACGL_ITEM-WRBTR)
    *PERFORM........USING WA_PREPARE-LINE+121(15).
      CONCATENATE 'ACGL_ITEM-WRBTR(' V_DCNT ')' INTO FNAM.
      WRBTR = WA_PREPARE-LINE+75(15).
      PERFORM BDC_FIELD       USING FNAM
                                    WRBTR.
      PERFORM BDC_DYNPRO      USING 'SAPMF05A' '1100'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                '=0006'.
      PERFORM BDC_FIELD       USING 'RF05A-BUSCS'
                                    'R'.
    ENDCASE.

    hi,
    check this example:
    http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
    REPORT  ZSR_BDC_TBCTRL
            NO STANDARD PAGE HEADING LINE-SIZE 255.
    TABLES : RF02K,LFA1,LFBK.
    DATA : BEGIN OF IT_VEN OCCURS 0,
          LIFNR LIKE RF02K-LIFNR,
          KTOKK LIKE RF02K-KTOKK,
          NAME1 LIKE LFA1-NAME1,
          SORTL LIKE LFA1-SORTL,
          LAND1 LIKE LFA1-LAND1,
          SPRAS LIKE LFA1-SPRAS,
          BANKS(6) TYPE C,
          BANKL(17) TYPE C,
          BANKN(19) TYPE C,
          END OF IT_VEN.
    DATA : BEGIN OF BANKS OCCURS 0,
           BANKS LIKE LFBK-BANKS,
           END OF BANKS,
           BEGIN OF BANKL OCCURS 0,
           BANKL LIKE LFBK-BANKL,
           END OF BANKL,
           BEGIN OF BANKN OCCURS 0,
           BANKN LIKE LFBK-BANKN,
           END OF BANKN.
    DATA : FLD(20) TYPE C,
           CNT(2) TYPE N.
    DATA : BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    INCLUDE BDCRECX1.
    START-OF-SELECTION.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = 'Z:\sr.TXT'
       FILETYPE                      = 'ASC'
       HAS_FIELD_SEPARATOR           = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      TABLES
        DATA_TAB                      = IT_VEN
    EXCEPTIONS
      FILE_OPEN_ERROR               = 1
      FILE_READ_ERROR               = 2
      NO_BATCH                      = 3
      GUI_REFUSE_FILETRANSFER       = 4
      INVALID_TYPE                  = 5
      NO_AUTHORITY                  = 6
      UNKNOWN_ERROR                 = 7
      BAD_DATA_FORMAT               = 8
      HEADER_NOT_ALLOWED            = 9
      SEPARATOR_NOT_ALLOWED         = 10
      HEADER_TOO_LONG               = 11
      UNKNOWN_DP_ERROR              = 12
      ACCESS_DENIED                 = 13
      DP_OUT_OF_MEMORY              = 14
      DISK_FULL                     = 15
      DP_TIMEOUT                    = 16
      OTHERS                        = 17
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    PERFORM OPEN_GROUP.
    LOOP AT IT_VEN.
        REFRESH BDCDATA.
        REFRESH : BANKS,BANKL,BANKN..
        SPLIT IT_VEN-BANKS AT ',' INTO TABLE BANKS.
        SPLIT IT_VEN-BANKL AT ',' INTO TABLE BANKL.
        SPLIT IT_VEN-BANKN AT ',' INTO TABLE BANKN.
    PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0100'.
    PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                  'RF02K-KTOKK'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '/00'.
    PERFORM BDC_FIELD       USING 'RF02K-LIFNR'
                                  IT_VEN-LIFNR.
    PERFORM BDC_FIELD       USING 'RF02K-KTOKK'
                                  IT_VEN-KTOKK.
    PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0110'.
    PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                  'LFA1-SPRAS'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '/00'.
    PERFORM BDC_FIELD       USING 'LFA1-NAME1'
                                  IT_VEN-NAME1.
    PERFORM BDC_FIELD       USING 'LFA1-SORTL'
                                  IT_VEN-SORTL.
    PERFORM BDC_FIELD       USING 'LFA1-LAND1'
                                  IT_VEN-LAND1.
    PERFORM BDC_FIELD       USING 'LFA1-SPRAS'
                                  IT_VEN-SPRAS.
    PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0120'.
    PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                  'LFA1-KUNNR'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '/00'.
    PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0130'.
    PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                  'LFBK-BANKN(02)'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '=ENTR'.
    *perform bdc_field       using 'LFBK-BANKS(01)'
                                 'DE'.
    *perform bdc_field       using 'LFBK-BANKS(02)'
                                 'DE'.
    *perform bdc_field       using 'LFBK-BANKL(01)'
                                 '10020030'.
    *perform bdc_field       using 'LFBK-BANKL(02)'
                                 '67270003'.
    *perform bdc_field       using 'LFBK-BANKN(01)'
                                 '12345'.
    *perform bdc_field       using 'LFBK-BANKN(02)'
                                 '66666'.
    MOVE 1 TO CNT.
        LOOP AT BANKS.
          CONCATENATE 'LFBK-BANKS(' CNT ') ' INTO FLD.
          PERFORM BDC_FIELD USING FLD BANKS-BANKS.
          CNT = CNT + 1.
        ENDLOOP.
        MOVE 1 TO CNT.
        LOOP AT BANKL.
          CONCATENATE 'LFBK-BANKL(' CNT ') ' INTO FLD.
          PERFORM BDC_FIELD USING FLD BANKL-BANKL.
          CNT = CNT + 1.
        ENDLOOP.
        MOVE 1 TO CNT.
        LOOP AT BANKN.
          CONCATENATE 'LFBK-BANKN(' CNT ') ' INTO FLD.
          PERFORM BDC_FIELD USING FLD BANKN-BANKN.
          CNT = CNT + 1.
        ENDLOOP.
    PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0130'.
    PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                  'LFBK-BANKS(01)'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '=ENTR'.
    PERFORM BDC_DYNPRO      USING 'SAPLSPO1' '0300'.
    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                  '=YES'.
    PERFORM BDC_TRANSACTION USING 'XK01'.
    ENDLOOP.
    PERFORM CLOSE_GROUP.

  • VK code for Enter

    when i try the code
    Robot r = new Robot();
    r.keyPress(20);
    r.keyRelease(20);
    it works for all the VK values i found except for 20 for return, i jus get Invalid key code Eception. can any one tell me the integer code for enter?
    thanks

    i tried that but it doesn't seem to work. ...Here is a little example I made.
    Does it work as you expect?import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    /** Example of using the Robot to type in a text field,
    use the enter key, and activate a button via the space bar. */
    class ActivateButtonUsingRobot {
       static Robot robot;
       static void activateKey(int keycode) {
          robot.keyPress( keycode );
          robot.keyRelease( keycode );
          robot.delay( 150 );
       public static void main(String[] args)
          throws AWTException {
          // if headless, exit early
          robot = new Robot();
          final JFrame f = new JFrame();
          f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
          JTextArea ta = new JTextArea("1st line!",10,20);
          f.getContentPane().add(ta, BorderLayout.CENTER);
          JButton button = new JButton("Press Me!");
          button.addActionListener( new ActionListener() {
             public void actionPerformed( ActionEvent ae ) {
                JOptionPane.showMessageDialog(
                   f, "Button Activated!" );
          f.getContentPane().add(button, BorderLayout.SOUTH);
          f.pack();
          // put frame in center of screen
          f.setLocationRelativeTo(null);
          f.setVisible(true);
          Dimension screensize =
             Toolkit.getDefaultToolkit().getScreenSize();
          // move mouse to center of screen, and ..
          robot.mouseMove(
             screensize.width/2, screensize.height/2 );
          // ..activate the frame
          robot.mousePress( InputEvent.BUTTON1_MASK );
          robot.mouseRelease( InputEvent.BUTTON1_MASK );
          robot.delay( 400 );
          // try using enter key..
          activateKey( KeyEvent.VK_ENTER );
          activateKey( KeyEvent.VK_ENTER );
          // this text should have a blank line above it..
          activateKey( KeyEvent.VK_H );
          activateKey( KeyEvent.VK_I );
          // move to the button
          robot.keyPress( KeyEvent.VK_CONTROL );
          robot.keyPress( KeyEvent.VK_TAB );
          robot.keyRelease( KeyEvent.VK_TAB );
          robot.keyRelease( KeyEvent.VK_CONTROL );
          robot.delay( 500 );
          // try activating the button..
          activateKey( KeyEvent.VK_SPACE );
    }

  • Need platform independent java code for TNS PING

    Hi, I am able to ping server /ip address. but unable to ping some TNS entry.
    There is one way to ping TNS entry using System command, but that will make my code platform dependent. i want platform independent code.. need code help for TNS Ping to database server.. here are my code:
    ---Code for server / Ip address ping:---------
    package DBM;
    import java.io.IOException;
    import java.net.InetAddress;
    import java.net.UnknownHostException;
    import java.util.ArrayList;
    import oracle.net.TNSAddress.*;
    public class PingServer
    public static void main(String[] args)
    System.out.println(" Server Pinging Starts...");
    ArrayList<String> list=new ArrayList<String>();
    list.add("g5u0660c.atlanta.hp.com");
    list.add("g1u1675c.austin.hp.com");
    list.add("gvu1785.atlanta.hp.com");
    list.add("10.130.14.109");
    list.add("10.130.0.173");
    list.add("DESCRIPTION = (SDU = 32768) (enable = broken) (LOAD_BALANCE = yes) (ADDRESS = (PROTOCOL = TCP)(HOST = gvu1515.atlanta.hp.com)(PORT = 1525))(ADDRESS = (PROTOCOL = TCP)(HOST = gvu1785.atlanta.hp.com)(PORT = 1525)");
    list.add("IDSENGI");
    //This Ipadd variable is used to convert the arraylist into String
    String ipadd="";
    try
         for(String s: list)
              ipadd=s;
              // InetAddress is class.in this class getByName()is used to take only string parameter.
              InetAddress inet = InetAddress.getByName(ipadd);
              //InetAddress inet1 =InetAddress.getAllByName("IDESENGP");
              System.out.println("Sending Ping Request to " + ipadd);
              //in InetAddress call IsReachabe(3000)method is used to ping the server IP and if ping is successfully then return true otherwise false.
              //IsReachable()take time in millisecond and return type is boolean.
              System.out.println("Host is reachable: "+inet.isReachable(3000));
         System.out.println("Server Pinging program is working fine........");
    catch (UnknownHostException e)
         System.err.println("Host does not exists");
    catch (IOException e)
         System.err.println("Error in reaching the Host");
    ----Code for TNS ping using system host----
    package DBM;
    import java.io.*;
    public class doscmd
    public static void main(String args[])
    try
    Process p=Runtime.getRuntime().exec("cmd /c tnsping IDSENGP");
    p.waitFor();
    BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line=reader.readLine();
    while(line!=null)
    System.out.println(line);
    line=reader.readLine();
    catch(IOException e1) {}
    catch(InterruptedException e2) {}
    System.out.println("Done");
    The above two codes are working absolutely fine... but need TNS ping program is platform dependent..we need to deploy it in both windows, unix...
    Please help.

    You don't need to install another JDK, just use the api from 1.2 and you should be fine. You can even use the 1.4 jdk to compile as if it were 1.2 by using the -target option in javac.

Maybe you are looking for

  • IPod freezes after connecting to PC/iTunes

    I think it's a common problem that iPods freeze after plugging in the USB cable. I don't know if it's working for others, but if i do a reset (hold menu plus select) on the iPod while it is plugged and iTunes is running it works. But i have to do thi

  • URL item not shown

    I added an URL item in a folder, but when wieving the folder portal returns the following error: Error: Call to utl_http failed (WWS-32136) ORA-1: User-Defined Exception (WWC-36000) Using: IAS102, Portal 3.0.6.5 on Solaris. Thanx & Bye all Fab null

  • Book - TOC Positioning

    Is this possible to have (DEFAULT)Table Of Contents (TOC) as the 2nd report in the book? i.e. presently my editor shows the below reports Report A Report B Report Z The PDF output of the book shows as below: TOC Report A Report B Report Z I want the

  • Mozilla support redirects to japanese site

    Beginning yesterday, I awoke to find that my outlook.com pinned tab, that shows my hotmail inbox, had changed to the outlook sign-in page (which I didn't consider unusual - I simply thought the cookie had expired and it wanted me to sign in again). H

  • HT201272 Can someone please help me to find a previous purchased app .

    I had purchased quickoffice on a former Ipad I had. I have no longer this ipad anymore but a new Ipad but I cannot find anywhere the Quickoffice App that I bought 3 years ago. Its not listed anywhere on my Itunes.