Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7192167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:53:03+00:00 2026-05-28T19:53:03+00:00

I created a program to set an imageIcon in jtable fixed column, i created

  • 0

I created a program to set an imageIcon in jtable fixed column, i created a jtable and getting a database records, then set a first column as fixed column. i set an image icon in fixed column. when i am compiling this program, i am getting only a path of the imageicon not getting an image. I fixed an imageIcon in project package folder.

    This is the code i used

public void Frm_FlxD_Database() {
           try{
                TmpRow=0;
                TmpMainPrj.PRJ_DB_CONNECTION_ASSGN();
                TmpFlxMdl =(DefaultTableModel)FlxD.getModel();
                TmpFlxDRow = 0;

                TmpFlxSt=TmpGPrjVarDec.GContn.createStatement();
                TmpFlxDRs=TmpFlxSt.executeQuery("SELECT * from activitymaster");
                PRJ_FLX_DEFTL_ASSGN(FlxD, "BEGIN");
                TmpFlxDRs.first();
                do {
                    FlxD.setValueAt(TmpFlxDRs.getString("ACTVTYDESC"), TmpRow,1);
                    FlxD.setValueAt(TmpFlxDRs.getString("ACTVTYCODE"), TmpRow,2);
                    FlxD.setValueAt(TmpFlxDRs.getString("DISPSTATUS"), TmpRow,3);
                    FlxD.setValueAt(TmpFlxDRs.getString("ACTVTYID"), TmpRow,4);
                    TmpFlxMdl.addRow(new Object[]{""});
                    TmpRow = TmpRow + 1;
                }while(TmpFlxDRs.next());

                FRM_FLXD_PTR_DATA_ASSGN(TmpFlxDRow);
           }
           catch(Exception e){
                System.out.println(e);
           }
    }
private void FRM_FLXD_PTR_DATA_ASSGN(int PFlxRow) {
           TmpFlxDRow = PRJ_FLX_PTR_ASSGN(FlxD, PFlxRow, TmpFlxDRow);
   }

    private int PRJ_FLX_PTR_ASSGN(JTable PFlx, int PCurRow, int PPrvRow) {
            ImageIcon TmpIcon;

            System.out.println(PCurRow);
            System.out.println(PPrvRow);

            if (PCurRow != PPrvRow){
                TmpIcon = new ImageIcon(getClass().getResource("Blank.gif"));
                PFlx.setValueAt(TmpIcon,PPrvRow,0);
                System.out.println(TmpIcon);
            }
            TmpIcon = new ImageIcon(getClass().getResource("Pointer.gif"));
            PFlx.setValueAt(TmpIcon,PCurRow,0);
            System.out.println(TmpIcon);               
            return(PCurRow);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:53:03+00:00Added an answer on May 28, 2026 at 7:53 pm

    JTable knows Icon/ImageIcon, simple example

    enter image description here

    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.EventQueue;
    import javax.swing.*;
    import javax.swing.table.*;
    
    public class TableIcon extends JFrame implements Runnable {
    
        private static final long serialVersionUID = 1L;
        private JTable table;
        private JLabel myLabel = new JLabel("waiting");
        private int pHeight = 40;
        private boolean runProcess = true;
        private int count = 0;
    
        public TableIcon() {
            ImageIcon errorIcon = (ImageIcon) UIManager.getIcon("OptionPane.errorIcon");
            ImageIcon infoIcon = (ImageIcon) UIManager.getIcon("OptionPane.informationIcon");
            ImageIcon warnIcon = (ImageIcon) UIManager.getIcon("OptionPane.warningIcon");
            String[] columnNames = {"Picture", "Description"};
            Object[][] data = {{errorIcon, "About"}, {infoIcon, "Add"}, {warnIcon, "Copy"},};
            DefaultTableModel model = new DefaultTableModel(data, columnNames);
            table = new JTable(model) {
    
                private static final long serialVersionUID = 1L;
                //  Returning the Class of each column will allow different
                //  renderers to be used based on Class
    
                @Override
                public Class getColumnClass(int column) {
                    return getValueAt(0, column).getClass();
                }
            };
            table.setRowHeight(pHeight);
            table.setPreferredScrollableViewportSize(table.getPreferredSize());
            JScrollPane scrollPane = new JScrollPane(table);
            add(scrollPane, BorderLayout.CENTER);
            myLabel.setPreferredSize(new Dimension(200, pHeight));
            myLabel.setHorizontalAlignment(SwingConstants.CENTER);
            add(myLabel, BorderLayout.SOUTH);
            EventQueue.invokeLater(new Runnable() {
    
                public void run() {
                }
            });
            new Thread(this).start();
        }
    
        public void run() {
            while (runProcess) {
                try {
                    Thread.sleep(750);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                SwingUtilities.invokeLater(new Runnable() {
    
                    @Override
                    public void run() {
                        ImageIcon myIcon = (ImageIcon) table.getModel().getValueAt(count, 0);
                        String lbl = "JTable Row at :  " + count;
                        myLabel.setIcon(myIcon);
                        myLabel.setText(lbl);
                        count++;
                        if (count > 2) {
                            count = 0;
                        }
                    }
                });
            }
        }
    
        public static void main(String[] args) {
            TableIcon frame = new TableIcon();
            frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
            frame.setLocation(150, 150);
            frame.pack();
            frame.setVisible(true);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created socket program in Blackberry. and also set socket to keep alive
I have created a program, i need to save the content into mysql database.
I created a program using dev-cpp and wxwidgets which solves a puzzle. The user
I created a program, and it uses the vector.h #include, and iterators, etc... But
I created this program: #include <iostream> #include <fstream> using namespace std; int main ()
I created a program called test: #include<stdlib.h> #include<iostream> int main() { std::cout<<system(..\\add\\debug\\add.exe 4 8);
I created a program that more or less holds an array of strings as
I've created a program in Delphi that uses Google's AJAX Search API to evaluate
I've created a program that creates and populates a custom document property in an
I've created a program in Eclipse / MinGW / C (project type: C) which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.