Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By Fubarable

Thread: swings

  1. #1
    hemanth123 is offline Member
    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    0

    Lightbulb swings

    import javax.swing.*;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    public class tabledemo extends JPanel
    {
    private boolean debug = false;
    public tabledemo()
    {
    super(new GridLayout(1,0));
    String[] columns={"name","id","place"};
    Object[][] data={
    {"hem",new Integer(1),"vizag"},
    {"ram",new Integer(2),"vizag"},
    {"hemram",new Integer(3),"vizag"}
    };

    final JTable tb = new JTable(data, columns);
    if(debug)
    {
    tb.addMouseListener(new MouseAdapter()
    {
    public void mouseClicked(MouseEvent me)
    {
    printdebugdata(tb);
    }
    });
    }
    }
    private void printdebugdata(JTable tb)
    {
    int numrows=tb.getRowCount();
    int numcols=tb.getColumnCount();
    javax.swing.table.TableModel tm = tb.getModel();
    for(int i=0;i<numrows;i++)
    {
    System.out.println("rows : " + i);
    for(int j=0;j<numcols;j++)
    {
    System.out.println("Rows and columns are : " + tb.getValueAt(i,j));
    }
    }
    }
    private static void createshowgui()
    {
    JFrame jf = new JFrame("emp table");
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    tabledemo newContentPane = new tabledemo();
    newContentPane.setOpaque(true); //content panes must be opaque
    jf.setContentPane(newContentPane);

    //Display the window.
    jf.pack();
    jf.setVisible(true);
    }
    public static void main(String[] args)
    {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void Run()
    {
    createshowgui();
    }
    });
    }
    }


    getting error <anonymous tabledemo> is not a abstract and does not overide abstract method run() in Runnable

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: swings

    Quote Originally Posted by hemanth123 View Post
    Java Code:
     javax.swing.SwingUtilities.invokeLater(new Runnable() {
       public void Run()
       {
          createshowgui();
       }
    });
    getting error <anonymous tabledemo> is not a abstract and does not overide abstract method run() in Runnable
    That error is telling you that the code above that implements the Runnable interface does not implement all the methods of Runnable correctly. Since a Runnable only has to implement one method, run, then you're not doing it right (hint: spelling and especially capitalization matters).

    A suggestion for future questions here: consider using a more informative thread title. "swings" doesn't tell us briefly what your problem is. I'd have titled this thread "Error: class is not abstract and does not override the inherited abstract method...".
    Last edited by Fubarable; 10-08-2011 at 08:38 AM.
    hemanth123 likes this.

  3. #3
    hemanth123 is offline Member
    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    0

Similar Threads

  1. JAVA-Swings
    By HariPrasad in forum AWT / Swing
    Replies: 6
    Last Post: 12-29-2010, 02:29 AM
  2. How to get the GUI Help for Swings?
    By CHARU_SH in forum Eclipse
    Replies: 1
    Last Post: 05-19-2010, 11:03 AM
  3. URL retrieval using swings
    By gbose in forum AWT / Swing
    Replies: 1
    Last Post: 02-07-2010, 02:19 PM
  4. Swings
    By bsantosh in forum AWT / Swing
    Replies: 4
    Last Post: 08-31-2009, 02:10 PM
  5. awt and swings
    By masa in forum AWT / Swing
    Replies: 2
    Last Post: 11-24-2008, 07:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •