Page 1 of 2 12 LastLast
Results 1 to 20 of 21
  1. #1
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default Image not displaying

    Hi

    My Code is
    Java Code:
    IconLabel.setVisible(true);
    
    try{
    Loaded Sql server driver and database operations
    }
    catch(Exception e){
    e.getMessage();
    }
    My problem is IconLabel is an image which is not loading oly i.e. not display

    why is this happening, help me out

    Regards
    Sandeep

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    Can you make a small program that compiles and executes that demonstrates your problem? You have not provided enough information.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,457
    Blog Entries
    7
    Rep Power
    20

    Default

    And this has no use at all:

    [QUOTE=sandeep43;219752]
    Java Code:
    catch(Exception e){
    e.getMessage();
    }
    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default

    Hi Norm and josAH

    @Norm:
    Java Code:
      IconLabel.setVisible(true);
             
            DateFormat formatter ; 
            Date date ;
            String schemaaccess = SchemaAccess.getText();
            String GetSchema=SchemaName.getText(); 
            String ArchiveSchemaName= ArchiveSchema.getText();
            Document document=new Document(); 
                  
                   
     try
            {  
                Schema.setEnabled(false);
                AddServerName.setEnabled(false);
            
               Class.forName("net.sourceforge.jtds.jdbc.Driver");
                
               String url = "jdbc:jtds:sqlserver://"+SrcServer+"/"+SrcConnectionString;
               Properties props = new Properties();
               props.setProperty("user",SrcUser);
               props.setProperty("password",SrcSourcePassword);
               props.setProperty("namedPipe","true");
               Connection  conn = DriverManager.getConnection(url,props);
                java.sql.Statement sta = conn.createStatement(); 
              
                   ResultSet rs  = sta.executeQuery("SELECT A.NAME FROM "+SrcConnectionString+".sys.tables A WHERE"
                           + " EXISTS (SELECT B.NAME FROM "+ArcConnectionString+".sys.tables B WHERE B.NAME=A.NAME)"
                           + " UNION "
                           + "SELECT A.NAME FROM "+SrcConnectionString+".sys.views A WHERE "
                           + "EXISTS (SELECT B.NAME FROM "+ArcConnectionString+".sys.views B WHERE B.NAME=A.NAME)");
                 
                   date = new Date();
                   formatter = new SimpleDateFormat("dd-MMM-yy HH-mm-ss");
                   
                   String Final_Date = formatter.format(date);
                     
                   while ( rs.next() ) {
                   RecName =   rs.getString("NAME");
                   document.add(new Paragraph(RecName)); 
                   java.sql.Statement stmt =conn.createStatement();
                   boolean rs1  = stmt.execute("CREATE VIEW "+GetSchema+"."+RecName+ " AS  (SELECT * FROM OPENQUERY ("+ArcServer+",'SELECT * FROM "+ArcConnectionString+"."+ArchiveSchemaName+"."+RecName+"')"
                                                     +"UNION ALL "
                                                     + "SELECT * FROM "+SrcConnectionString+"."+schemaaccess+"."+RecName +")");
                   //System.out.println("CREATE VIEW "+GetSchema+"."+RecName+ " AS  (SELECT * FROM OPENQUERY ("+ArcServer+",'SELECT * FROM "+ArcConnectionString+"."+ArchiveSchemaName+"."+RecName+"')"
                                                   //  +"UNION ALL "
                                                     //+ "SELECT * FROM "+SrcConnectionString+"."+schemaaccess+"."+RecName +")");
                 
                  UnionView.setEnabled(false);
                  
                   }
            
              
                conn.close();
               
                JOptionPane optionPane = new JOptionPane("Successful creation of Synonyms and Union views", JOptionPane.INFORMATION_MESSAGE);
                JDialog dialog = optionPane.createDialog("Seamless Access");
                dialog.setVisible(true);
               
                
               
            
            }
           catch (Exception e)
            {
              
                
            JOptionPane optionPane = new JOptionPane("Synonyms and Union views are not created in new Schema", JOptionPane.ERROR_MESSAGE);
            JDialog dialog = optionPane.createDialog("Seamless Access");
            //UnionViewsBar.setIndeterminate(false);
           
            }
    this is my code, my 1st line is my VariableName, it is not displaying at all , what ever way i call it, it wont display.
    but the image will come up after the process is finished, which is off no use

    @josH: thats true, i just wrote it

  5. #5
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,789
    Rep Power
    7

    Default

    Quote Originally Posted by sandeep43 View Post
    but the image will come up after the process is finished, which is off no use
    Don't do everything in the same thread.

  6. #6
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default

    so how can i do it junky, an idea please

    Regards
    Sandeep

  7. #7
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,789
    Rep Power
    7

    Default

    Lesson: Concurrency in Swing (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    How come people are incapable of doing their own research?

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    Your code segment does not compile and execute. It does not show us the problem.
    Where is the IconLabel created, initialized and added to the GUI?
    The database code is not part of creating a GUI.

  9. #9
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default

    Hi Norm

    it is not initialized, it is added to GUI i use Netbeans and ya creating database is not part of GUI.

    Regards
    Sandeep

  10. #10
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default

    IconLabel is JLabel and i added an image via properties and i have written code in Post-init in properties to invisible i.e. IconLabel.setVisible("false");

    later in action performed of a button i have made it visible as i have shown in above, but it is not displaying.

    Regards
    Sandeep

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    Please write a small, complete program that executes and shows the problem.
    The code you have posted is useless for figuring out why an image is not displaying for you.

  12. #12
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default

    Hi Norm,

    to post other code i called it in other method its working fine, oly in this code it is not working. i can post other code which is not a problem but there is no issue in other code, i have it in this method where i have written above code where it is not working


    Regards
    Sandeep

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    How can anyone compile and test your code to see the problem?
    Given this one statement: IconLabel.setVisible(true);
    It won't even compile.

    Good luck then.

  14. #14
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,953
    Rep Power
    19

    Default

    What Norm is saying is write a really really small piece of code that attempts to do what you want (show an icon label on the push of a button).
    If that results in the same problem then show us that small code.
    If it doesn't cause a problem then try and figure out why the small code is different from the above large code.

    Because otherwise I might be tempted to pick apart your database code, which isn't what you are looking for.

  15. #15
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default

    hi toll and norm

    @toll: your 100% correct, when i attempted to write a small code, i got that image no issues came up, oly when i had plugged it with that database code i am getting that prob.

    @norm: suggest me a different technique how i can show that image, i am trying from past 4 days on same bug, please.
    all my requirement is during the database operation i have to show user saying "Processing", so dont cancel the process or close the window. i have done it by calling an image as u know which is not displaying. u suggest me a technique how to accomplish it, i will design and write code myself.

    regards
    Sandeep

  16. #16
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default

    i observed something norm, whenever there is some database operation like creation of views in sql, my IconLabel is not visible or not coming. when there is no database operation IconLabel is working perfectly.

    Regards
    Sandeep

  17. #17
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default

    You have been given a link to the Swing concurrency tutorial. Whether you choose to follow the tips in that tutorial is up to you.

    db

  18. #18
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,953
    Rep Power
    19

    Default

    Quote Originally Posted by sandeep43 View Post
    hi toll and norm

    @toll: your 100% correct, when i attempted to write a small code, i got that image no issues came up, oly when i had plugged it with that database code i am getting that prob.
    So, it's a concurrency issue then.
    The basic rule is, do not do heavy calculations in the EDT.
    If you don't know what the EDT is then you need to do the tutorials.

  19. #19
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default

    Hi db and tolls and Norm

    i used EDT, now im getting different error

    Java Code:
    class SwingWorkerCompletionWaiter  {
         private JDialog dialog1;
         public SwingWorkerCompletionWaiter(JDialog dialog2) {
             this.dialog1 = dialog2;
         }
         public void propertyChange(PropertyChangeEvent event) {
             if ("state".equals(event.getPropertyName())
                     && SwingWorker.StateValue.DONE == event.getNewValue()) {
                 IconLabel.setVisible(true);
                 dialog1.setVisible(true);
                 dialog1.dispose();
                 
             }
         }
    }
     JDialog dialog3 = new JDialog();
     Icon icon = new ImageIcon("processing.gif");
     JOptionPane.showMessageDialog(myAppFrame,aboutGreeting, "About MyApp", JOptionPane.INFORMATION_MESSAGE,icon);
    */
      
     worker.execute();
     
     UnionView.setEnabled(false);
    [COLOR="red"] dialog3.setVisible(true);[/COLOR]

    Worker program is
    Java Code:
    SwingWorker worker = new SwingWorker<ImageIcon, Void>() {
        @Override
        public ImageIcon doInBackground() {
            final ImageIcon innerImgs = new ImageIcon("processing.gif");
           
          IconLabel.setVisible(true);
            return innerImgs;
    now the icon is displayed properly but im getting an unnecessary dialog box visible, if i make it setvisible=false then my image is not displaying
    help me out now dialog statement is highlighted in red because of which im getting error

  20. #20
    sandeep43 is offline Member
    Join Date
    May 2011
    Posts
    97
    Rep Power
    0

    Default

    Hi junky Norm db and others

    Thread concept rocked, it worked exactly frget about the post which i have posted one above. i did use Runnable{} and finished and it was pretty easy

    Thanks Junky and Norm in particular

    Regards
    Sandeep

Page 1 of 2 12 LastLast

Similar Threads

  1. Displaying an image
    By BariMutation in forum New To Java
    Replies: 6
    Last Post: 11-12-2010, 01:23 AM
  2. Displaying an image
    By Samari413 in forum New To Java
    Replies: 10
    Last Post: 11-06-2010, 08:56 PM
  3. Displaying an image
    By SWEngineer in forum AWT / Swing
    Replies: 11
    Last Post: 01-28-2010, 05:48 AM
  4. displaying image into screen !
    By burningflower12 in forum AWT / Swing
    Replies: 14
    Last Post: 11-16-2009, 02:02 AM
  5. Displaying image in same jsp
    By SreenivasGurramkonda in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-08-2008, 06:01 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
  •