Javax.xml.stream import problem???? plz help

hi, i am looking into using stax to write to xml, however i believe i need some classes contained within javax.xml.stream.*; and this is not contained within j2se docs i know, i think it comes with the web services.
what i wanted to know is as i am using netbeans what is the best way for me to use these packages as i still need the current ones contained within j2se for the rest of my app
thanks
Danny =)

do i have to download another jre or can it be done using the one i currently have, j2se 1.9

Similar Messages

  • Javax.xml.stream.XMLInputFactory problems with &

    Hi all
    I am using javax.xml.stream.XMLInputFactory to create an XMLStreamReader, which reads XML in from a database.
    The problem is that when it encounters & entities, it is replacing them simply with &. When I then go to transform the XML with an XSL stylesheet, it fails with a parser error due to the presence of unescaped & characters.
    Looking at the API documentation, I thought that setting the property javax.xml.stream.isReplacingEntityReferences to false would solve the problem, but it isn't. The line of code I am using is as follows: -
    inputFactory.setProperty("javax.xml.stream.isReplacingEntityReferences", new Boolean(false));
    Any further ideas as to what I am doing wrong or what else I should be doing?
    Many thanks for reading and considering my post.
    Kind Regards
    Jon

    Thanks for your continued posts guys...
    Quote from DrClap: "So if you consider this to be a problem, you are most likely misunderstanding. Or is there a reason why you feel you have to know how the text was represented in the document it came from?"
    Right, just to clarify, this is what I'm trying to do...
    1. XML, complete with properly escaped characters (&, etc) is sitting in the database.
    2. Next, I am attempting to read the XML into memory character for character via an XMLInputStream and so I still want &, etc, not just &.
    3. Finally, I apply stylesheet to XML Now I do want the parser to decode the & into &. The problem is that it has already been done in 2 (above) so the parser in 3 falls over.
    Thanks for pointing out that javax.xml.stream.XMLInputFactory is not a standard class DrClap - looks like it's back to the drawing board for me!!
    Thanks
    Jon

  • Xml photogallery description problem plz help

    hai to all
    i am working on xml photogallery in flash mx 2004
    here everything is working fine the thumbs, main images ok
    now what i want is when i click on the thumbs the desc for
    pics should be displayed in desc box which is on top layer.
    heregallery is gallery.xml which is in /gallery/gallery.xml
    here is the code:-
    pic_mc._visible = false;
    my_xml = new XML();
    my_xml.ignoreWhite = true;
    my_xml.load("gallery/gallery.xml.xml");
    my_xml.onLoad = function() {
    rootElement = my_xml.firstChild;
    children = rootElement.firstChild.childNodes;
    //adding the main image node
    mainImageNode = rootElement.childNodes[1].childNodes;
    trace("mainImageNode="+mainImageNode);
    descNode = rootElement.childNodes[2].childNodes;
    trace(desc);
    hspace = my_xml.firstChild.attributes.hspace;
    //trace("hspace="+hspace);
    vspace = my_xml.firstChild.attributes.vspace;
    //trace("vspace="+vspace);
    nofimagesperrow =
    my_xml.firstChild.firstChild.attributes.nofimagesperrow;
    //trace(nofimagesperrow);
    nofimagespercol =
    my_xml.firstChild.firstChild.attributes.nofimagespercol;
    //trace(nofimagespercol);
    startx = my_xml.firstChild.firstChild.attributes.starty;
    //trace("startx"=+startx);
    starty = my_xml.firstChild.firstChild.attributes.starty;
    //trace("starty"=+starty);
    m = nofimagesperrow*nofimagespercol;
    //trace(m);
    duplicateMovie();
    function duplicateMovie() {
    l = children.length;
    for (var i = 0; i<l; i++) {
    pic_mc.duplicateMovieClip("pic_"+i, i*100);
    if (i<nofimagesperrow && i<nofimagespercol) {
    setProperty("pic_"+i, _x, i*hspace+10);
    setProperty("pic_"+i, _y, starty);
    if (i>=nofimagesperrow && i>=nofimagespercol) {
    setProperty("pic_"+i, _x, i*hspace-400+10);
    setProperty("pic_"+i, _y, vspace-starty);
    if (i>=nofimagesperrow*2 &&
    i>=nofimagespercol*2) {
    setProperty("pic_"+i, _x, i*hspace-800+10);
    setProperty("pic_"+i, _y, vspace*2-starty*3);
    this["pic_"+i].external_mc.loadMovie(children
    .attributes.thumb);
    this["pic_"+i].external_mc._alpha = 0;
    trace("mainImageNode"+i+mainImageNode);
    this["pic_"+i].image = mainImageNode
    .attributes.main;
    var text1:Array = new Array();
    text1 = descNode
    .attributes.desc;
    trace(text1);
    this.onEnterFrame = function() {
    for (var i = 0; i<children.length; i++) {
    if (this["pic_"+i].external_mc._alpha<100) {
    this["pic_"+i].external_mc._alpha += 5;
    if (this["pic_"+i].external_mc._alpha>100) {
    this["pic_"+i].external_mc._alpha = 100;
    delete this.onEnterFrame;
    this["pic_"+i].onPress = function() {
    //getting the custom proprty, which is imageID
    var imageToLoad:String = this.image;
    trace(imageToLoad);
    _root.holder_mc.loadMovie(imageToLoad);
    _root.holder_mc._xscale = 65;
    _root.holder_mc._yscale = 65;
    _root.holder_mc._x = 440;
    _root.holder_mc._y = 38;
    _root.desc_txt.text = text
    ;---here i am getting error. any corrections plzzzzz .. it is
    displaying undefined in the textbox which is dynamic one its var
    and instance is desc_text
    trace("="+desc_txt);
    here is xml file :-
    <?xml version="1.0" encoding="UTF-8" ?>
    - <photo >
    - <thumb nofimagesperrow="4" nofimagespercol="4"
    startx="10" starty="10">
    <pic thumb="humb/pic1.jpg" main="main/pic1.jpg"
    desc="this is 1 pic" />
    <pic thumb="thumb/pic2.jpg" main="main/pic2.jpg"
    desc="this is 2 pic" />
    <pic thumb="thumb/pic3.jpg" main="main/pic3.jpg"
    desc="this is 3 pic" />
    <pic thumb="thumb/pic4.jpg" main="main/pic4.jpg"
    desc="this is 4 pic" />
    <pic thumb="thumb/pic5.jpg" main=main/pic5.jpg"
    desc="this is 5 pic" />
    </thumb>
    </photo>

    i could not see anywhere "text",
    i think you are using "text1".
    just try this...
    _root.desc_txt.text = text1

  • Problem in javax.xml.stream package

    i am getting some trouble while using the import statement for following package:-
    import javax.xml.stream.*;
    I have j2sdk1.4.2 installed in my system. I am using NetBeans 3.6 IDE.
    Should i copy some jars in order to resolve this issue. You can send me the steps at:- [email protected]
    Please help me.
    Regards
    Sks

    Have not been able to find anything in the bug database.
    I am alittle worried that the StAX - 1.0.1 (http://stax.codehaus.org) has a method with the same signature that does something very different.

  • Javax.xml.stream.XMLStreamException throws when present '&' character

    Hi
    I am writing a code using stax parser. But recently I got an error when "&" or "&" present in the xml document.
    This is the error I am getting
    javax.xml.stream.XMLStreamException: ParseError at [row,col]:[30,30]
    Message: The reference to entity "name" must end with the ';' delimiter.This is my xml
    <url>  http://url?id=1&name=aaa  </url>  This is my code
    XMLInputFactory xmlInputFactory =  XMLInputFactory.newInstance();
                xmlInputFactory.setProperty(
                        XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES,
                        Boolean.TRUE);
                xmlInputFactory.setProperty(
                        XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES,
                        Boolean.FALSE);
                xmlInputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
    String xmlSource;
    XMLStreamReader reader = xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(xmlSource.getBytes("UTF-8")));
    while (reader.hasNext())
      reader.next(); // error throws in this line
    }Can someone please help me.

    Sorry for the late reply. I was waited with the intention because this was my fault.
    Yes I am using & amp;
    But the problem return persist.
    Now I have identified the problem.
    The problem was I am using same xml for process multiple time.
    First time it does not fail.
    But the second time I am assigning the processed xml to a string and use this string as a input to the second xml processing.
    This time it automatically replace all & amp; with & .
    Now it fails.
    To eliminate this What I have done is when reading text and attribute values I am do a simple string replacing process.
    protected String encode2XML(String source)
            String src = source;
            if (src != null)
                src = src.replace("&", "&");
                src = src.replace("<", "<");
                src = src.replace(">", ">");
                src = src.replace("\"", """);
                src = src.replace("\'", "&#039;");
                return src;
            else
                return "";
        }

  • Audio Clip problem plz help..

    There is some problem with my code. It is actually for simply playing a wav file.
    It gives errors on two lines....
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    public class MediaPlayerDemo extends JFrame
         AudioClip clip; //Error Here
         public MediaPlayerDemo(String title)
              super(title);
         clip = getAudioClip(getCodeBase(),"access.wav"); //Error Here
         clip.loop();
         public static void main(String args[])
              MediaPlayerDemo m = new MediaPlayerDemo("Title");
              m.setSize(400,400);
              m.setVisible(true);
    }

    "Audio Clip problem plz help"
    You have to learn to help yourself.
    Have you done anything to try to fix the errors yourself?
    AudioClip clip; //Error Here
    the error generated here is self-explanatory.
    if you can't fix this, you should get a good book on java basics and start again.
    the other error is also easy to fix.

  • JAXP 1.4 in JDK 1.5? javax.xml.stream.FactoryFinder$ConfigurationError

    hello,
    i'm forced to develop in jdk 1.5 and need to use package javax.xml.stream (StAX), which is not included in jaxp1.3 (in jdk 5), so there is a need to somehow integrate jaxp 1.4 to jdk5.
    first thing i've tried was getting jaxp 1.4 src and include a buildpath to my project to it. problem is, that javax.xml.stream.XMLOutputFactory.newInstance() throws exception javax.xml.stream.FactoryFinder$ConfigurationError: Provider com.sun.xml.internal.stream.XMLOutputFactoryImpl not found
    thanks in advance

    problem solved

  • Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/stream

    I am trying to develop a web service client for amazon webservice.but i am getting this error while running the app. Can anyone please help me. I have installed the JWSDP and but could not understand why i have to locate all the jar files in the classpath?Please help.
    ===== error=========================================
    C:\abr\classes>java -classpath c:\abr\test.jar;C:\abr\jaxrpc-api.jar;C:\abr\jaxrpc-impl.jar;C:\abr\jaxrpc-spi.jar;c:\abr\classes\amazon.jar;C:\abr\mail.jar;C:\a
    br\saaj-api.jar;C:\abr\activation.jar;c:\abr\FastInfoset.jar;%classpath% Client
    [b]Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/stream/XMLS
    treamWriter
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at com.sun.xml.rpc.client.StreamingSender._writeRequest(StreamingSender.
    java:672)
    at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:87)
    at amazon.AmazonSearchPort_Stub.authorSearchRequest(AmazonSearchPort_Stu
    b.java:988)
    at Client.main(Client.java:21)

    I'm assuming you're using JWSDP 1.6 as I see Fastinfoset.jar in your list. You are missing some jar files in your classpath there. The best way to know what you need is to look at the release notes for JWSDP 1.6. Since you're building a web serivce start with the table in there and lookup JAX-RPC. It'll show you what jar files are needed and what other libraries are needed. Now depending on what you're doing you don't really need all those.
    For sure you're missing jsr173_api.jar which is where I believe that class you need is located. This is in the JWSDP_1_6\sjsxp\lib directory. You will probably need the other jar thats in there too. Best bet is to follow the dependancy chart in the release notes.
    This should get you going.
    Ryan

  • Javax.xml.stream is not found

    I'm running eclipse on a mac using java 6.
    And for some reason eclipse cant find javax.xml.stream
    does anyone know where i can download this file?
    and or how I can tell eclipse where to find it?
    Thanks!

    alan_mehio wrote:
    Hi,
    You definitely will get more help if you post your question with eclipse related forumUnless someone points out that javax.xml.stream simply isn't part of J2SE. You can download it here

  • Classpath problem plz help me

    hi!
    i am unable to run my RMI server program .Name of My server class is SumServer.java,it implements SumInterface.java all the files(.class,.java and stub) are at location c:\javaprog\rmi\sum.
    I have not put them in any package.
    value of classpath is
    classpath=c:\jdk1.4\lib;.;c:\javaprog\rmi\sum
    i go in sum folder and run the program
    c:\javaprog\rmi\sum > SumServer
    it gives me following exception.plz help me out.
    Thx in advance.
    Exception occur.Unable to register serverjava.rmi.ServerException: RemoteExcepti
    on occurred in server thread; nested exception is:
    java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
    tion is:
    java.lang.ClassNotFoundException: SumServer_Stub

    Deepa lakshmi wrote:
    Hi,
    Am new to weblogic.
    Am using the tools are,
    Weblogic8.1 version
    MySql5.0,mysql-connector-java-3.1.12-bin.jar file
    While test configuration of connection pooling am getting the error is "JDBC Driver is not on the classpath".
    How can i solve this problem
    plz help me
    regards
    DeepaEdit the start-weblogic script. Near the bottom, you will see
    lines that create a CLASSPATH for the weblogic server. Add a
    script line that adds the mysql driver to the classpath there.
    Joe

  • Very important post. plz help!!! video problems. cant find related posts.

    okay so i bought the new ipod video 30 gig, like a few days ago. i just bought two episodes of Lost from season 2, the first two episodes of the season. they play fine on my computer on itunes, they wont play on my ipod. this is what happens: i click on the episode, it pauses for 3 seconds and than a blue/purple screen comes up for like 6 seconds and than it goes back tothe menu with the two episodes.
    i also bought the new CD from Anti-Flag today as well from itunes, they play fine on itunes but on my ipod it skips from song to next song without playing it but when i plug it in my computer it says it played X number of times.
    plz help me.

    And no purchased content works?
    Try this...
    Part 1:
    1. Navigate to \iPod_Control\iTunes on the iPod in Windows Explorer. You may have to turn on Show Hidden Files and folders. To do this, go to Tools-->Folder Options, click the view tab, click the bubble to show hidden files and folders, click Apply, and click OK. Look for the presence there of a file named iEKInfo. Is it there? If so, make a copy of this onto your computer somewhere. While there, make a copy of iTunesDB also. Don't delete these copies.
    2. Create a new, administrator user in Windows . (Start-->control panel-->user accounts-->create a new account)
    3. Log out of the current user.
    4. Log into the new user.
    5. Restore the iPod as documented in this article:
    http://docs.info.apple.com/article.html?artnum=60983.
    6. Open iTunes.
    7. Set the Music sync preference in iTunes for the iPod to Manual mode.
    8. Download the free single of the week from the iTunes Music Store.
    9. Verify that the song plays in iTunes.
    10. Drag only this song to the iPod.
    11. Eject the iPod from iTunes.
    12. Disconnect the iPod from the computer.
    Does the song play?
    If the iPod is able to play this song, follow these steps:
    Part 2:
    1. Log out of the new user.
    2. Log back into the original (affected) user.
    3. Reconnect the iPod to the computer.
    4. Drag some of the older purchased content (that would not play before) to the iPod.
    5. Eject the iPod from iTunes.
    6. Disconnect the iPod from the computer.
    Does the affected content play?
    Is the iPod still having the same issue? Try these possible solutions:
    Part 3:
    * Delete the SC Info.sidb file as documented in http://docs.info.apple.com/article.html?artnum=302386.
    * If the issue persists, recreate the iTunes Music Library as described in http://docs.info.apple.com/article.html?artnum=93313.
    Does the music play?
    Please post back if this works or not.
    btabz

  • Import problems please help

    Hello,
    Really thick intern looking for help would be eternally gratefull.I'm an Irish student in France working on a webservices project
    >
    so my current problem is as follows:
    >
    I'm trying to run a simple web service so I've sucessfully downloaded
    tomact and apache axis and they're installed and working well. I've
    deployed a webserice jws?wsdl all well and good but I'cant get the client
    to work this is the code I have so far, problem with the imports please help...
    Using linux mandrake 9.0
    and the free version of JBuilder8 from borlands site
    tomcat4.0.6
    axis-1_1RC2
    ������������������������������������������������������������������
    import org.apache.axis.client.Service;
    import org.apache.axis.utils.Options;
    import javax.xml.rpc.namespace.QName;
    import java.net.*;
    public class HelloWorldClient
    public static void main(String args []) throws Exception
    Service service = new Service();
    Call call = (Call)service.createCall();
    String endpoint = "http://localhost:8080/axis/HelloWorld.jws";
    call.setTargetEndpointAddress(new java.net.URL(endpoint));
    call.setPoerationName(new QName("getHelloWorld"));
    String output = (String)call.invoke(new object[]{});
    System.out.println("Got result : " + output);
    }It's recognising the imports and is giving me the following error message:
    Sorry about the French
    "HelloWorldClient.java" : Erreur No : 302 : classe
    org.apache.axis.client.Service non accessible ; java.io.IOException:
    classe
    introuvable : classe org.apache.axis.client.Service en ligne 3, colonne
    31
    "HelloWorldClient.java" : Erreur No : 302 : classe
    org.apache.axis.utils.Options non accessible ; java.io.IOException: classe
    introuvable : classe org.apache.axis.utils.Options en ligne 4, colonne 30
    "HelloWorldClient.java" : Erreur No : 302 : classe
    javax.xml.rpc.namespace.QName non accessible ; java.io.IOException: classe
    introuvable : classe javax.xml.rpc.namespace.QName en ligne 5, colonne 32
    "HelloWorldClient.java" : Erreur No : 300 : classe Service introuvable
    dans classe HelloWorldClient en ligne 17, colonne 5
    "HelloWorldClient.java" : Erreur No : 300 : classe Service introuvable
    dans classe HelloWorldClient en ligne 17, colonne 27
    "HelloWorldClient.java" : Erreur No : 300 : classe Call introuvable dans
    classe HelloWorldClient en ligne 18, colonne 5
    "HelloWorldClient.java" : Erreur No : 300 : classe Call introuvable dans
    classe HelloWorldClient en ligne 18, colonne 18
    "HelloWorldClient.java" : Erreur No : 300 : classe QName introuvable dans
    classe HelloWorldClient en ligne 22, colonne 31"HelloWorldClient.java" : Erreur No : 300 : classe object introuvable
    dans
    classe HelloWorldClient en ligne 23, colonne 45
    I'm a real novice to computing so I'd be gratefull if you could help me and give me the most simplistic instructions possible
    Thanks for reading this at least!

    You may want to check to see if you have your class path set properly.

  • JTable problem plz help me urgent

    sir
    i carefully read the swing tutorial for JTable for the purpose
    of rendring specially header rendring.
    first u see the code
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.border.*;
    import java.util.*;
    import javax.swing.table.*;
    public class Myscrollpane extends JScrollPane
    ImageIcon icon=new ImageIcon("images/beach1.jpg");
    Image img;
    int w,h,wi,hi;
    TableColumn column = null;
    /*Vector cols=new Vector();
    cols.addElement("Company Code");
    cols.addElement("Company Name");
    String[] names = {"Company Code", "Company Name"};
    DefaultTableModel model=new DefaultTableModel(names,0);
    JTable table=new JTable(model);
    LogoViewport vp;//custom class extends with JViewport
    Myscrollpane(int width,int height)
    vp= new LogoViewport(width,height);
    setOpaque(false);
    setMinimumSize(new Dimension(width,height));
    setPreferredSize(new Dimension(width,height));
    setSize(350,125);
    ///////////here r the table methods to control /////////////////////
    table.setPreferredScrollableViewportSize(new Dimension(width,height));
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF );
    table.getTableHeader().setReorderingAllowed(false);
    table.setBackground(new Color(245,235,237));
    table.setForeground(Color.black);
    table.setOpaque(true);
    table.setEnabled(false);
    table.setFont(new java.awt.Font("Dialog", Font.ITALIC, 12));
    table.setGridColor(Color.pink);
    table.setRowHeight(22);
    table.setSelectionBackground(Color.lightGray);
    DefaultTableCellRenderer renderer=new DefaultTableCellRenderer();
    TableColumn code=table.getColumnModel().getColumn(0);
    renderer.setBackground(Color.red);
    ????//if i use the setIcon method then the data comes from the database
    ????//is not shown because the icon paint above the data.
    code.setCellRenderer(renderer);
    TableCellRenderer headerRenderer = table.getTableHeade.().getDefaultRenderer();
    TableColumn column1=null;
    ???//i use this to change the color of header column but it is not work
    for (int j = 0; j < 2; j++) {
    column1 = table.getColumnModel().getColumn(j);
    Component comp = headerRenderer.getTableCellRendererComponent(
    null, column1.getHeaderValue(),
    false, false, 0, 0);
    comp.setBackground(Color.red);
    ???//if i use following it also not work
    TableCellRenderer headerRenderer = table.getTableHeader().
    getDefaultRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer)headerRenderer).setBackground(Color.red);}
    for (int i = 0; i <=1; i++)
    column = table.getColumnModel().getColumn(i);
    if (i == 0) {
    column.setPreferredWidth(100);
    else
    column.setPreferredWidth(225);
    vp.setView(table);
    this.setViewport(vp);
    plz help me with the code.
    i also want to draw the image on the table with the use of DefaultTabel
    Model and data set from the data base.Initally no row is shown.
    plz help me
    shown(???) are the quesstion which i am unable to solve.
    thanks in advance.

    Formatting the code makes it easier to read, which means more people may attempt to read your code and answer your questions. Click on the "Help" link at the top of the page.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TableHeader extends JFrame
        public TableHeader()
            JTable table = new JTable(5, 5);
            table.setPreferredScrollableViewportSize(table.getPreferredSize());
            JScrollPane scrollPane = new JScrollPane( table );
            getContentPane().add( scrollPane );
            table.getTableHeader().setBackground( Color.red );
        public static void main(String[] args)
            TableHeader frame = new TableHeader();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.pack();
            frame.setLocationRelativeTo( null );
            frame.setVisible(true);
    }

  • JTable problem plz help me urgent withDefault TableModel

    sir
    i carefully read the swing tutorial for JTable for the purpose
    of rendring specially header rendring.
    first u see the code
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.border.*;
    import java.util.*;
    import javax.swing.table.*;
    public class Myscrollpane extends JScrollPane {
    ImageIcon icon=new ImageIcon("images/beach1.jpg");
    Image img;
    int w,h,wi,hi;
    TableColumn column = null;
    String[] names = {"Company Code", "Company Name"};
    DefaultTableModel model=new DefaultTableModel(names,0);
    JTable table=new JTable(model);
    LogoViewport vp;//user class extends with JViewport
    Myscrollpane(int width,int height){
    vp= new LogoViewport(width,height);
    setOpaque(false);
    setMinimumSize(new Dimension(width,height));
    setPreferredSize(new Dimension(width,height));
    setSize(350,125);
    ///////////here r the table methods tocontrol /////////////////////
    table.setPreferredScrollableViewportSize(new Dimension width,height));
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF );
    table.getTableHeader().setReorderingAllowed(false);
    table.setBackground(new Color(245,235,237));
    table.setForeground(Color.black);
    table.setOpaque(true);
    table.setEnabled(false);
    table.setFont(new java.awt.Font("Dialog", Font.ITALIC, 12));
    table.setGridColor(Color.pink);
    table.setRowHeight(22);
    table.setSelectionBackground(Color.lightGray);
    DefaultTableCellRenderer renderer=new DefaultTableCellRenderer();
    TableColumn code=table.getColumnModel().getColumn(0);
    renderer.setBackground(Color.red);
    //if i use the setIcon method then the data comes from the database is
    //not shown because the icon paint above the data.Iwant to paint the
    //image on the table dynamically means as table populated the image is
    //paint on the table means no fix no of rows.How can i
    //do.
    code.setCellRenderer(renderer);
    TableCellRenderer headerRenderer = table.getTableHeade.().getDefaultRenderer();
    TableColumn column1=null;
    //i use this to change the color and paste icon of header column
    //but it is not work
    for (int j = 0; j < 2; j++) {
    column1 = table.getColumnModel().getColumn(j);
    Component comp = headerRenderer.getTableCellRendererComponent(null, column1.getHeaderValue(), false, false, 0, 0);
    comp.setBackground(Color.red);
    comp.setIcon(new ImageIcon("myimage.gif")); }
    //if i use following it also not work
    TableCellRenderer headerRenderer = table.getTableHeader().getDefaultRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {((DefaultTableCellRenderer)headerRenderer).setBackground(Color.red);} vp.setView(table);
    this.setViewport(vp);
    }plz help me with the code.
    stated as above i also want to draw the image on the table with the use of DefaultTabel
    Model and data set from the data base.Initally no row is shown.
    plz help me
    thanks in advance

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TableHeader extends JFrame
        public TableHeader()
            Object[] columnNames =
                new ImageIcon("copy16.gif"),
                "Some Text",
                new ImageIcon("add16.gif")
            //  Columns headings are cast to a String when created automatically.
            //  We want Icons, so use a special renderer and create the columns manually
            JTable table = new JTable();
            table.getTableHeader().setDefaultRenderer( new HeaderRenderer() );
            for (int i = 0; i < columnNames.length; i++)
                TableColumn newColumn = new TableColumn(i);
                newColumn.setHeaderValue( columnNames[i] );
                table.addColumn(newColumn);
            table.setPreferredScrollableViewportSize(table.getPreferredSize());
            JScrollPane scrollPane = new JScrollPane( table );
            getContentPane().add( scrollPane );
        class HeaderRenderer extends DefaultTableCellRenderer
            public Component getTableCellRendererComponent(
                JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col)
                setBorder(UIManager.getBorder("TableHeader.cellBorder"));
                setHorizontalAlignment(CENTER);
                //  color each cell
                if (col == 1)
                    setBackground( Color.yellow );
                else
                    setBackground( Color.green );
                //  display text or icon
                if (value instanceof Icon)
                    setIcon( (Icon)value );
                    setText( "" );
                else
                    setIcon( null );
                    setText((value == null) ? "" : value.toString());
                return this;
        public static void main(String[] args)
            TableHeader frame = new TableHeader();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.pack();
            frame.setLocationRelativeTo( null );
            frame.setVisible(true);
    }

  • Package Problem : Plz help

    I've make two classes named First.java and Second.java in e:\javafiles\test\vg folder
    package vg;
    public class First
              public int m = 100;
              public int n = 200;
    package vg;
    public class Second
              public static void me0()
                   System.out.println("Stupid cant u see the value of m is zero");
              public static void mgrn()
                   System.out.println("Yaar m is greater than n");
              public static void neven()
                   System.out.println("The value of n is Even");
    and a Third class
    import vg.*;
    public class Last
              public static void main(String robert[])
                   Second d = new Second();
                   First f = new First();
                   if(f.m==0)
                        d.me0();
                   if(f.m>f.n)
                        d.mgrn();
                   if((f.n%2)==0)
                        d.neven();
                   else
                        System.out.println("The value of n is Odd");
    Now the problem is that if I put the Last.java at e:\javafiles\test and compile it , it works fine but if I put the Last.java anywhere else e.g at e:\javafiles and try to compile it it does not works and gives error
    E:\JavaFiles>javac Last.java
    Last.java:1: package vg does not exist
    import vg.*;
    even if I change classapth variable as E:\javafiles\test or even E:\javafiles\test\vg
    plz help me in this regard

    You need to change where it is trying to find the 'vg' package. So, if your Last.java is in e:\javafiles, then you need to
    import test.vg.*
    e.g.
    import test.vg.*;           // Change this line
    public class Last
              public static void main(String robert[])
                   Second d = new Second();
                   First f = new First();
                   if(f.m==0)
                        d.me0();
                   if(f.m>f.n)
                        d.mgrn();
                   if((f.n%2)==0)
                        d.neven();
                   else
                        System.out.println("The value of n is Odd");
    Alan

Maybe you are looking for

  • Macbook Air second thoughts. PLEASE RESPOND.

    I just recently purchased a MBA '11 64 GB, so far I love it but I'm scared about the storage. I'm a college freshman and I'll be using it mainly for papers and maybe powerpoints and of course web browsing, twitter, facebook, and a little recreational

  • Battlefield Hardline PC Digital Download Pre-Order issues

    Seems there's a couple issues with the "Digital Download" for PC pre-order of Battlefield Hardline. First, the pre-order is not showing up as a $10 certificate promo for Gamersclub, which is should be because all versions of Battlefield Hardline are

  • Financial Reporting using BPC 5.1: A few questions

    Hello, A client of mine is doing an assessment of using BPC 5.1 as a financial report writing tool versus BI/BEx. They are not currently using BPC for either planning or consolidations but that might happen in the future. The financial data is being

  • IPhone 4 won't power up. What should I do?

    I turned my iPhone 4 off earlier tonight because the display seemed to freeze up. It has been working fine. Now it will not power up. What can I do to get the phone to power up?

  • Question: clean and use multiple System Preparation

    Hi there, I am curious if this is possible: - How to clean the system preparation once it is set up ? I mean, I can create a system preparation, but I'd like to re-create it, and I dont see any "delete" button for erase the current system prep params