A Jrame with progressbar that is setVisible() in a n otherThread

This title may seem a bit weird, but I really don't know how to explain it.
My problem is this:
For a (huge :p) project for school we need to read csv( Comma separated value) and put them in a database. Because this can take a while on remote servers I wanted to make Jframe with progressbar that is updated with each function that is done. But for some reason he doesn't show this Jframe UNTILL everything is read. It's like he doesn't use the Thread at all.
I have to say I allready have 1 thread running for checking the database connection (+ the threads that swing uses), I don't know if this causes any problems:
Here's the code
The thread class
* CsvCheckDoneThread.java
* Created on 2 juni 2007, 18:12
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
package Data;
import View.CsvProgress;
* @author Welles
public class CsvCheckDoneThread implements Runnable {
    CsvProgress progress=new CsvProgress();
    /** Creates a new instance of CsvCheckDoneThread */
    public CsvCheckDoneThread(){
    public void run() {
        progress.setVisible(true);
    public void stopthread(){
        progress.dispose();
    public void setValue(int value){
        progress.setValue(value);
}the Jframe with the progressbar
* CsvProgress.java
* Created on 2 juni 2007, 18:35
package View;
import javax.swing.*;
import java.awt.*;
* @author  Welles
public class CsvProgress extends JFrame {
    /** Creates new form CsvProgress */
    public CsvProgress() {
        initComponents();
        //centerscreen();
        this.prgbar.setValue(0);
    private void centerscreen(){
        Dimension dim = getToolkit().getScreenSize();
        Rectangle abounds = getBounds();
        setLocation((dim.width - abounds.width) / 2,(dim.height - abounds.height) / 2);
    public void setValue(int value){
        this.prgbar.setValue(this.prgbar.getValue()+value);
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        prgbar = new javax.swing.JProgressBar();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setAlwaysOnTop(true);
        setBackground(new java.awt.Color(214, 205, 244));
        setResizable(false);
        prgbar.setStringPainted(true);
        jLabel1.setFont(new java.awt.Font("Calibri", 0, 14));
        jLabel1.setForeground(new java.awt.Color(0, 0, 153));
        jLabel1.setText("<html>De csv's worden geladen.<br><p align=\"center\">Even geduld aub</p></html>");
        jPanel2.setBackground(new java.awt.Color(67, 67, 201));
        jLabel2.setFont(new java.awt.Font("Calibri", 0, 48));
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("<html>D<br>C<br>I</html>");
        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jLabel2)
                .addContainerGap(37, Short.MAX_VALUE))
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(23, Short.MAX_VALUE))
        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addComponent(prgbar, javax.swing.GroupLayout.PREFERRED_SIZE, 242, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(80, 80, 80)
                        .addComponent(jLabel1)))
                .addGap(34, 34, 34))
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(65, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(prgbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(77, 77, 77))
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        pack();
    }// </editor-fold>                       
     * @param args the command line arguments
    // Variables declaration - do not modify                    
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JProgressBar prgbar;
    // End of variables declaration                  
}The class where I run the Thread
public void InitializeCsv(String path) throws SQLException, IOException{
        csvcheckclass=new CsvCheckDoneThread();
        Thread cvsth = new Thread(csvcheckclass);
        try{
            cvsth.start();
            Csv c= new Csv(game, wedstrijd, speeldag, speler, team, club, reeks, bc,csvcheckclass);
            c.LeesCsv(path);
            kalender k= new kalender(14,wedstrijd,team, club, bc);
            k.create(); 
            csvcheckclass.stopthread();
        } catch (SQLException e){
            csvcheckclass.stopthread();
            throw new SQLException();
    }Some words will probably be unreadable by you guys (unless you understand dutch/flemisch), but I hope you get the picture on what I like to do :).
If you could tell me what I'm doing wrong it would be a gigantic help for me (this is the last thing that I need to do).
grtz!

The most likely answer is that your CVS code is actually running in the AWTEventQueue thread. The fact that you call setVisible in another thread really does nothing, since it is the AWTEventQueue thread that actually controls the painting of the object. I am really surprised that having it in another thread actually does something different than not. Try printing out the name of the thread from the CSV code and see if I'm right, maybe we can work from there.

Similar Messages

  • Problem with JMenus that Persist - Is this a Java bug?

    I am having a problem with JMenus that persist. By this I mean
    that my drop down menus persist on the screen even after they have
    been selected.
    I've checked the Java bug database, and the following seems
    to come closest to my problem:
    Bug ID: 4235188
    JPopupMenus and JMenus persist when their JFrame becomes visible
    State: Closed, not a bug
    http://developer.java.sun.com/developer/bugParade/bugs/4235188.html
    This page says that the matter is closed and is not a bug. The
    resolution of this matter printed at the bottom of the page
    is completely abstruse to me and I would appreciate any
    comments to understand what they are talking about.
    The code at the end of my message illustrates my problem.
    1. Why should paintComponent() make any difference to
    Menu behavior?
    2. Is this a bug?
    3. What's the workaround if I have to paint() or repaint()?
    Thanks
    Tony Lin
    // Example of Menu Persistence Problem
    // Try running this with line 41, paintComponent(), and without line 41
    // Menus behave normally if line 41 is commented out
    // If line 41 exists, menus will persist after they have been selected
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class P2 extends JPanel {
    JMenuItem[] mi;
    public P2() {
    JFrame thisFrame = new JFrame();
    thisFrame.getContentPane().add(this);
    JMenu menu = new JMenu("My Menu");
    JMenuBar mb = new JMenuBar();
    mi = new JMenuItem[4];
    for (int i=0; i<mi.length; i++) {
    mi[i] = new JMenuItem("Menu Item " + String.valueOf(i));
    menu.add(mi);
    mb.add(menu);
    thisFrame.setJMenuBar(mb);
    thisFrame.setSize(400,200);
    thisFrame.setLocation(150,200);
    thisFrame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent we) {
    System.exit(0);
    thisFrame.setVisible(true);
    public void paintComponent(Graphics g) {} //Affects menu behavior!
    public static void main(String[] args) {
    new P2();

    Well, my understanding of the way painting works is that a component doesn't UNPAINT itself. Instead a message is sent to the component under the coordinates of the menu to REPAINT itself.
    In your demo program the JFrame is the component under the JMenu. The paintComponent() method of JFrame is empty, so nothing gets repainted.
    I added super.paintComponent(g); to the method and everything works fine.

  • I have problem with account that i can't make update or buy from app store There is massage appear in my payment page that i must contact with i tunes support to complete this transaction Please help me to fixe this problem as soon possible Hany hassan 00

    I have problem with account that i can't make update or buy from app store
    There is massage appear in my payment page that i must contact with i tunes support to complete this transaction
    Please help me to fixe this problem as soon possible
    Hany hassan
    0096597617317
    0096596677186
    Thank you

    You need to Contact iTunes Support...
    Apple  Support  iTunes Store  Contact Us

  • I have a late 2011 model MacBook Pro running Mountain Lion.  I love the AirPlay mirroring feature with Apple TV...BUT, how do I mirror with TVs that don't have Apple TV?  I used to run a cable from my mini display port to the HDMI input of a TV.

    I have a late 2011 model MacBook Pro running Mountain Lion.  I love the AirPlay mirroring feature with Apple TV...BUT, how do I mirror with TVs that don't have Apple TV?  I used to run a cable from my mini display port to the HDMI input of a TV.  This feature seems to be lost in the Mountain Lion upgrade.  Did Apple feel that once Mountain Lion came out that EVERYONE would have Apple TV?  There are no settings in System Preferences/Display like there used to be...only for AirPlay Mirroring.

    Running a cable to the HDMI port is still supported. (and still works on mine).
    If the Arrangement tab in System Preferences > Displays isn't present then it doesn't recognize the physical connection.  Double check all cables.  If that doesn't work try a PRAM reset:
    http://support.apple.com/kb/ht1379

  • I have one out of five email address's with coxmail that opens with a blank inbox but other browsers show the content of the same inbox

    Question
    I have one out of five email address's with coxmail that opens with a blank inbox. Other browsers like opera or IE show the content of the same inbox. I've contacted cox but they tell me the problem is on my computer. I've used three different anti virus/malware scanners to eliminate all the bugs they can find. I need a firefox guru with suggestions. Thanks, Charles

    You can undo your permission changes. Probably the most relevant one is cookies. Try one or both of these methods:
    (1) Page Info > Permissions tab
    While viewing a page on the site:
    * right-click and choose View Page Info > Permissions
    * Alt+t (open the classic Tools menu) > Page Info > Permissions
    (2) about:permissions
    In a new tab, type or paste '''about:permissions''' and press Enter. Allow a few moments for the list on the left to populate, as this information needs to be extracted from a database.
    Then type or paste ''rcn''' in the search box above the list to filter it to the most relevant domains. When you highlight a domain, you can adjust its permissions in the right pane.
    Any luck?

  • How to find table with colum that not support by data pump network_link

    Hi Experts,
    We try to import a database to new DB by data pump network_link.
    as oracle statement, Tables with columns that are object types are not supported in a network export. An ORA-22804 error will be generated and the export will move on to the next table. To work around this restriction, you can manually create the dependent object types within the database from which the export is being run.
    My question, how to find these tables with colum that that are object types are not supported in a network export.
    We have LOB object and oracle spital SDO_GEOMETRY object type. our database size is about 300G. nornally exp will takes 30 hours.
    We try to use data pump with network_link to speed export process.
    How do we fix oracle spital users type SDO_GEOMETRY issue during data pump?
    our system is 32 bit window 2003 and 10GR2 database.
    Thanks
    Jim
    Edited by: user589812 on Nov 3, 2009 12:59 PM

    Hi,
    I remember there being issues with sdo_geometry and DataPump. You may want to contact oracle support with this issue.
    Dean

  • How can I make an app with xcode that works like a news app? So that I can post articles on the app. Do I have to use a database or can I connect the app directly with my mac?

    How can I make an iphone app with xcode that worrks like a newspaper? So that I can post articles on the app while it is on appstore. Can I directly connect the app with my mac or do I have to connect it to a database?  Thanks

    Funny, I was thinking you'd want to use the prescribed deployment that Apple went to all the trouble to provide so you wouldn't trot down the garden path with some other implementation, only to find your app rejected with the admonition to use Newsstand after all...
    If you're all hot to ignore all that & DIY, why are you even asking...why not just go for it...

  • Question: Is there a way to create a PDF from outlook e-mail that does not embed the attachment? better, is there a way to convert the e-mail with attachement (not embeded) as pdf pages? - Problem: I have 1400 e-mails with attachments that need to be conv

    Is there a way to create a PDF from outlook e-mail that does not embed the attachment? better, is there a way to convert the e-mail with attachement (not embeded) as pdf pages?
    - Problem: I have 1400 e-mails with attachments that need to be converted into pdf and the attachments cannot be embeded.
    System: PC Windows 7 using Acrobat X Prof. - Thank you!

    Hi ,
    There is an option of embedding index for faster search while converting email to a PDF .
    However I am not sure that will serve your purpose or not .
    I would recommend you to get in touch with Microsoft support as well .
    Meanwhile I'll work on it and get back to you in case I get a desired solution .
    Regards
    Sukrit Dhingra

  • I have copied many photo's from another laptop to my Mac.  The older photo's are in directories with names that help me select what I need to view. I would like to have all my imported new photo's also bee added to the directory structure I have in Finder

    I have copied many photo's from another laptop to my Mac.  The older photo's are in directories with names that help me select what I need to view. I would like to have all my imported new photo's also bee added to the directory structure I have in Finder but my new photo's are all in iPhoto.  I want to use directories for storing and iPhoto for viewing.  Is this possible or do I need to have all my photo's in iPhoto??
    Mitch

    iPhoto is not a Photo Viewer. It's a Photo Manager and designed for looking after the files while you organise the Photos. It really works much better if you let it manage those files. If you use iPhoto you never go near those files because iPhoto is your start point for anything you want to do with your Photos - the point of the pplication.
    You can run iPhoto in Referenced mode, where it does not copy the files to the Library, but I caution you that you are making life a lot more difficult for yourself by doing that.
    How to, and some comments on why you shouldn't, are in this thread
    https://discussions.apple.com/thread/3062728?tstart=0
    Regards
    TD

  • Creative Zen with keys that don't play well.

    ,Creative Zen with keys that don't play well.uHello all,
    I have had a Creative Zen 6 GB for a couple of years. It is has not been a pretty picture. This product has been the most problematic mp3 player I have ever owned...but it has usually played music and I have been able to navigate the menus. A couple of months ago, the keys started to not respond very well. It almost seems like they are stiff and when I press them (not all, but most), they just don't do what they once did. If i keep on? mashing on the keys, eventually I can get it into working order enough to use, but what a royal pain this has been. I don't know if I should continue messing with it if there is physical damage, which it feels like. However, I have not used it that much and don't know what may have caused this, other than bouncing around in a gym bag.
    Anyone have any thoughts before it goes to the scrap heap?

    . It is physical damage & they just wear out. They wear out faster when they are pushed very hard. The control pad can be replaced. You can DYI or send to someone to repair. DYI? repair services

  • Can EJB 3.0 beans be used with tables that do not have a primary key?

    Can a EJB 3.0 persistence bean be used with tables that do not have a primary key defined? I am building a test application based on the HowTo - Building EJB 3.0 Faces App paper posted after Openworld (schalk). The issue I am running into when trying to run the application is: Exception Description: Entity class [class com.persistence.Rpthead] has no primary key specified. Note: I get a simular error when using toplink directly.
    The tables I am binding to do not have primary keys defined. They use unique constraints to manage the table integrity.
    Is it possible to use EJB 3.0 on tables without a primary key? If not, are there plans to support this in the future?

    The spec requires a primary key Id annotation. I will take your suggestion to EJB 3.0 expert group.
    Can you also send an email to [email protected] with your requirement?
    -Debu

  • Since i got the new Iphone 4s it constantly drops calls. Apple have replaced the phone with another new iphone 4s but i am still having the same problem. I have checked with vodapohe that there is no issue from there end, given a new sim, still drops out

    Since i got the new Iphone 4s it constantly drops calls. Apple have replaced the phone with another new iphone 4s but i am still having the same problem. I have checked with vodapohe that there is no issue from there end, given a new sim, still drops out

    Have a look at this it might help
    http://support.apple.com/kb/TS4148

  • I have a hard disk drive with data that i want to back up onto another hard disk drive. I tried just copy and it won't let me paste it in the new drive. I have also tried to drag the files across and they won't go across. Does anyone know how to do this?

    I have an external hard disk drive with data that I want to back up onto another extrnal hard disk drive. I have tried to copy and paste but this wont give me a paste option. I have also tried to click and drag but it wont let me either. I have reformatted the external hard drive to accept both mac and pc files and this did not make any difference. Can anyone help me with this?

    How did you reformat the drive? If you formatted it as NTFS, your Mac will not be able to write files to it unless you use a small application such as Paragon's.
    Please reply as to how you formatted the drive.
    Clinton

  • I have an iMac with Mavericks that is experiencing a lot of "spinning balls" from particularly Mail, Google Chrome, and Word. I took it to the Apple store and it was fast there, at home slow. I have been having internet speed issues, could it be that?

    I have a pretty new iMac with LOTS of storage (about 4TB with externals) that is experiencing a lot of "spinning balls of death" from time to time in almost any program that I might have open, but particularly MacMail, Google Chrome browsers, and Word. I took it to the Apple store to be checked out and it was really fast with no issues there. I brought it home and it was better at first but then it started happening again.
    I have been having a lot of issues with Time Warner where my download speeds will dip really low, and all I can think of is that MacMail goes and tries to check for email and can't get out to the internet and it locks all the other resources up while it is doing it. It will also take a REALLY long time to even let you look at mail. The folder size is over 13GB (down from 22GB that I just cleared out from - I have a lot of MP3s etc in there) and I will try to get this down to under 10GB which might help, and the mail is on an external drive. I have been told that Verizon is not a shared network but a direct connection to their server, and if I can't fix this then I will try switching to them. If anyone has any direct knowledge on this stuff, I am all ears.

    We need to know more about your system, please download EtreCheck and run the report and please post it on your next reply. Then we can see how your system is configured, what apps are on it and look for anything obvious. We will look forward to seeing your report.

  • I keep getting prompts to update my Firefox to 4.0.1 but I already use 4.0.1. What's wrong with Firefox that it keeps sending these?

    I keep getting prompts to update my Firefox to 4.0.1 but I already use 4.0.1. What's wrong with Firefox that it keeps sending these prompts and what can I do to stop them?

    I keep getting prompts to update my Firefox to 4.0.1 but I already use 4.0.1. What's wrong with Firefox that it keeps sending these prompts and what can I do to stop them?

Maybe you are looking for