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);
}

Similar Messages

  • 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);
    }

  • JDesktop Problem plz help me urgent

    sir
    i do the following
    class mydesk extends JDesktop
    mydesk()
    //some code here but not using layered pane
    class main extends JFrame
    public static mydesk desk=new mydesk();
    main()
    //container here
    cp.add(desk);
    now i create a menu bar class and write events in this class
    then i make a internal frame class and initilize that in menu class
    now i write action performed method here
    public void actionPerformed(ActionEvent e)//in menu class
    main.desk.add(frame);//frame is the object of IntenalFrame
    The problem is that it throws a exception illegal component position
    but when i add frame object in main class it works well
    what is the problem when call in menu class
    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

    sir
    some one who is kind prson send link on rendering the table
    and how to use JTable but i am not sucessfull to draw image
    on the table.and set the background color of table column header and insert the icon on table header.
    plz guide me with sample of code
    i am very thankful to u.

    The examples at the link shown below were written over 5 years ago and have never been updated. Some examples will not compile using the latest JDK but they should give you a hint on what needs to be done:
    http://www2.gol.com/users/tame/swing/examples/SwingExamples.html
    ;o)
    V.V.

  • Migration to an asm instance. plz help me urgent

    RMAN> BACKUP AS COPY DATABASE FORMAT '+DGROUP1';
    Starting backup at 20-AUG-07
    Starting implicit crosscheck backup at 20-AUG-07
    using target database controlfile instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=328 devtype=DISK
    ORA-19501: read error on file "+DGROUP1/sravan/backupset/2007_08_03/nnsnf0_ora_asm_migration_0.260.1", blockno 1 (blocksize=512)
    ORA-17507: I/O request size is not a multiple of logical block size
    Crosschecked 7 objects
    Finished implicit crosscheck backup at 20-AUG-07
    Starting implicit crosscheck copy at 20-AUG-07
    using channel ORA_DISK_1
    ORA-19587: error occurred reading 8192 bytes at block number 1
    ORA-17507: I/O request size 8192 is not a multiple of logical block size
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of backup command at 08/20/2007 16:53:21
    ORA-19587: error occurred reading 8192 bytes at block number 1
    ORA-17507: I/O request size 8192 is not a multiple of logical block size

    > plz help me urgent
    Adjective
        * S: (adj) pressing, urgent (compelling immediate action) "too pressing to permit of longer delay";So you are saying that your problem is a lot more important than any other person's problem on this forum?
    And you're demanding a quick response from professionals that give you and others assistance here in their free time without getting a single cent compensation?
    Don't you think that this "it is urgent!" statement severely lacks manners?

  • Lsmw issue plz help its urgent

    Hi Experts ,
    i need to create a LSMW using batch input .
    but the requirement is on the basis of conditions my recording need to be changed .
    dat means
    3127POL09 3127POL09-1 CTR 3127-1003E 100 FUL
    3127POL09 3127POL09-2 WBS 3127POL01 60 FUL
    for ctr i ill have to post data in screen number 200
    and for wbs i ill have to post data in screen number 400 .
    can we put some conditions in recording in lsmw ?
    i no we can create multiple recording but how can we use them to fullfill my requirement .
    plz help its urgent
    thanx in advance

    Hi,
    Within LSMW, there is an option to write our own code wherein this code can be incorporated.
    This is in the Field Mapping Option...
    Just go to the Menu Extras->Layout
    and click on the check box Form Routines
    Global Data.
    Here you can define Global Variables and also perform your ABAP Coding.
    Regards,
    Balaji.

  • 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.

  • 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

  • My recirculating pump in sub vi simulation link doesnt work in the second iteration .It opens for maybe half a second whereas i gave the time delay for 5 secs..plz help very urgent

    Hi,
         I have attached my simulation loop.In the model attached i hav eone main pump with constant rpm which drives the 5 smaller pumps and fills the tank at the same time.As soon as the tanks reach their 90% level,the valves of the five pumps close(SP1,SP2,SP3,Sp4,Sp5).After that the recirculating pumps opens for 5 secs of the first tank.As soon as the recirculation finishes,the drain valve(SV1) for tank 1 open and the volume goes to interim storage.This happens for all the remaining tanks.
    My simulation works the first time,but when the second time the loop starts,it skips the recirculation pump even though i gave a time delay for 5 secs.Plz help ..I have attached the simulation.
    Thanks,
    Rami
    Attachments:
    Spatial Logic_2_Final.vi ‏223 KB

    Rami,
    I suspect that you have a race condition. The widespread use of local variables frequently leads to race conditions. Your subVI (Spatial Logic Sub_2.vi was not included) so I cannot run the VI. You have no way of knowing whether the subVI or the inner case structure will execute first, because there is no data dependency between them.
    I think a shift register or a few and some dataflow thinking would allow you to eliminate the inner case structure, the local variables, and, probably, most of your problems.
    Some of the SPi are indicators and some are controls. How are they used?
    The last case of the inner loop retursn to Case 1. Would case 0 be better?
    As for the second time through issue, it may be related to the Elapsed time function Auto Reset. From the help file: "Resets the start time to the value in Present (s) when the Express VI reaches the Time Target (s)." If more than 5 seconds elapses between the first time you use this and the next, it will exit immediately on the subsequent calls.
    Lynn

  • Jaxrpc compilation exception(plz Help very Urgent Plz)

    Hello there....
    while deploying a simple webservice using deploytool i m getting this error while the application that is being deployed is not even using ejbs....
    i m trying to compile the example given on the forum by Qusay H. Mahmoud, so plz help me to get out from this......
    Thank u ....alll
    distribute: C:\Sun\AppServer\apps\Add.war
    deployment started : 0%
    Deploying application in domain failed; Error while running ejbc -- Fatal Error from EJB Compiler -- jaxrpc compilation exception
    ; requested operation cannot be completed
    !!! Operation Failed !!!
    !!! With The Following Failure Messages !!!
    Deploying application in domain failed; Error while running ejbc -- Fatal Error from EJB Compiler -- jaxrpc compilation exception
    ; requested operation cannot be completed
    Error while running ejbc -- Fatal Error from EJB Compiler -- jaxrpc compilation exception
    [Completed (time=24.0sec, status=13)]
    **********************************************************************

    I had a similar problem with Sun App Server.If you can check the domain/log/Server.log.It explains a valid endpoint address is missing in the deployment.To do this open the deployment tool and click the Implementation class in the tree(Bean Shaped).
    You can see a endpoint tab within which you need to configure the Endpoint address.
    The deployment went fine after this.
    Good Luck !!!

  • Plz help me URGENT

    hi abapers. i want solution for the below task .
    "The Create screen will allow user to enter Sales Organization, Distribution Channel, and Customer at the Header Level. Mandatory fields include Sales Organization, Distribution Channel, Customer, Material Number, Plant, and Valid On and Valid To Dates. Icons for Select All / Deselect All, Delete an Copy entries need to be provided. "
    please help me out in saving the above mentioned data to a z-table.
    And also i want transaction code for "create slap/ship record".
    please kindly help me ASAP. thanks in advance.
    Regards,
    Sindhu

    this is the problem i think u can understand..................
    In bean file,
    i will select 5 records from database.Then i will return the result set to first jsp page.
    In first jsp page,
    i will have two text box with one button.I will show first two fields in two text box.If i click that button it should goto next jsp page.
    In second jsp page,
    I will have three text box with one button.I will show another three fields in three text box.If i click that button it should goto first jsp page with next record(only if any records r there)..
    Plz help me ya ...I am struck with that.........

  • Problem PLZ Help me

    Hi Guys,
    I have a problem to make a developer application Client/Server.
    When i install forms Runtime on the Client`s computer and i open the application, i get the error that he can`t find the menu and the libraries.
    The menu path is for example on my computer F:\s3\Salesmenu
    But on the client it can be a different path an then he can`t find the menu.
    Now the properties for the main form are:
    Menu module f:\s3\Salesmenu
    Initial menu Salemenu
    Does anyone know how to fix this problem for example:
    1) by let the program search for the menu.
    2) .....
    Plz Help
    Vincent

    set your FORMS60_PATH on the client to Formspath;libpath;menupath so it looks in every dir named in the path.

  • Big Problem, PLZ HELP

    So, when i click on the itunes shortcut, which has the same icon as the Apple Software Updater, I get a box that says that iTunes has encountered a problem and needs to close. We are sorry for the inconvenience. I hit send once and sent the error report, and then restarted my computer to see if that would help. It didnt, so, now i cant access itunes this is a major problem cause i have all my songs on this computer. I also tried to plug in my ipod and see if that would make it load.
    I installed iTunes 7.0 on my laptop, the exact same way, and i works on my laptop, but not on my computer.
    PLZ HELP ME

    ok this is what i did when that happened to me. i uninstalled quicktime then went here: http://www.apple.com/quicktime/win.html and reinstalled the latest version :0)

  • Nokia n79 problem Plz Help!

    Hello!My nokia just stuck,or hang in(i dont now english good) but i cant do enything.Evry button just dont work only at start when i write my pi(and somethimes then too).Works only power button.Its weard.Plz help.Somethimes a whole day are no problems somhetimes a whol day.

    hey ivee n everyone else .. i'm facing the same problem.. n i need to fix this problem myself..
    my n79 gets hang constantly nowadays.. i've used this phone for 1 year plus now so warranty's no more..... none of the buttons on the keypad works when it gets hang.. onli the power button is functioning.. now it's gettin worse .. it even hangs before i insert my pincode... i cant sms, call , or anything.. it hangs after i pressed a few buttons..
    so ivee u've fixed ur n79 youself right..? umm.. can u explain to me wat a smallboard is? is that the board at the lower part of the keypad where u can see buttons underneath the white layer? and is that board expensive?
    pls reply asap anyone.. urgent

  • N79 hanging problem plz help....

    while unlocking the keypad of my n79 sometimes the phone gets hanged then i have to take the battery out and then again switch on the phone........plz help me how to get rid of this problem???

    I have also same problem with my Nokia N79, I just cancelled sensor for automatic themes from cover. Just open back cover & stick some paper or plastic cello tape on four hole marks of covers wich r sensor for automatic themes to change colour of back cover same as theme colour. From 2 days I feel my mobile working fine without hanging ! so try it, all the best.

Maybe you are looking for

  • LiveCache - LC10 message - Index issue

    hi, LiveCache - LC10, - Problem Analysis ->Performance -> Database Analyser -> bottleneck report The message read as follows: LiveCache- Bottle-neck messages: 2 tables contain > 1.000.000 records but only 20.000 rows will be sampled for statistics. T

  • Travel in France...for real, people

    I want to take my US-bought MacBook Pro, use the World Travel Kit, and plug into a France outlet. Some people swear the MBP does this without a converter or transformer and some claim that certain foreign voltages fry the machine. Really now this is

  • In Which Table  I Will get Reference Document for MIGO Transaction

    Hai Experts In Which Table  I Will get Reference Document for MIGO Transaction Regards Jagadish

  • How to appeal a podcast rejection? Please help

    Hello to all. I recently submitted a podcast to the iTunes directory. It was rejected. here is the note I got from them. http://tinypaste.com/79144f8f I clicked the specks link and it all looked good. In fact I have submitted many podcasts of this na

  • Trying to reduce size of movies in iPhoto

    I'm trying to free up space on my Macbook air. I have 135GB of videos in iPhoto that have been shot on my iPhone over the years. I would like to be able to edit many of those videos so I can reduce their file size. I would be keeping it very simple a