Appearing the added JTable's cell JComboBox at running the Class

During the time of employing the JTable,arising the problem of how to appear the added JTable's cell JComboBox at loading the class..Can you aid me plz to resolve this bug...If u know answer,plz forward the resolution..

Sorry, I don't understand the question so I'll just point you to the Swing tutorial on "How to Use Tables" which has a working example of using a combo box in a table:
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html

Similar Messages

  • JTable with editable JComboBoxes

    For some reason once I added editable JComboBoxes to a JTable I can no longer tab among the fields in the table. If I just select a cell, I can tab to the other cells in that row, and then to proceeding rows as I reach the end of each. However if I double click the cell and enter data or select from the combobox. I no longer can tab to the next cell. At that point once I do hit tab, I am taken to the next table. Not the next cell in the row, or the next row in the current table.
    I have tried messing with a bunch of listeners, but I am not using the right listener on the right object? What listerner and object should the listener belong to? Table, model, cell editor, combobox, jpanel, jframe ? I hope this is not to vague.

    Well I am starting to think it's an implementation issue. Like I am not doing it how I should. I am basically doing
    JComboBox jcb = new JComboBox();
    jcb.setEditable(true);
    column.setCellEditor(new DefaultCellEditor(jcb));
    When I think I should be inheriting, and creating my own editor and/or renderer? Now my combobox vars are globally available in the class, so I can set and clear their contents. It does not matter that each row in the table has the same content in the combo boxes, that's basically what I want. User to be able to select an existing entry or make a new one.
    What I am trying to do is on tables have a drop down box that shows up when a user types a matching entry. If no entry matches, no popup box. If entry matches, box pops up and shows possible entries starting with what they are typing. Like code completion in IDE's like Netbeans. However I am doing this in a table. I thought a JComboBox would be a good widget to start with?

  • Image display (Image don't appear the first time?)

    Applet at: http://saladinsite.tripod.com/Project/MiniProject.htm
    Code at and Bottom: http://saladinsite.tripod.com/Project/MiniProject.java
    Hi,
    I just created my very first applet. It's a simple quiz. I'll agree it's very unefficient.. but heh.. good for first try.
    There is a lil problem I am having. Sometimes when I load the applet, the background image don't show up. Sometimes, the happy/cry images (corresponding to right/wrong answer) don't show up (check the applet to see what I am talkin about) It only happens once tho. It's strange. Take a look at the applet, you will see. Btw: It's not the downloadin of image that cuzes the bug. Same problem happens in appletviewer. If it doesn't appear the first time, the next time you go back to it, it will appear.
    My teacher has also struggled with this problem but failed. Hope you guys can help me out.
    Thanks,
    Gant
    LONG Code again:
    import java.awt.*;
    import java.applet.*;
    import java.net.*;
         public class MiniProject extends Applet implements Runnable {
              boolean flag=true;
              Image happy,cry,cartoon,test,buffer;
              Graphics bufferg;
              Thread main;
                   int x = 50;
                   int y = 50;
                   int a,b,c;
                   String str;
                   double score =0;
                   double correct = 0.0;
                   TextField txt, percent, invis;
                   String boxName[] = {"Addition (+)", "Substraction (-)","Multiplication (x)","Division (�)"};
                   CheckboxGroup checkGr = new CheckboxGroup();
                   AudioClip RedMove, Applause, BadMove, NewGame, sad;
              public void init() {
                   URL codeBase = getCodeBase();
                   happy = getImage(getCodeBase(),"happy.gif");
                   cry = getImage(getCodeBase(),"cry.gif");
                   cartoon = getImage(getCodeBase(),"cartoon.gif");
                   test = getImage(getCodeBase(),"test.gif");
                   RedMove = getAudioClip(codeBase, "RedMove.au");
                   Applause = getAudioClip(codeBase, "Applause.au");
                   BadMove = getAudioClip(codeBase, "BadMove.au");
                   NewGame = getAudioClip(codeBase, "NewGame.au");
                   sad = getAudioClip(codeBase, "sad.au");
                   invis = new TextField("",1) ;
                   invis.setVisible(false);
                   setBackground(Color.white);
                   setLayout(new BorderLayout() );
                   Panel p1 = new Panel();
                   add("South",p1);
                   p1.setBackground(Color.gray);
                   p1.add(new Button("Start") );
                   p1.add(new Button("Exit") );
                   p1.add(new Button("Help") );
                   p1.add(new Button("Credits") );
                             p1.add(new Label(" Score in (%):") );
                             percent = new TextField("",3);
                             percent.setEditable(false);
                             percent.setBackground(Color.gray);
                             p1.add(percent);
                   Panel p2 = new Panel();
                   p2.setBackground(Color.gray);
                   add("North",p2);
                   p2.add(new Label("Quiz with: ") );
              Panel p3 = new Panel();
              p3.setLayout(new FlowLayout(FlowLayout.CENTER, 25, 75));
                   txt = new TextField("", 3);
                   txt.setText("");
    txt.setEditable(false);
                   Font f = new Font("Helvetica", Font.BOLD, 36);
                   txt.setFont(f);
              p3.add(txt);
              add("East",p3);
              p3.setBackground(Color.white);
              for (int i=0; i<boxName.length; i++)
                   p2.add(new Checkbox(boxName, checkGr, false) );
              buffer=createImage(size().width,size().height);
              bufferg=buffer.getGraphics();
              startM();
         } //end init
              public void run(){
              while(main!=null){
                   try {
                   main.sleep(50);
                   catch(Exception e){}
         public void stop(){
              if(main!=null){main.stop();}
         public void startM() {
                        bufferg.setColor(Color.white);
                        bufferg.fillRect(0,0,400,400);
                        bufferg.setColor(Color.black);
                             Font f = new Font("Helvetica", Font.PLAIN, 14);
                             bufferg.setFont(f);
                             bufferg.drawImage(cartoon,0,50,this);
                        bufferg.drawString("^ Click on a Quiz above to begin!", 25,47);
                        txt.setEditable(false);
                        txt.setBackground(Color.white);
                        txt.setText("");
                        percent.setText("");
                             Font f4 = new Font("Helvetica", Font.BOLD, 28);
                             bufferg.setFont(f4);
                             bufferg.setColor(Color.red);
                             bufferg.drawString("WELCOME!",15,90);
                             bufferg.setColor(Color.black);
                             bufferg.drawString("to the Interactive",55, 155);
                             bufferg.drawString("Grade 9 Math Quiz",85, 200);
                             Font f5 = new Font("Helvetica", Font.PLAIN, 18);
                             bufferg.setFont(f5);
                             bufferg.drawString("Designed by: Wasay R.",175,360);
         public void clearM() {
              bufferg.fillRect(0,0,450,400);
         public boolean action(Event evt, Object obj) {
              if (evt.target instanceof Button) {
                   String butLabel = (String) obj;
                        if (obj.equals("Credits") ) {
                             NewGame.play();
                             URL url = getCodeBase(); // get url of the applet
                             try {
                        getAppletContext().showDocument (new URL(url+"credits.htm"));
                             } catch(MalformedURLException e) {
                             showStatus("URL not found");
              if (evt.target instanceof Button) {
                   String butLabel = (String) obj;
                        if (obj.equals("Help") ) {
                             NewGame.play();
                             URL url = getCodeBase(); // get url of the applet
                             try {
                        getAppletContext().showDocument (new URL(url+"help.htm"));
                             } catch(MalformedURLException e) {
                             showStatus("URL not found");
              if (evt.target instanceof Button) {
                   String butLabel = (String) obj;
                        if (obj.equals("Exit") ) {
                             NewGame.play();
                             URL url = getCodeBase(); // get url of the applet
                             try {
                        getAppletContext().showDocument (new URL(url+"end.htm"));
                             } catch(MalformedURLException e) {
                             showStatus("URL not found");
              if (evt.target instanceof Checkbox && flag) {
                   flag=false;
                   NewGame.play();
                   txt.setEditable(true);
                   Color c = new Color(204,204,204);
                   txt.setBackground(c);
                   bufferg.setColor(Color.white);
                   clearM();
                   handleCheckbox(evt);
                   if (evt.target instanceof Button) {
                   String butLabel = (String) obj;
                        if (obj.equals("Start") ) {
                             flag=true;
                             y=50;
                             x=50;
                             score=0;
                             correct=0;
                             startM();
              if (evt.target==txt && score<10) {
                   String find = (invis.getText() ).substring(0,1) ;
                   if (find.equals("+")) {
                             handle2();
                             paint( Create(0) );
                             txt.setText("");
                             score++;
                   else if (find.equals("-") ) {
                        handle2();
                        paint( Create(1) );
                        txt.setText("");
                        score++;
                   else if (find.equals("x") ) {
                        handle2();
                        paint( Create(2) );
                        txt.setText("");
                        score++;
                   else if (find.equals("/") ) {
                        handle2();
                        paint( Create(3) );
                        txt.setText("");
                        score++;
              if (score==10) {
                   if (correct>=5 && !(evt.target instanceof Checkbox) )
                        Applause.play();
                   else if (correct<5 && !(evt.target instanceof Checkbox) )
                        sad.play();
                   txt.setText("");
                   txt.setBackground(Color.white);
                   txt.setEditable(false);
                        bufferg.setColor(Color.white);
                        bufferg.fillRect(100,100,350,75);
                        bufferg.setColor(Color.black);
                        bufferg.drawRect(65,110,225,75);
                             Font f = new Font("Helvetica", Font.BOLD, 28);
                             bufferg.setFont(f);
                             bufferg.setColor(Color.red);
                             bufferg.drawString("Quiz Complete!", 75,143);
                             Font f2 = new Font("Helvetica", Font.PLAIN, 18);
                             bufferg.setFont(f2);
                             bufferg.setColor(Color.black);
                             bufferg.drawString( ("Your Score: " + String.valueOf( Math.round( (correct/score*100)/0.01 )*0.01 )+"%"),101,170);
                             Font f3 = new Font("Helvetica", Font.PLAIN, 14);
                             bufferg.setFont(f3);
                             bufferg.drawString("Click Start and select a Quiz at the Top to begin",19,240);
                             bufferg.drawRect(10,227,326,0);
                             bufferg.drawRect(336,38,0,189);
                             bufferg.drawRect(10,243,326,0);
                             bufferg.drawRect(10,243,0,85);
              percent.setText( String.valueOf( Math.round( (correct/score*100)/0.01 )*0.01 ) );
              repaint();
              return true;
                   private void handle2() {
                        str = invis.getText();
                             Font f = new Font("Helvetica", Font.BOLD, 14);
                             bufferg.setFont(f);
                             bufferg.drawString("Correct:",15,70);
                             bufferg.drawString("Incorrect:",4,345);
                        if ( (str.substring(0,1) ).equals("+") )
                             if (Integer.parseInt(txt.getText() )==(a+b) ) {
                                       invis.setText("+correct");
                                       x+=25;
                                       bufferg.drawImage(happy,x,50,this);
                                       correct++;
                                       RedMove.play();}
                             else {
                                       invis.setText("+wrong");
                                       y+=25;
                                       bufferg.drawImage(cry,y,325,this);
                                       BadMove.play();
                        else if ( (str.substring(0,1) ).equals("-") )
                             if (Integer.parseInt(txt.getText() )==(a-b) ) {
                                       invis.setText("-correct");
                                       x+=25;
                                       bufferg.drawImage(happy,x,50,this);
                                       correct++; RedMove.play();}
                             else {
                                       invis.setText("-wrong");
                                       y+=25;
                                       bufferg.drawImage(cry,y,325,this);
                                       BadMove.play();
                        else if ( (str.substring(0,1) ).equals("x") )
                             if (Integer.parseInt(txt.getText() )==(a*c) ) {
                                       invis.setText("xcorrect");
                                       x+=25;
                                       bufferg.drawImage(happy,x,50,this);
                                       correct++; RedMove.play();}
                             else {
                                       invis.setText("xwrong");
                                       y+=25;
                                       bufferg.drawImage(cry,y,325,this);
                                       BadMove.play();
                        else if ( (str.substring(0,1) ).equals("/") )
                             if (Integer.parseInt(txt.getText() )==(a/c) ) {
                                       invis.setText("/correct");
                                       x+=25;
                                       bufferg.drawImage(happy,x,50,this);
                                       correct++; RedMove.play();}
                             else {
                                       invis.setText("/wrong");
                                       y+=25;
                                       bufferg.drawImage(cry,y,325,this);
                                       BadMove.play();
              public String Multi() {
                        a = ( (int) (Math.random()*100) )+10;
                        c = ( (int) (Math.random()*10) );
                   while(c==0 || c==1)
                        c = ( (int) (Math.random()*10) );
                   String a1 = String.valueOf(a);
                   String a2 = String.valueOf(c);     
                   return (a1+" x "+a2+" = ");
                   public String Divi() {
                        a = 2*( (int) (100*Math.random() ) )+2;
                        c = 2*( (int) (10*Math.random() ) )+2;
                        while (a%c!=0)
                             c = 2*( (int) (10*Math.random() ) )+2;
                   String a1 = String.valueOf(a);
                   String a2 = String.valueOf(c);     
                   return (a1+" � "+a2+" = ");
              public Graphics Create(int i) {
              repaint();
              Dimension d=size();
              bufferg.setColor(getBackground());
              bufferg.fillRect(100,100,350,75);
              bufferg.setColor(Color.yellow);
                   a = ( (int) (Math.random()*100) );
                   b = ( (int) (Math.random()*100) );
                   String a1 = String.valueOf(a);
                   String a2 = String.valueOf(b);
                   Font f = new Font("Helvetica", Font.BOLD, 36);
                   bufferg.setFont(f);
                   bufferg.setColor(Color.black);
                   if (i==0)
                        bufferg.drawString(a1+" + "+a2+" = ", 145,150);
                   else if (i==1)
                        bufferg.drawString(a1+" - "+a2+" = ", 145,150);
                   else if (i==2)
                        bufferg.drawString( Multi() , 145,150);                    
                   else if (i==3)
                        bufferg.drawString( Divi() , 145,150);
                        return bufferg;
         private void handleCheckbox(Event evt) {
              Checkbox cb = (Checkbox)evt.target;
                   String str = cb.getLabel();
                   bufferg.drawImage(test,0,50,this);
                   if (str==boxName[0]) {
                        paint( Create(0) );
                        invis.setText("+");
                   else if (str==boxName[1]) {
                        paint( Create(1) );
                        invis.setText("-");
                   else if (str==boxName[2]) {
                        paint( Create(2) );
                        invis.setText("x");
                   else if (str==boxName[3]) {
                        paint( Create(3) );     
                        invis.setText("/");
         } //end handleCheckBox
         public void update(Graphics g){
              paint(g);
         public void paint(Graphics g) {
              g.drawImage(buffer,0,0,this);
    }//end class

    Its not easy to follow your code without the [ code] +[ /code] tags and your link may as well not be there, the code one. I would resolve this by reducing the overhead ie: stripping down the code as much as I could and then adding them back one by one. DIVIDE and CONQUER!!!
    1. Take out the audio data (I suspect this may be the key problem)
    2. Take out the Thread 'main' and have an actionListener attached to your answer field to handle the changes
    3. Take out java.net and your URLs
    4. use a MediaTracker and WaitForAll()
    5. Strip it down further - AS MUCH AS YOU CAN (you can easily reassemble it quickly again) and then look at the program flow
    6. Add more boolean logic to give you control over all your elements ie
    if(myAnswer==answer) smiley=true;
    else smiley = false;
    // or whatever, as I said I could only scan through your code as it is difficult to read in its present format.
    Finally: this is good work I like the smileys and the instant %'s, the general layout, good /intelligent use of random() to generate different Q's each time. It's a good application, just remember that applets can be unreliable and I think your basic problem is that you have too much data here.
    Strip it right down, focus on your logical flow and then put back the elements one-by-one

  • Need help serializing an AbstractTableModel for a JTable with cell editing.

    Fun times are ahead. Here we go!
    I have a JTable that contains data I'd like to serialize out to a file to be restored and viewed later.
    So I tried saving the AbstractTableModel subclass out to a file. Whenever I do this, I get the following error message:
    java.io.NotSerializableException: javax.swing.JTable$CellEditorRemover
    Now I know for fact that serializing an AbstractTableModel that was installed in a JTable without cell editing works just fine (my old code did exactly that). As a result, I think that the code that handles events in the AbstractTableModel contains references back out to the JTable, which causes the JTable to be saved no matter what (even though I'm just interested in saving the TableModel only). It causes a bigger file than normal, but file size is not an issue. The only issue I have is that CellEditorRemover (an undocumented inner class of JTable), which is automatically installed for JTables with editable cells, is not serializable.
    This leads to the following questions:
    1. Is there a way to avoid serialization/deserialization of the CellEditorRemover inner class of JTable?
    2. Is there a way to save an AbstractTableModel without saving all of the event listeners associated with it?
    I think an answer to either of these questions would go a long way towards solving my problem. Otherwise, I'll resign myself to weeping silently in the corner of my office.
    Thanks!

    I would suggest that if you can you only save the
    data... but i would do this by using the
    externalizable interface.
    What you will need to do is have the
    writeExternal(ObjectOutputStream out) and
    readExternal(ObjectOutputStream out) methods in your
    class. These will be responsiable for saving the
    data.
    Here's an example of what you can do in these
    methods... this is just a little tidbit from a program
    i've written.public void writeExternal(ObjectOutput out) throws
    IOException {
              out.writeInt(size);
              out.writeObject(drawName);
              out.writeInt(playersLength);
    for(int i = 0; i < playersLength; i++)
    ) out.writeObject(players);
              out.writeInt(seedsLength);
    for(int i = 0; i < seedsLength; i++)
    ) out.writeObject(seeds[i]);
              out.writeInt(drawLength);
    for(int i = 0; i < drawLength; i++)
    ) out.writeObject(draw[i]);
    public void readExternal(ObjectInput in) throws
    IOException, ClassNotFoundException {
              size = in.readInt();
              drawName = (String)in.readObject();
              playersLength = in.readInt();
    for(int i = 0; i < playersLength; i++) players[i] =
    = (String)in.readObject();
              seedsLength = in.readInt();
    for(int i = 0; i < seedsLength; i++) seeds[i] =
    = (String)in.readObject();
              drawLength = in.readInt();
    for(int i = 0; i < drawLength; i++) draw[i] =
    = (String)in.readObject();
    You can now use your class as you would a Serializable
    class, but it will only save the data
    Hope this helped
    webaf409java
    I forgot to add some critical information in my original post. My apologies. :(
    I've thought about using Externalizable, but am hesitant to use it because the application would no longer be able to read in files using the old save format (ie, AbstractTableModels for JTables without CellEditorRemovers ).  I want to preserve the ability to read the old saved AbstractTableModel formats if possible. 
    Do you know of a way to revert to the default deserialization mechanism from readExternal?  This way, during deserialization, I could do a quick test on the object being read and have the ability to default to the regular deserialization mechanism if the object is of the old type or continue with the new Externalizable stuff if the object is one of the new type.  Maintaining file compatibility is key.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • JTable's Cell navigation with TAB

    Dear ALL
    I have face one problem in JTable's cell navigation with TAB. The problem as describe bellow.
    I have two columns NAME and ADDRESS. Set focus on ADDRESS column's first cell. now if i am press tab key then focus controll comes on second cell which is the ADDRESS column. At the end of row controll comes on first row second column that means focus on ADDRESS column's first cell.
    Please give me some hints.
    Thanks in advance.
    Amit

    Your description doesn't make any sense (to me at least) so I don't know what your problem is or what you are asking to be changed.
    The normal tab order is Left to Right, Top to Bottom. So if the focus is at the top/left normal tabbing would be:
    Row 0, Column 0 (name 0)
    Row 0 Column 1 (address 0)
    Row 1, Column0 (name 1)
    Row 1, Column 1 (address 1)
    Row 2, Column 0 (name 2)
    Row 2, Column 1 (address 2)
    Your question seems to imply that your tab from address to addreass, which doesn't make sense.
    "Set focus on ADDRESS column's first cell. now if i am press tab key then focus controll comes on second cell which is the ADDRESS "

  • JTable & custom cell editor

    Hello everyone,
    what is the correct way of writing a custom cell editor for a JTable? I followed the example in the Java tutorial ([How to use tables|http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#editor]), but the result is a bit weird. The code I have is the following:
        private class NumericCellEditor extends AbstractCellEditor implements TableCellEditor {
            NumericFTField field = new NumericFTField(threeDecimalsFormat, 3, null, 1);
            public Component getTableCellEditorComponent(JTable table, Object value,
                    boolean isSelected, int row, int col) {
                field.setValue(value);
                return field;
            public Object getCellEditorValue() {
                return field.getValue();
            @Override
            public boolean stopCellEditing() {
                if (((NumericFTField)field).verifyDouble()) {
                    field.setBorder(new EmptyBorder(0, 0, 0, 0));
                    fireEditingStopped();
                    return true;
                } else {
                    field.setBorder(BorderFactory.createLineBorder(Color.red));
                    return false;
        }where the NumericFTField is a class derived from JFormattedTextField that only allows digits, decimal separator, minus and 'E' to be inserted, and it monitors clipboard operations. verifyDouble() is a method of the NumericFTField class that verifies whether the current input can be parsed to a double and whether it satisfies everything it should. This is then used in
    ((TableColumn)jTblSpecs.getColumnModel().getColumn(1)).setCellEditor(new NumericCellEditor());The NumericFTField class works great, I use it also in place of a JTextFields, so I'd say there is nothing wrong with it.
    After I click in a cell (single click), it behaves a little different that the default cell editor: the cell is not highlighted, but it immediately jumps to the editing state (why???). I, indeed, can insert the allowed characters only. When I click in a cell, do some editing and press Enter, the cell's content gets validated. If it is invalid, stopCellEditing() method does its magic; if it is valid, the caret disappears and everything SEEMS okay. However, if I started typing at this point, the cell reverts to the editing state, but now I am able to enter any character I want. It truly looks like the cell editor is now some other component, not the original NumericFTField one. What is going on here?
    It would be great is someone could provide a short schematic source of a custom cell editor class that would work exactly as the JTable's default one except it would only permit digits and so on. It doesn't have to be anything fancy, just a "skeleton" of the class with comments like "input verification here" etc.
    I am sorry for any lack of clarity, but I am still a Java newbie.
    Any help would be much appreciated.
    Best regards,
    vt

    Hi,
    I am also facing the same problem. In addition to what you have specified, my requirement is to be able to select multiple rows for deletion. But, the very first row selected using mouse is not visible as selected though its selected. The other rows are visible as selected.
    If you can use any JDK version, start using JDK1.6. You will not be facing this problem. There were so many changes done for swings from JDK 1.4 to 1.6. But, I have to strictly use JDK1.4, but could not find any workaround for this problem.
    It would be great if anyone can help me out in this issue to get workaround for this problem.

  • Adding JTable on an image..............??help need.....edited

    i am using JFame
    on JFrame i hav added JTabbedpane....
    on one of the tab i hav added image on whole background....
    on that tab i hav added JTable....
    but when i add JTable on that tab .....instead of adding table on that image...it add image on background with no image
    that no color part shoud be covered with part of image added on a tab
    and also i want to position (x,y) of JTable on tab.....
    so i hav used gridLayout so that it looks better....but that not i want.....
    here is the code.... check search tab
    //project.java
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    class tdsgui{
    JFrame f,pass;
    JTabbedPane jtp = new JTabbedPane();
    JApplet obj=new JApplet();
    JMenuBar mb=new JMenuBar();
    public tdsgui(){
    f=new JFrame("TELEPHONE DIRECTORY SYSTEM");
    JMenu m1=new JMenu("File");
    JMenu m2=new JMenu("About");
    JMenu m3=new JMenu("Help");
    mb.add(m1);
    mb.add(m2);
    mb.add(m3);
    JMenuItem mi1=new JMenuItem("Save");
    JMenuItem mi2=new JMenuItem("Exit");
    JMenuItem mi3=new JMenuItem("save as");
    mi3.setVisible(true);
    m1.add(mi1);
    m1.add(mi3);
    m1.add(mi2);
    public void launch(){
    jtp.addTab(" REGISTRATION ",new registerpanel());
    jtp.addTab(" MODIFY ",new updatepanel());
    jtp.addTab(" SEARCH ", new searchpanel());
    f.add(mb);
    f.setJMenuBar(mb);
    f.add(jtp);
    f.setSize(500,600);
    f.setVisible(true);
    public class project{
    public static void main(String args[]){
    tdsgui next=new tdsgui();
    next.launch();
    class registerpanel extends JPanel{
    public registerpanel(){
    class updatepanel extends JPanel{
    public updatepanel(){
    class searchpanel extends JPanel{
    public searchpanel(){
    Icon icon = new ImageIcon("Sunset.jpg");
    JLabel label = new JLabel(icon);
    add(label);
    this.setLayout(new GridLayout(2,0));
    final String[] colHeads = { "Name", "Phone", "Fax" };
    final String[][] data = {
    { "Gail", "4567", "8675" },
    { "Ken", "7566", "5555" },
    { "Viviane", "5634", "5887" },
    { "Melanie", "7345", "9222" },
    { "Anne", "1237", "3333" },
    { "John", "5656", "3144" }
    // Create the table
    JTable table = new JTable(data, colHeads);
    JTableHeader header = table.getTableHeader();
    table.setRowHeight(20);
    TableColumn column = table.getColumnModel().getColumn(0);
    table.setCellSelectionEnabled(true);
    table.getTableHeader().setPreferredSize(new Dimension(0,30));
    table.setFont(new Font("Dialog", Font.BOLD, 15));
    table.setBackground(Color.green);
    header.setFont(new Font("Courier",Font.BOLD,25));
    header.setBackground(Color.yellow);
    //label.add(table,BorderLayout.CENTER);
    // Add table to a scroll pane
    int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
    int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
    JScrollPane jsp = new JScrollPane(table, v, h);
    // Add scroll pane to the content pane
    this.add(jsp, BorderLayout.SOUTH);
    add image i ur system....make changes on searchpanel class
    thanks in advance...

    on one of the tab i hav added image on whole background....no you haven't - you've added a JLabel to a GridLayout JPanel
    I have no idea what you're really trying to do, but here's a tab with image background and transparent table (except for the header)
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    class tdsgui{
    JFrame f;
    JTabbedPane jtp = new JTabbedPane();
    public tdsgui(){
    f=new JFrame("TELEPHONE DIRECTORY SYSTEM");
    public void launch(){
    jtp.addTab(" REGISTRATION ",new registerpanel());
    jtp.addTab(" MODIFY ",new updatepanel());
    jtp.addTab(" SEARCH ", new searchpanel());
    f.add(jtp);
    f.setSize(500,600);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
    class project{
    public static void main(String args[]){
    tdsgui next=new tdsgui();
    next.launch();
    class registerpanel extends JPanel{
    public registerpanel(){
    class updatepanel extends JPanel{
    public updatepanel(){
    class searchpanel extends JPanel{
    Image img;
    public searchpanel(){
    try{img = javax.imageio.ImageIO.read(new java.net.URL(getClass().getResource("Test.gif"), "Test.gif"));}
    catch(Exception e){}//do nothing - handled in paintComponent
    this.setLayout(new GridLayout(2,0));
    final String[] colHeads = { "Name", "Phone", "Fax" };
    final String[][] data = {
    { "Gail", "4567", "8675" },
    { "Ken", "7566", "5555" },
    { "Viviane", "5634", "5887" },
    { "Melanie", "7345", "9222" },
    { "Anne", "1237", "3333" },
    { "John", "5656", "3144" }
    JTable table = new JTable(data, colHeads);
    table.setOpaque(false);
    table.setBackground(new Color(0,0,0,0));
    JScrollPane jsp = new JScrollPane(table);
    jsp.setOpaque(false);
    jsp.getViewport().setOpaque(false);
    this.add(jsp);
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    if(img != null) g.drawImage(img,0,0,this.getWidth(), this.getHeight(),this);
    }

  • Adding JTable on an image..............??help need

    i am using JFame
    on JFrame i hav added JTabbedpane....
    on one of the tab i hav added image on whole background....
    on that tab i hav added JTable....
    but when i add JTable on that tab .....instead of adding table on that image...it add image on background with no image
    that no color part shoud be covered with part of image added on a tab
    and also i want to position (x,y) of JTable on tab.....
    so i hav used gridLayout so that it looks better....but that not i want.....
    here is the code.... check search tab
    //project.java
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    class tdsgui{
    JFrame f,pass;
    JTabbedPane jtp = new JTabbedPane();
    JApplet obj=new JApplet();
    JMenuBar mb=new JMenuBar();
    public tdsgui(){
    f=new JFrame("TELEPHONE DIRECTORY SYSTEM");
    JMenu m1=new JMenu("File");
    JMenu m2=new JMenu("About");
    JMenu m3=new JMenu("Help");
    mb.add(m1);
    mb.add(m2);
    mb.add(m3);
    JMenuItem mi1=new JMenuItem("Save");
    JMenuItem mi2=new JMenuItem("Exit");
    JMenuItem mi3=new JMenuItem("save as");
    mi3.setVisible(true);
    m1.add(mi1);
    m1.add(mi3);      
    m1.add(mi2);
    public void launch(){
    jtp.addTab(" REGISTRATION ",new registerpanel());
    jtp.addTab(" MODIFY ",new updatepanel());
    jtp.addTab(" SEARCH ", new searchpanel());
    f.add(mb);
    f.setJMenuBar(mb);
    f.add(jtp);
    f.setSize(500,600);
    f.setVisible(true);
    public class project{
    public static void main(String args[]){
    tdsgui next=new tdsgui();
    next.launch();
    class registerpanel extends JPanel{
    public registerpanel(){
    class updatepanel extends JPanel{
    public updatepanel(){
    class searchpanel extends JPanel{
    public searchpanel(){
    Icon icon = new ImageIcon("Sunset.jpg");
         JLabel label = new JLabel(icon);
    add(label);
    this.setLayout(new GridLayout(2,0));
    final String[] colHeads = { "Name", "Phone", "Fax" };
    final String[][] data = {
    { "Gail", "4567", "8675" },
    { "Ken", "7566", "5555" },
    { "Viviane", "5634", "5887" },
    { "Melanie", "7345", "9222" },
    { "Anne", "1237", "3333" },
    { "John", "5656", "3144" }
    // Create the table
    JTable table = new JTable(data, colHeads);
    JTableHeader header = table.getTableHeader();
    table.setRowHeight(20);
    TableColumn column = table.getColumnModel().getColumn(0);
    table.setCellSelectionEnabled(true);
    table.getTableHeader().setPreferredSize(new Dimension(0,30));
    table.setFont(new Font("Dialog", Font.BOLD, 15));
    table.setBackground(Color.green);
    header.setFont(new Font("Courier",Font.BOLD,25));
    header.setBackground(Color.yellow);
    //label.add(table,BorderLayout.CENTER);
    // Add table to a scroll pane
    int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
    int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
    JScrollPane jsp = new JScrollPane(table, v, h);
    // Add scroll pane to the content pane
    this.add(jsp, BorderLayout.SOUTH);
    add image i ur system....make changes on searchpanel class
    thanks in advance...

    as was mentioned in your previous post, please use code tags when posting code here. Your current code is unformatted making it difficult to read. Also, when doing this, make sure that the pasted code has proper indentation before you use the code tags.
    To do this, you will need to paste already formatted code into the forum, highlight this code, and then press the "code" button at the top of the forum Message editor prior to posting the message. You may want to click on the Preview tab to make sure that your code is formatted correctly. Another way is to place the tag &#91;code] at the top of your block of code and the tag &#91;/code] at the bottom, like so:
    &#91;code]
      // your code block goes here.
      // note the differences between the tag at the top vs the bottom.
    &#91;/code]

  • JTable - active cell not highlited when editable

    Hello,
    I'm using JDK 1.4.2_05, and I'm seeing some behavior that seems a bit strange.
    In my JTables, some cells are editable, and others are not. When the user moves the active cell around (with the arrow keys, or TAB and RETURN) the non-editable cells show up with a nice blue color. If a cell is editable, it doesn't change at all, so the user has no idea where the "cursor" (meaning the active cell) is.
    These cells don't have any special renderer or anything. My JTable has these set:
    setRowSelectionAllowed(false);
    setColumnSelectionAllowed(false);
    setCellSelectionEnabled(true);Thanks for any advice!
    --- Eric

    Okay, yeah, I overrode the default renderer, and had it check whether the cell was selected or not, setting the background color appropriately. Duh. --- Eric

  • Jtable on cell changed event

    How can i treat an Jtable on cell changed event, not on value changed

    Do you mean cell selection changed? One way is to add a ListSelectionListener to both the table's and the table's ColumnModel's ListSelectionModels. Something likeListSelectionListener lsl = new ListSelectionListener() {
       public void valueChanged(ListSelectionEvent e) {
          System.out.println(e.getSource());
          ListSelectionModel lsm = (ListSelectionModel) e.getSource();
          if (!lsm.getValueIsAdjusting()) {
             System.out.println("Selection changed");
    table.getSelectionModel().addListSelectionListener(lsl);
    table.getColumnModel().getSelectionModel().addListSelectionListener(lsl);Note that simultaneous change of both row and column will generate two valueChanged events.
    If that's not what you wanted to know, ask a better question.
    [http://catb.org/~esr/faqs/smart-questions.html]
    db

  • HELP!!!Embedding a JTable on a ScrollPane into a JTable's cell

    I have a single column DND JTable on a DND JScrollPane that I would like to put into another's JTable's cell. I've tried creating a CellRenderer that extends the DNDJScrollPane and returns this but this doesn't work. I do have code I could post if anyone is interested in helping out.

    First copy this and compile and run and c.. then look at the code
    import javax.swing.border.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    import java.awt.*;
    public class JTableExample extends JFrame
    JTableRenderer renderer;
    MyTableModel m1, m2;
    public JTableExample()
    super();
    m1 = new MyTableModel();
    m2 = new MyTableModel();
    DefaultTableModel dtm = new DefaultTableModel()
    // make first cell uneditable
    public boolean isCellEditable(int row, int column)
    return !(column == 0);
    dtm.setDataVector(new Object[][]{{ "JTable1",  m1},
    { "JTable2",  m2}},
    new Object[]{ "Column1","Column2"});
    JTable table = new JTable(dtm);
    renderer = new JTableRenderer();
    table.getColumn("Column2").setCellRenderer(renderer);
    table.getColumn("Column2").setCellEditor(new JTableEditor());
    table.setRowHeight(80);
    JScrollPane scroll = new JScrollPane(table);
    getContentPane().add(scroll);
    setSize( 400, 250 );
    setVisible(true);
    public static void main(String[] args) {
    JTableExample frame = new JTableExample();
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    * JTable Editor
    class JTableEditor extends DefaultCellEditor
    public JTableEditor()
    super(new JCheckBox());
    public Component getTableCellEditorComponent(JTable table, Object value,
    boolean isSelected, int row, int column)
    return renderer;
    public Object getCellEditorValue()
    return (MyTableModel)((JTableRenderer)renderer).jtable.getModel();
    * JTable Renederer
    class JTableRenderer extends JScrollPane implements TableCellRenderer
    JTable jtable;
    public JTableRenderer()
    jtable = new JTable();
    getViewport().add(jtable);
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus,
    int row, int column)
    if (isSelected)
    setForeground(table.getSelectionForeground());
    setBackground(table.getSelectionBackground());
    jtable.setForeground(table.getSelectionForeground());
    jtable.setBackground(table.getSelectionBackground());
    else
    setForeground(table.getForeground());
    setBackground(table.getBackground());
    jtable.setForeground(table.getForeground());
    jtable.setBackground(table.getBackground());
    jtable.setModel((AbstractTableModel)value);
    return this;
    class MyTableModel extends AbstractTableModel {
    final String[] columnNames = {"First Name",
    "Last Name",
    "Sport",
    "# of Years",
    "Vegetarian"};
    final Object[][] data = {
    {"Mary", "Campione",
    "Snowboarding", new Integer(5), new Boolean(false)},
    {"Alison", "Huml",
    "Rowing", new Integer(3), new Boolean(true)},
    {"Kathy", "Walrath",
    "Chasing toddlers", new Integer(2), new Boolean(false)},
    {"Mark", "Andrews",
    "Speed reading", new Integer(20), new Boolean(true)},
    {"Angela", "Lih",
    "Teaching high school", new Integer(4), new Boolean(false)}
    public final Object[] longValues = {"Angela", "Andrews",
    "Teaching high school",
    new Integer(20), Boolean.TRUE};
    public int getColumnCount() {
    return columnNames.length;
    public int getRowCount() {
    return data.length;
    public String getColumnName(int col) {
    return columnNames[col];
    public Object getValueAt(int row, int col) {
    return data[row][col];
    public Class getColumnClass(int c) {
    return getValueAt(0, c).getClass();
    public boolean isCellEditable(int row, int col) {
    if (col < 2) {
    return false;
    } else {
    return true;
    public void setValueAt(Object value, int row, int col) {
    if (data[0][col] instanceof Integer
    && !(value instanceof Integer)) {
    try {
    data[row][col] = new Integer(value.toString());
    fireTableCellUpdated(row, col);
    } catch (NumberFormatException e) {
    } else {
    data[row][col] = value;
    fireTableCellUpdated(row, col);
    private void printDebugData() {
    cheers
    good luck

  • My BB Cruve 9300 Battery was Darined, it appears the Symbol of Charging but doesnt startup

    Hello, Im so Desperate, that after reading about 5 forums about the same topic in similar circunstances, can not solve my own problem, so here I am, hopefully someone in the 2014 will help me!
    I was in a trip where my CellPhone battery Died, and anything else, I arrived home and charge it and not even the red light, lights.
    After 2 days where I was waiting to arrive to my hometown to solve the problem with my tools, the cell phone did start to charge, appears both the red light for about 10 seconds then the black screen, and then the symbol of the Battery with a yellow lighting bolt. I leave it there for the whole night! 
    When I woke up, the phone stills in the screen with the Symbol of the Battery, so there has start my dilema:
    I dont know why the system does'nt boot, I begin with the tricks of removing the battery, and putting it again, all the ones I read on the forums, after that doesnt work, I decided to proove with reinstalling the OS from 0, with both the Desktop Manager and the Loader, then tried the second instances which was forcing the recognition of the device with both options (Desktop Manager and the Loader), in both cases the problem was the same, when it comes to the part: "Reconnecting the JVM" on my cell phone just lights the same symbol of the Battery with the Yellow Lighting Bolt and after a while appears the error message: "Application Loader was unable to connect with your device. Please re-connect your device, enter the password, if required, and click retry"
    So til there all a mess, so i finally decide to use extreme measures: the JL_cmder, and the problem is, i think a wipe my cellphone for at least 10 times, and all what keeps appearing is the goddamm symbol of the Lighting Battery!
    SO PLEASE IF SOME KNOWS WHAT HAPPENS OR WHAT CAN I DO!!! PLEASE PLEASE TELL ME!
    THANKS FOR THOSE WHO TAKE THE TIME TO READ ALL THIS!

    Hi and Welcome to the Community!
    No need to yell:
    http://kathrynvercillo.hubpages.com/hub/What-Peopl​e-Think-When-You-Type-in-All-Caps
    Please try this sequence...note that, throughout the entire 4h15m process, your BB must remain directly connected to a known-good wall charger (not PC USB, not a cradle):
    With the battery inside, connect your BB to the wall charger
    Leave it alone for 2 hours, no matter what the LED or the display does
    Remove the battery
    Wait 15 minutes
    Insert the battery
    Wait another 2 hours, no matter what the LED or the display does
    This has been known to "kick start" some BBs.
    It is also possible that your battery or BB has experienced a problem...to test, this sequence is needed:
    Obtain an known good and already fully charged additional battery...use it in your BB and see what happens
    Obtain access to a known good and identical BB...use your battery in it and see what happens
    The results of this will indicate if it's your BB or your battery that has the problem. Note carefully please that "new" and "know good" are not necessarily the same things. While rare, a "new" battery certainly could be defective. Rather, the simplest (and least costly, btw) method to conduct this test is to find someone with an identical BB who has no issues...trade batteries and see what happens.
    Good luck and let us know!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • When I plug in my Ipod touch to my computer a warning appears "The program cant start because MSVCR80.dll is missing."  I can not access my Itunes library.  Also, an "error 7 Windows error 126" appears as well.  Any ideas?

    When I plug in my Ipod Touch to my computer I can not access my Itunes library.  The following message appears "The program cant start because MSVCR80.dll is missing."  Also, another message appears as well - "Error 7  Windows error 126" as well as APSDaemon.exe.
    I have NO IDEA what the heck to do.
    Any ideas?
    Thanks!

    Issues installing iTunes or QuickTime for Windows
    solving MSVCR80
    iTunes 11.1.4 for Windows: Unable to install or open
    Troubleshooting issues with iTunes for Windows updates

  • Hi all, I upgraded my MBP to Lion , but on the screen where i need to type my password, click  on my photo and it does not appear the place for me to type my password and it stay stuck there. Can anyone solve this problem for me?

    Hi all, I upgraded my MBP to Lion , but on the screen where i need to type my password, click  on my photo and it does not appear the place for me to type my password and it stay stuck there. Can anyone solve this problem for me?

    Reboot the machine holding Command and r keys down, you'll boot into Lion Recovery Partition
    In there will be Disk Utility, use that to select your Lion OS X Partition and Repair Permissions.
    After that is done reboot the machine and see if you can log in.
    If not repeat the above steps to get into Lion Recovery, get online and reinstall Lion again, it will overwrite the installed version and hopefully after that it wil work.
    Reboot and try again.
    If not follow my steps to create a Snow Leopard Data Recovery drive, then option boot from it and grab a copy of your files off the machine.
    Then reinstall all your programs onto the external drive like setting up a new machine, then use Disk Utility to erase the entire internal boot drive (select the drive media on the far left, not the partiton slightly indented) format Option: GUID , 1 partition OS X Extended and then use Carbon Copy Cloner to clone the external to the newly formatted internal drive. Once that is finished reboot and disconnect the external drive.
    Once you go that, boot into Snow Leopard and update to 10.6.8, use the AppStore and option click on Purchases and download Lion again and install.
    Lots of work, but there is no Lion disks.
    https://discussions.apple.com/message/16276201#16276201

  • My iphone 5 won't sync, even i restored. it always appeared " The iPhone could not be synced because the sync session failed to start.

    my iPhone 5 won't sync even i restored. it always appeared  "The iPhone could not be synced because the sync session failed to start.

    https://discussions.apple.com/thread/3415227?start=0&tstart=0
    https://discussions.apple.com/message/16400530#16400530

Maybe you are looking for