Rerieve the content of a JScrollPane???!!

Hi,
I have constructed a JScrollPane with a JList reference as given in the code segment..
JList list = new JList(vector_data);
JScrollPane scroll = new JScrollPane(list);
At later point (where I do not have the reference to JList but to JScrollPane), if I want to retrieve the 'list' reference contained in the JScrollPane what should I do?
Please help!.
Satish

i really dont get the point that you wont have reference to the JList but you have reference to the scrollpane, if your JList is declared public than i think you can refer it from anywhere within the class.

Similar Messages

  • JScrollPane- Scrolling makes the contents of the Pane garbled

    I have a JTextPane inserted into a JScrollPane and the JSrcollPane is Inserted into the bottom part of the JSplitPane..
      private JTextPane ResultTextPane = new JTextPane();
      ResultScrollPane.getViewport().add(ResultTextPane, BorderLayout.CENTER)
      ResultSplitPane.add(ResultScrollPane, JSplitPane.BOTTOM);Now, When i try scrolling the scrollpane, the text is garbled. (A part of text seems be to dragged when the scroll bar is moved..).If i resize the window, the text is displayed fine and if I start scrolling, the text gets garbled again..
    I am not sure what the problem is? Am I suppose to use a scrollinglistener(AdjustChangeListener) and repaint the contents of the textpane or is it suppose to be happen automatically.

    The easiest way to use a JScrollPane is:
    JScrollPane scrollPane = new JScrollPane( textPane );
    If you need to reset the component in the scrollPane then you would use:
    scrollPane.getViewport().setView( textPane );
    Dont use the add(..) method of the viewport.

  • Displaying the content of JPanel

    hello, I have a JPanel which contains a JScrollPane displaying data from a database. I have created a JButton which permit to hide and show the content
    of jpanel (hide and show jscrollpane alternaly). but when I hide the content the first once I cant re-show it. the code of the JButton is :
    // first click
    jPanel3.add(jScrollPane1, null);
    jPanel3.repaint();
    // second click
    jPanel3.removeAll();
    this.repaint();
    Best Regards.

    Instead of actually removing the component from the GUI and then trying to put it back, why don't you just make use of the setVisible() method?

  • Save the contents into hard disk on click of Save As button in Swing

    Hi,
    I have a JButton "Save As". On clicking the button, the contents in the JTextArea should be saved in the local hard disk by opening a Save As dialog box and allowing the user to save in any location.
    Is it possible to do this? If so, please inform me how it could be done.

    Hi,
    Please find the code below.
    try{
    File f = new File("Out.txt");
    FileInputStream fis = new FileInputStream(f);
    BufferedInputStream bis = new BufferedInputStream(fis); DataInputStream dis = new DataInputStream(bis); String stb = null;
    JDialog w = null;
    stb = new String();
    stb = dis.readLine();
    if(stb != null){
    w = new JDialog();
    final Container c = w.getContentPane();
    c.setLayout(null);
    w.setContentPane(c);
    w.setResizable(true);
    w.setTitle("Log Window");
    w.setSize(330,500);
    final JTextArea jt = new JTextArea();
    JScrollPane jsp = new JScrollPane(jt);
    jt.setLineWrap(true);
    jt.setText("Records not available for the id's"+"\n"+stb);
    jt.setBounds(10,10,285,500);
    final JButton jbSave = new JButton("Save File As");
    JPanel spacer = new JPanel();
    spacer.setMinimumSize(new Dimension(50, 18));
    spacer.setPreferredSize(new Dimension(50, 18));
    JPanel jpButtons = new JPanel();
    jpButtons.add(jbSave);
    jpButtons.add(spacer);
    jpButtons.setBorder(BorderFactory.createEtchedBorder());
    JScrollPane scroll = new JScrollPane();
    c.setLayout(new BorderLayout());
    c.add(jt,BorderLayout.CENTER);
    c.add(jpButtons, BorderLayout.SOUTH);
    jbSave.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    JFileChooser fileChooser = new JFileChooser();
    int userOption = fileChooser.showSaveDialog(null);
    if(userOption == JFileChooser.APPROVE_OPTION)
    //*******************STATEMENTS TO BE ADDD****************** }
    jt.getText()-----This is how I can get the contents from JTextArea.
    But how I can save the contents. i.e on click of Save As button, Save dialog box opens, and I can choose the location and give the name. but if I go to the location I don't find the file....
    Please guide me to finish this....
    Thanks in Advance.....

  • Disabling "auto scroll to the bottom function" on JScrollPane

    Hi all!
    I have a little problem with JScrollPane.
    I have a JEditor Pane on my JScrollPane which content type is text/html. When the content of html code is too large scrollbars are appear and vertical scrollbar automatically scrolls down to the bottom of my JEditorPane. How can I disable this "function", because I don't want to see the bottom of the page after contet is loaded. (Only in case when the user scrolls down manually.)
    Thanks for your help!

    after loading the file you should be able to use:
    textComponent.setCaretPosition(0);

  • Controlling the knob of a JScrollPane

    I have a JTable inside a JScrollPane.
    When starting the program the horizontal knob is at its left-most position.
    The JTable is larger than the JViewPort, hence only the top left area of the JTable is visible.
    Using the mouse pointer I can drag the horizontal knob towards the right, hence scrolling the JTable.
    Now that I have manually scrolled my JTable, I want to click on the contents of one cell of the JTable and do some actions.
    The problem is that, as soon as I click on the JTable, the horizontal knob moves back to its original left-most position and the JTable gets scrolled back to its left corner again.
    How can I keep the horizontal knob in the position that I set manually with the mouse pointer?
    in other words...
    How can I keep the horizontal knob in the position where it was before clicking in the JTable ?

    Following the sugestions given by: StanislavL and akhalil100, I have inseterd the following code when creating the JScrollPane for the first time:
              theJScrollPaneOfCandidates.setMinimumSize( new Dimension(50, 50) );
              theJScrollPaneOfCandidates.setPreferredSize( new Dimension(125, 125));
              theJScrollPaneOfCandidates.getHorizontalScrollBar().setValue(500);
              * Now I am going to test if the JScrollPane has the good Value
              int theValue = theJScrollPaneOfCandidates.getHorizontalScrollBar().getValue();
    I have a breakpoint placed after the last line of code, to be able to see the contents returned by getValue().
    Now this is the strange behaviour:
    It works when I try to set a value =< 90, but it does not work for values larger than 90.
    In more detail:
    I can setValue between 0 and 90 and a get the same value from getValue.
    But if a setValue larger than 90, then the getValue returns always 90.
    In particular, if you see the code above, I setValue(500) and in the next line of code the getValue() method returns to me 90.

  • Apply formatting in a JEditorPane and export the content in HTML.

    Hi,
    I'm writing, a program to allow the user to enter a formated text and even add images in a JEditorPane.
    Here is a simple sample of the code:
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.*;              //for layout managers and more
    import java.awt.event.*;        //for action events
    import java.net.URL;
    import java.io.IOException;
    public class EditorPane extends JPanel{
        private String newline = "\n";
        private JPanel buttonPanel;
        private JPanel textPanePanel;
        private JEditorPane myEditorPane;
        private JButton boldButton;
        private JButton colorButton;
        private JButton imgButton;
        private JButton saveButton;
         public EditorPane() {
            createGUI();
        private void createGUI() {
            buttonPanel = new JPanel();
            boldButton = new JButton("Bold");
            boldButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    boldButtonActionPerformed(evt);
            colorButton = new JButton("Color");
            colorButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    colorButtonActionPerformed(evt);
            imgButton = new JButton("Image");
            imgButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    imgButtonActionPerformed(evt);
            saveButton = new JButton("Save");
            saveButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    saveButtonActionPerformed(evt);
            buttonPanel.setLayout(new GridLayout(1, 4));
            buttonPanel.add(boldButton);
            buttonPanel.add(colorButton);
            buttonPanel.add(imgButton);
            buttonPanel.add(saveButton);
            textPanePanel = new JPanel();
            textPanePanel.setLayout(new BorderLayout());       
            myEditorPane = this.createEditorPane();
            JScrollPane paneScrollPane = new JScrollPane(myEditorPane);
            textPanePanel.add(paneScrollPane, BorderLayout.CENTER);
            this.setLayout(new BorderLayout());
            this.add(buttonPanel, BorderLayout.NORTH);
            this.add(textPanePanel, BorderLayout.CENTER);
        public static void main(String[] args) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                     JFrame frame = new JFrame("TextSamplerDemo");
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   EditorPane newContentPane = new EditorPane();
                    //newContentPane.setOpaque(true); //content panes must be opaque
                    frame.setContentPane(newContentPane);
                    frame.pack();
                    frame.setSize(300,300);
                    frame.setVisible(true);
    private JEditorPane createEditorPane() {
            JEditorPane editorPane = new JEditorPane();
            editorPane.setEditable(true);
            java.net.URL helpURL = TextSamplerDemo.class.getResource(
                                            "simpleHTMLPage.html");
            if (helpURL != null) {
                try {
                    editorPane.setPage(helpURL);
                } catch (IOException e) {
                    System.err.println("Attempted to read a bad URL: " + helpURL);
            } else {
                System.err.println("Couldn't find file: simpleHTMLPage.html");
            return editorPane;
        private void boldButtonActionPerformed(java.awt.event.ActionEvent evt) {
        System.out.println("boldButtonNextActionPerformed");
        //myEditorPane
            // TODO add your handling code here:
        private void colorButtonActionPerformed(java.awt.event.ActionEvent evt) {
        System.out.println("colorButtonActionPerformed");
            // TODO add your handling code here:
        private void imgButtonActionPerformed(java.awt.event.ActionEvent evt) {
        System.out.println("imgButtonActionPerformed");
            // TODO add your handling code here:
        private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {
        System.out.println("saveButtonActionPerformed");
        String newStr = new String("this is the new String");
        //newStr.setFont(new java.awt.Font("Tahoma", 0, 14));
        this.myEditorPane.replaceSelection("sdfsdfsd");
            // TODO add your handling code here:
    }and the HTML Code of simpleHTMLPage.html is
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <p>Simple text</p>
    <p><strong>Bold text</strong></p>
    <p><em>Italic text</em></p>
    <p align="center">Center text</p>
    <p><font color="#000099"><strong>Color text</strong></font></p>
    <p>image here : <img src="images/Pig.gif" width="121" height="129"></p>
    <p> </p>
    </body>
    </html>By pressing the Save button I can change the selected text.
    I don�t know the way to get and apply the format (size, color �) to only the selected text and display the selected image in real time in the EditorPane. Like if you press the Bold button, the selected text font will be change to bold.
    I would like to get or save the HTML code of the content of the EditorPane by pressing the Save button, How to make it?
    I can apply the formatting on the selected text in a JTextPane, but I don't know the way to save or export the content in HTML. By doing that it could fix my problem too.
    So any help to do that will be much appreciated.
    Thanks.

    Hi,
    Tks for your answer. That one I can do it. I would like to display the selected text in bold instead of adding the tag in the JEditorPane. If I get you right, you get the hole content of the JEditorPane and save it. How did you get it ? And before saving that in the database, did you fing the keysWord to convert the HTML tag in the corresponding entities ?
    Bellow you have a sample of code to make the formatting in the JTextPane.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.text.*;
    import javax.swing.text.Highlighter;
    import javax.swing.event.*;
    import java.util.*;
    import javax.swing.text.*;
    import javax.swing.text.BadLocationException;
    public class MonJTextPane extends JFrame implements CaretListener, ActionListener
              *     Attributs :
         private JTextPane monTextPane;
         private JLabel monLabel;
         private JButton monBouton;
         private StyleAide style; // class qui defini les effets de style de l'editeur
              *     Constructeur :
         public MonJTextPane ()
         {     super ("Aide");
              // construction du composant Texte
              this.style = new StyleAide (new StyleContext ());
              this.monTextPane = new JTextPane ();
              this.monTextPane.setDocument (style);
              this.monTextPane.addCaretListener (this);
              // construction de la fenetre :
              this.getContentPane ().setLayout (new BorderLayout ());
              this.setBounds (150,150,600,550);
              this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
              this.monLabel = new JLabel ("Auncune ligne saisie...");
              this.monBouton = new JButton ("change de style");
              this.monBouton.addActionListener (this);
              JPanel panel = new JPanel ();
              panel.setLayout (new GridLayout (1,2));
              panel.add (monLabel);
              panel.add (monBouton);
              this.getContentPane ().add (panel, BorderLayout.SOUTH);
              this.getContentPane ().add (this.monTextPane, BorderLayout.CENTER);
              this.setVisible (true);
              *     Methodes :
         private int getCurrentLigne ()
         {     return ( this.style.getNumLigne (monTextPane.getCaretPosition ())+1 );
         public int getCurrentColonne ()
         {     return ( this.style.getNumColonne (monTextPane.getCaretPosition ())+1 );
              *     Methodes CaretListener:
         // ecoute les deplacements du curseur d'insertion
         public void caretUpdate(CaretEvent e)
         {     int debut = java.lang.Math.min (e.getDot (), e.getMark ());
              int fin   = java.lang.Math.max (e.getDot (), e.getMark ());
              this.monLabel.setText ("Ligne numero : "+ this.getCurrentLigne ()+" Colonne : "+this.getCurrentColonne ()+" (debut : "+debut+", fin : "+fin+")");
              *     Methodes ActionListener:
         public void actionPerformed (ActionEvent e)
         {     int start     = monTextPane.getSelectionStart();
              int end          = monTextPane.getSelectionEnd();
              int debut     = java.lang.Math.min (start, end);
              int fin          = java.lang.Math.max (start, end);
              int longueur= fin - debut;
              this.style.changeStyleSurligne (debut, longueur);
         // lance le tout ....
         public static void main (String argv [])
         {     new MonJTextPane ();
    // la Classe DefaultStyledDocument correspond a la classe utilise comme Model pour les
    // composant Texte evolue comme : JTextPane ou JEditorPane
    // en derivant de cette derniere nous pouvons donc redefinir les methodes d'insertion afin de personnalise
    // le style d'ecriture en fonction du texte et creer une methode permettant de modifier le style utilise pour
    // une partie de texte deja ecrite.
    class StyleAide extends DefaultStyledDocument
              *     Constructeur :
         public StyleAide (StyleContext styles)
         {     super (styles);
              initStyle (styles);
              *     Methodes :
         // redefini pour choisir l'effet de style a utiliser
         public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
         {     try
              {     // si le texte insere est egale a HELP le texte s'ecrit avec le style "styleOp"
                   if ( str.equals ("HELP") )
                   {     super.insertString (offs, str, getStyle ("styleOp"));
                   else // sinon le texte est ecrit avec le style "styleNormal"
                   {     super.insertString (offs, str, getStyle ("styleNormal"));
              catch (BadLocationException e)
              {     System.out.println ("Tuuuttt erreur Insere");
         // modifie le style d'ecriture d'un texte deja ecrit compris
         public void changeStyleSurligne (int positionDepart, int longueur)
         {     setCharacterAttributes (positionDepart, longueur, getStyle ("styleKeyWord"), true);
         // le Model d'un composant texte est enregistre sous form d'un arbre
         // cette methode permet de recuperer le noeud root de l'arbre
         private Element getRootElement ()
         {     return this.getDefaultRootElement ();
         // methode permettant d'obtenir la ligne correspondant a un offset donnee
         public int getNumLigne (int offset)
         {     Element eltR = getRootElement ();
              int numLigne = eltR.getElementIndex (offset);
              Element elt  = eltR.getElement (numLigne);
              if ( offset != elt.getEndOffset () )
              {     return numLigne;
              else
              {     if ( numLigne != 0 )
                   {     return numLigne+1;
              return 0;
         public int getNumColonne (int offset)
         {     Element eltR = getRootElement ();
              Element elt = eltR.getElement (eltR.getElementIndex (offset));
              int numColonne = offset-elt.getStartOffset ();
              return numColonne;
         // Defini les differents styles
         private static void initStyle (StyleContext styles)
         {     // definition du style pour le texte normal (brute)
              javax.swing.text.Style defaut = styles.getStyle (StyleContext.DEFAULT_STYLE);
              javax.swing.text.Style styleNormal = styles.addStyle("styleNormal", defaut);
              StyleConstants.setFontFamily (styleNormal, "Courier");
              StyleConstants.setFontSize (styleNormal, 11);
              StyleConstants.setForeground(styleNormal, Color.black);
              javax.swing.text.Style tmp = styles.addStyle("styleKeyWord", styleNormal);
              // Ajout de la couleur blue et du style gras pour les mots cle
              StyleConstants.setForeground(tmp, Color.blue);
              StyleConstants.setBold(tmp, true);
              tmp = styles.addStyle("styleOp", styleNormal);
              // Ajout de la couleur rouge pour le style des operateurs
              StyleConstants.setForeground(tmp, Color.red);
    }But it hard for me to convert it in the corresponding HTML document.
    Did you have and idea
    Tkks

  • Click a row in jTextArea and get the content of the row.

    I have an array of strings display in a textarea, once a user click on a row, i will like to display the content of the clicked row. I am new in java swing. how should i achieve it? thank you all!!

    Working example with CaretListener:
    package org.apex.sunforums;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    * TextAreaLineSelectionTest.java
    * @author mrityunjoy_saha
    * @version 1.0
    * @since Apex 1.2
    public class TextAreaLineSelectionTest {
        public void createUI() {
            final JFrame frame = new JFrame("TextAreaLineSelectionTest");
            frame.setSize(400, 400);
            JPanel panel = new JPanel();
            panel.setLayout(new GridLayout(2, 1));
            final JTextArea textField = new JTextArea(
                    "Hello\nThis is a test class.\nTo show line selection\nType some text and see the magic.",
                    10, 20);
            JScrollPane scroll = new JScrollPane(textField,
                    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                    JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
            final JLabel display = new JLabel();
            textField.addCaretListener(new CaretListener() {
                public void caretUpdate(CaretEvent e) {
                    String lineText = "";
                    try {
                        int dot = e.getDot();
                        int rowStart = Utilities.getRowStart(textField, dot);
                        int rowEnd = Utilities.getRowEnd(textField, dot);
                        lineText = textField.getDocument().getText(rowStart,
                                (rowEnd - rowStart));
                    } catch (BadLocationException ex) {
                        ex.printStackTrace();
                    display.setText(lineText);
            panel.add(scroll);
            panel.add(display);
            frame.getContentPane().add(panel);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
        public static void main(String[] args) {
            final TextAreaLineSelectionTest test = new TextAreaLineSelectionTest();
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    test.createUI();
    }Thanks,
    Mrityunjoy

  • How to change the size of a JScrollPane

    hi there,
    a JScrollPane always has the same size... how can i change this?
    because i want to add a JTable that is much larger( x-size )than the JScrollPane and I want that the whole row can be seen without the need of scrolling.
    I cannot make the cells any smaller (because of the content) so is there anyway to make the JScrollPane bigger?
    thx anyway
    Errraddicator

    What is the container of the JScrollPane, what is the
    layout used there ?.bingo, thats exactly my answer too.. Dont use a layout if you need the screen to be set up a certain way, just use setBounds on all the components in you container.. ya, you have to specify a bunch of x/y coordinates and component sizes, but you wouldn't be having this problem if you didn't have a layout..
    If/after your layout really IS null, then use scrollpane.setBounds(x,y,l,w) to set position and size..
    doug

  • How do I separate the content of two iTunes accounts on one PC running Windows 7?

    Hello.  I have a dilemma that has been going on for years and am hopeful that someone can outdo the staff at the Apple Store Genius Bar who, after trying multiple times, could not solve this problem. This is a doozie, so get comfortable...
    My wife and I have two separate iTunes accounts.  For clarity, this is two separate iTunes store accounts, where we each can log in with a separate e-mail address and password. Years ago, she had her own laptop from which she accessed iTunes and synced her iPhone without any issues.  I used another laptop to sync my iPhone, and all was well until the hard drive on my wife's laptop crashed.
    After that, my wife logged into iTunes on my laptop and connected her iPhone to my laptop to sync up, but we found that all of the apps and data on her iPhone synced to my iTunes account.  When I connected my iPhone to the laptop to sync up, all of the content of her iPhone synced to my iPhone. Also, when she connected to the laptop and synced her iPhone, all of my content synced to her phone. So, she stopped connecting her iPhone to the laptop because we were not able to find a way to separate my content from her content when we sync our phones.
    To make it more complicated, any app that we both run on our iPhone (e.g. Facebook, Yelp, etc.) is somehow "registered" under my account on her iPhone.  So, if any apps that we both use have an updated version, she is prompted to first enter her iTunes password to authorize the download for apps that only she runs, and then for my password to authorize apps that we both run. In other words, her iPhone is somehow permanently linked to my iTunes account.
    Now, to make this even more interesting, let me add another level of despair.  When iOS 5 was released in 2011, we tried to update her iPhone by installing the new OS but the OS crashed during the install.  All of the apps that she had installed on her phone, including new contacts, were lost because she had not synced to the laptop for some time. When the iPhone was restored and iOS5 was installed at the Apple Store, we learned that all contacts and pictures stored there were lost.  Fortunately the apps that she purchased were saved because they were still stored on her iTunes account, but still are only accessible through my iTunes account on the laptop since all of the content is merged, as mentioned above. Also, when we restored them, she got all apps (mine and hers) so she had to manually delete mine which took a lot of time.  So, consequently she is still running iOS 5 because we don't want to deal with the hassle of losing any data or having to manually delete my apps from her iPhone.
    So, I am extremely hopeful that someone can demonstrate some intellectual "heavy lifting" and can help us to answer the following questions:
    1) How can we set up iTunes so that our content is separated rather than stored completely on my iTunes account?
    2) How can we modify the settings in iTunes and/or iPhone so that we will only access our own content upon connecting to the laptop? (Note: I realize that iCloud makes it unnecessary to sync via USB but occasionally use the computer to charge my iPhone and it syncs automatically)
    3) How can we modify the settings on her iPhone so that it does not recognize mutual apps as "my" apps and prompt her to enter my iTunes password to update them when a new release is available?
    4) If she were to install the current version of iOS, how can we ensure that her data will not be lost if the software crashes again?
    Whoever can figure this out gets to brag about being the coolest person in the world, at least in my book. Thanks in advance.

    Look here.
    http://support.apple.com/kb/index?page=answerlink&url=http%3A%2F%2Fsupport.apple .com%2Fkb%2FHT1495&answerid=16777216&src=support_site.home.search

  • How to read the content in one node of XML in Java? Pls help

    My dear brothers,
    I am a newbie of XML, I have a exercise which is creating a Tree View from XML file. But the trouble is I do not know how to read the content in one node of XML file. I decide to use the algorithm as following:
    1. Create a GUI form which gives the ability for user to choose a XML file (ok)
    2. Load XML and return the file (ok)
    3. Read the file from node to node to create the node in Tree View (?!)
    Please help me, and if you are enough kind, please give me an small example to easy understand. Thanks in advance.
    Hoang Yen Binh

    I hope this one helps you.
         <ABC Type="ProductBased" ProdName="One" Location="India">
              <CEO>Raj</CEO>
              <Finance>Vikram</Finance>
              <HR>Karthik</HR>
              <Technical>Satish</Technical>
         </ABC>
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.Attr;
    import org.w3c.dom.NodeList;
    import org.w3c.dom.Node;
    import org.w3c.dom.DOMException;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    import java.io.File;
    import java.io.IOException;
    public class XmlReading {
         Document doc;
         Element element;
         public static void main(String[] args) throws Exception{
              XmlReading xr = new XmlReading();
              xr.getXmlParser(args);
         public void getXmlParser(String[] args) {
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   if(args.length != 1) {
                        System.err.println("Argument Required");
              try {
                   DocumentBuilder builder = factory.newDocumentBuilder();
                   doc = builder.parse(new File(args[0]));
              }catch(ParserConfigurationException e1) {
              }catch(SAXException e2) {
              }catch(IOException e3) {
              getAttributes();
         public void getAttributes() {
              // Retrive the entire Document from the Dom Tree
              element = doc.getDocumentElement();
    //          System.out.println(element);
              NamedNodeMap attrs = element.getAttributes();
              // Get number of attributes in the element
         int numAttrs = attrs.getLength();
         // Process each attribute
              for (int i=0; i<numAttrs; i++) {
                   Node node = attrs.item(i);
                   // Get attribute name and value
                   String attrName = node.getNodeName();
                   String attrValue = node.getNodeValue();
                   System.out.println(attrName + ": " + attrValue);
              String s1 = element.getTagName();
              System.out.println(s1);
              // To get all the elements in a DOM Tree
              NodeList nl1 = element.getElementsByTagName("*");
              int i2 = nl1.getLength();
              System.out.println(i2);
              for(int i=0; i<i2; i++) {
                   System.out.println(nl1.item(i) + "\n");
    }

  • How can I print out the contents of my hardrive

    I have a hardrive with about 200 video clips and need to print the titles for cross refrerencing. I was just going to "grab" screenshots but this will take about ten sheets of paper. How can I print out a list of all the files on the drive?

    I tried this Finder drag method & discovered that it is very important to set the blank TextEdit document to plain text before the drag (from the format menu or with Cmd-shift-t). If you don't, TextEdit attempts to load the content of the files!
    Once I discovered this, I tried the method with Find (Cmd-F) results & it works for that, too. This means that by choosing the right combination of search location(s) & search criteria, you can extend the method to filter the list to just about any files you want, which could be very handy.
    For instance, set the "Kind" criteria to "QuickTime Movie" & location to "Computer" & you get a list of every QT movie. Or set the search location to the folder containing the movies of interest & you get all of them, including ones in subfolders. You could also use the 'date created' or other search criteria to filter the list to a specific subset of movies (or whatever).
    If you need to do this often, you could create one or more 'Smart Folders' with the criteria preloaded for each search.
    The only drawback I see for either Finder based method is the full path one. If you are getting results from just one or a few folders, Find & Replace can delete any of the path name fairly easily, but it becomes a chore if there are a lot of different ones. Some other text editor, like TexEdit Pro, that supports grep searches would be handy here, but since I'm not up to speed on grep, someone else will have to explain how to use it for this, if they want.

  • Error while updating the content in workflow

    Hi,
    I'm getting an error while updating the content in workflow thru the checkout option. i.e. contributor checks in the content - reviewer rejects the content - then contributor checks out and modifies the content as per the reviewer's remarks and while checking in the following error occurs
    Content Server Request Failed
    Unable to check in content item 'HO000128' for workflow. Unable to execute service method 'checkInUpdateRevByID'. (System Error: Runtime error: java.lang.NullPointerException
    at intradoc.server.DocServiceHandler.checkInRevByID(DocServiceHandler.java:248)
    at intradoc.server.DocServiceHandler.checkInUpdateRevByID(DocServiceHandler.java:240)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at intradoc.common.IdcMethodHolder.invokeMethod(ClassHelperUtils.java:617)
    at intradoc.common.ClassHelperUtils.executeMethodReportStatus(ClassHelperUtils.java:293)
    at intradoc.server.ServiceHandler.executeAction(ServiceHandler.java:79)
    at intradoc.server.Service.doCodeEx(Service.java:490)
    at intradoc.server.Service.doCode(Service.java:472)
    at intradoc.server.ServiceRequestImplementor.doAction(ServiceRequestImplementor.java:1360)
    at intradoc.server.Service.doAction(Service.java:452)
    at intradoc.server.ServiceRequestImplementor.doActions(ServiceRequestImplementor.java:1201)
    at intradoc.server.Service.doActions(Service.java:447)
    at intradoc.server.ServiceRequestImplementor.executeSubServiceCode(ServiceRequestImplementor.java:1071)
    at intradoc.server.Service.executeSubServiceCode(Service.java:3497)
    at intradoc.server.ServiceRequestImplementor.executeServiceEx(ServiceRequestImplementor.java:942)
    at intradoc.server.Service.executeServiceEx(Service.java:3492)
    at intradoc.server.Service.executeService(Service.java:3476)
    at intradoc.server.DocServiceHandler.determineWorkflowCheckin(DocServiceHandler.java:3833)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at intradoc.common.IdcMethodHolder.invokeMethod(ClassHelperUtils.java:617)
    at intradoc.common.ClassHelperUtils.executeMethodReportStatus(ClassHelperUtils.java:293)
    at intradoc.server.ServiceHandler.executeAction(ServiceHandler.java:79)
    at intradoc.server.Service.doCodeEx(Service.java:490)
    at intradoc.server.Service.doCode(Service.java:472)
    at intradoc.server.ServiceRequestImplementor.doAction(ServiceRequestImplementor.java:1360)
    at intradoc.server.Service.doAction(Service.java:452)
    at intradoc.server.ServiceRequestImplementor.doActions(ServiceRequestImplementor.java:1201)
    at intradoc.server.Service.doActions(Service.java:447)
    at intradoc.server.ServiceRequestImplementor.executeSubServiceCode(ServiceRequestImplementor.java:1071)
    at intradoc.server.Service.executeSubServiceCode(Service.java:3497)
    at intradoc.server.ServiceRequestImplementor.executeServiceEx(ServiceRequestImplementor.java:942)
    at intradoc.server.Service.executeServiceEx(Service.java:3492)
    at intradoc.server.Service.executeService(Service.java:3476)
    at intradoc.server.Service.doSubService(Service.java:3465)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at intradoc.common.IdcMethodHolder.invokeMethod(ClassHelperUtils.java:617)
    at intradoc.common.ClassHelperUtils.executeMethodEx(ClassHelperUtils.java:279)
    at intradoc.common.ClassHelperUtils.executeMethod(ClassHelperUtils.java:264)
    at intradoc.server.Service.doCodeEx(Service.java:507)
    at intradoc.server.Service.doCode(Service.java:472)
    at intradoc.server.ServiceRequestImplementor.doAction(ServiceRequestImplementor.java:1360)
    at intradoc.server.Service.doAction(Service.java:452)
    at intradoc.server.ServiceRequestImplementor.doActions(ServiceRequestImplementor.java:1201)
    at intradoc.server.Service.doActions(Service.java:447)
    at intradoc.server.ServiceRequestImplementor.executeActions(ServiceRequestImplementor.java:1121)
    at intradoc.server.Service.executeActions(Service.java:433)
    at intradoc.server.ServiceRequestImplementor.doRequest(ServiceRequestImplementor.java:635)
    at intradoc.server.Service.doRequest(Service.java:1707)
    at intradoc.server.ServiceManager.processCommand(ServiceManager.java:359)
    at intradoc.server.IdcServerThread.run(IdcServerThread.java:197))
    Please help to resolve.
    Thanks in advance
    Prasad

    I also get error while updating the content in workflow thru the checkout option as reviewer. i.e. contributor checks in the content - then reviewer either updates the metadata or checks out and modifies the content and while checking in the following error occurs
    Content Server Request Failed
    Unable to update the content item information for 'HO000128'.
    The content ID must be specified.
    Please help to resolve.
    Thanks in advance
    Prasad

  • Error While defining the content server

    Dear Folks,
    We are trying to define the content sever in our sever. It is required for integration of SAP with documentum. We are trying to define in below path.
    Cross-Application Components - Document Management - General data - Settings for storage systems - Maintain storage system -
    It already have DMS_C1 content repository with storage type R/3 database. We are creating a new content repository with storage type HTTP Content Server. We are giving below inputs.
    Vesion No. 0045, HTTP Server - (My machine's FQDN and port is 8080), HTTP script as - sap/bc/contentsever/300.
    After giving above inputs, if I click on test connection, I m getting error as Error in HTTP Access:IF_HTTP_CLIENT -> RECIEVE1 ICM_HTTP_CONNECTION_FAILED.
    If I define the HTTP content sever as sap-qas.vsnl.co.in (i.e. My quality servers host name) it works fine i.e. connection test goes OK. Does any one know how we can define the content server and what all steps required for the same?
    Thanks and Regards,
    Kedar

    Hi Kedar,
    YOu have to provide the details as fallows
    Storage type : HTTP content server
    Version no. : 45 (based on the content server version)
    HTTP server : <content server IP>
    Port Number of content server : 1090 (default port)
    HTTP Scrip : ContentServer/ContentServer.dll
    Once after these details you can check
    Also install the DBM gui in your local PC and add this content servers database (if the content server is on MAX DB) then you need to star it from the console or else use the command to start it once after the installation.
    /sapdb/programs/bin/dbmcli -d <SID> -u control,plmcont db_state - to check the database status
    /sapdb/programs/bin/dbmcli -d <SID> -u control,plmcont db_online - to start the database
    Thanks,
    Chaitanya

  • How to read the contents of XML file from my java code

    All,
    I created an rtf report for one of my EBS reports. Now I want to email this report to several people. Using Tim's blog I implemented the email part. I am sending emails to myself based on the USERID logic.
    However I want to email to different people other then me. My email addresses are in the XML file.
    From the java program which sends the email, how can I read the fields from XML file. If any one has done this, Please point me to the right examples.
    Please let me know if there are any exmaples/BLOG's which explain how to do this(basically read the contents of XML file in the Java program).
    Thank You,
    Padma

    Ike,
    Do you have a sample. I am searched so much in this forum for samples. I looked on SAX Parser. I did not find any samples.
    Please help me.
    Thank you for your posting.
    Padma.

Maybe you are looking for

  • App Store & Apple ID issues

    Hi everyone, Today I tried to use my TuneIn radio app. It wouldn't connect so I thought I'd delete and reinstall as I'd been experiencing buffering issues as well in the last few days. I deleted the app and went into the App Store to redownload it. T

  • I can't run example from JEE5tutorial - books

    OS- Linux NetBeans 5.5.1 ( with ant 1.7 ) ant 1.6 I tried run: ant 1.6 [root@zet books(0)]# ant create-tables Buildfile: build.xml BUILD FAILED /home/marcin/3ROK/1SEM/java1/javaeetutorial5/examples/web/books/build.xml:49: The following error occurred

  • Matching Quiz in Captivate CS4 (using images)

    Hi all, I am looking to create a quiz slide in Captivate CS4 using the matching quiz tool.  Does anyone know whether or not you can use images as a question rather than text, for example, (see below) i would have the 4 hazard signs on the left and th

  • Is there a registry booster and PC tuneup product like AVG or Uniblue that Firefox recommends for improved perfromance?

    I am having performance related issues with my PC, including issues with Firefox locking up or freezing, and was wondering if there is a product you recommend for registry cleaning and other PC performance improvements. I am looking at Uniblue and AV

  • System.OutOfMemoryException when using CrystalReport with VS 2010

    hey everybody... i am in problem from the few days... i have upgraded my "Web Report Project" that uses Crystal Report from dot net framework 3.5 to 4.0 with 32bit. I frequently encounter System.OutOfMemoryException when viewing large reports (when r