JLabel in a JFrame delayed Rendering. How do i render first then continue?

i have a snippent of code:
JDialog msg_window;
     public void create_window(JPanel contentPane, JLabel jLabel1) {
          msg_window= new JDialog();
          contentPane=(JPanel)msg_window.getContentPane();
          contentPane.setLayout(null);
          jLabel1.setBounds(48,16,133,18);
          contentPane.add(jLabel1);
          msg_window.setContentPane(contentPane);
          msg_window.setSize(222,85);
          msg_window.setLocation(300,252);
          msg_window.setTitle(jLabel1.getText());
          msg_window.setVisible(true);
that creates a JDialog box. My intentions are to display this dialog box while another part of the program is attempting to load the JTDS database driver. The driver loading seems to temporarily distract the VM. What happens is the box will render, but the JLabel will not until the driver is loaded ( at which point the box disapears).
How can i make sure the JDialog and all it's components fully rendered before proceding with then next step in the program?

This example just uses the extra thread to burn cpu cycles and updat a JLabel on the dialog, but shows interaction between modal dialog and an external thread.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class LoadDialog extends JDialog
    JLabel statusLbl;
    public LoadDialog(JFrame parent )
        super( parent );
        setTitle("Loadinig ");
        JPanel cp = new JPanel();
        cp.setLayout( new BorderLayout());
        cp.add( new JLabel("Please Wait") , BorderLayout.NORTH );
        statusLbl = new JLabel("Counter =     ");
        cp.add( statusLbl, BorderLayout.SOUTH );
        setContentPane( cp );
        pack();
        Runnable runner = new Runnable()
            public void run()
                for( int i = 0; i < 1000000; i++ )
                    for( int j = 1; j < 1000; j++ )
                        int x = 200 * i / j;
                    final int count = i;
                    try
                        SwingUtilities.invokeAndWait( new Runnable()
                                                          public void run()
                                                              statusLbl.setText( "Counter = "+count );
                    catch( Exception exc )
                        exc.printStackTrace();
        setModal( true );
        Thread t = new Thread( runner );
        t.start();
        setLocationRelativeTo( parent );
        setVisible( true );
    public static void main(String[] args) throws Exception
        try
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        catch( Exception e )
        final JFrame f = new JFrame("Threaded Dialog");
        JPanel cp = new JPanel();
        JButton button = new JButton( "Load");
        cp.add( button );
        button.addActionListener( new ActionListener()
                                      public void actionPerformed( ActionEvent e )
                                          new LoadDialog( f );
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setContentPane(cp);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
}For your problem, you I would recommend you thread off the file load and use invokeLater or invokeAndWait to dismis the dialog and pass the loaded file back to the main app.
Hope this helps,
Todd

Similar Messages

  • FCP 7 quit rendering audio selection. Render all audio continues to work

         FCP 7 simply quit performing audio render.  One minute it worked and the next it didn't (either with keyboard command or dropdown menu).  I can still get audio rendered by using the render all audio drop down menu but it's much more time consuming to do the dropdown menu.
         Any suggestions would be greatly appreciated.  Thanks.

    Try trashing your preferences using this.
    http://www.digitalrebellion.com/prefman/
    DM

  • Moving JLabel in a JFrame

    Hi .
    I want to move a JLabel in a JFrame and i set bounds for JLalbe using while
    such as :
    JLabel lb=new JLabel("JLABEL");
    int x=50,;
    int y=0;
    int w=60;
    int h=40;
    lb.setBounds(x,y,w,h) ;
    while(y<100)
    lb.setBounds(x,y,z,t);
    y+=1;
    But when lb moves in JFrame , it has vertical line its color is Color of lb ?
    what should i do to solve this problem ?

    Do you have an override of your paintComponent and do you call super.paintComponent from it?
    It probably has to do with the fact that you are trying to pig all the CPU cycles and not allowing other processing in your thread, try this:
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.Timer;
    public class Junk extends JFrame implements ActionListener{
      private int dX = 1;
      private int dY = 1;
      public int x = 1;
      public int y = 1;
      public JLabel l = null;
      public Timer t = null;
      Junk(){
        t = new Timer(10, this);
      public static void main(String[] args){
        Junk f = new Junk();
        f.setTitle("Junk X.x");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setLayout(null);
        f.setSize(600, 600);
        f.l = new JLabel("This is a JLabel");
        f.l.setSize(100, 30);
        f.add(f.l);
    //    f.pack();
        f.setVisible(true);
        f.t.start();
      public void actionPerformed(ActionEvent e){
        if((x+l.getWidth()) >= this.getWidth() || x == 0) dX *= (-1);
        if((y+l.getHeight()) >= this.getHeight() || y == 0) dY *= (-1);
         x += dX;
         y += dY;
         l.setLocation(x, y);
    }The timer gives the GUI time to update.
    BTW: yes, I know I should have used a JPanel. Mmmm... brain dead late night coding....

  • How to see render/encode time for individual comps rendered in AME?

    After rendering a number of comps in AME, following the new recommended workflow for H.264, I don't see any display of how long each render was. I do see a total for all the encodes at the top of the AME window. In the AE Render Queue, I can see when each render was started, and how long it took to complete.
    Where can I get that information in AME?

    Hi Experts,
    Request your valuable inputs and support on achieving the above requirements.
    Looking forward for your responses.
    Thanks,
    Bhargav

  • OS X - on startup iphoto and excel start up casuing delays. How do I control programs at upon startup

    OS X - on startup iphoto and excel start up causing delays. How do I control programs at upon startup
    Thanks for any assistance.

    sys / prefs /users and groups. if iphoto and excel are present in the login items then simply check the sidebar as to prevent them starting up.
    if they are not simply add them and do the above.

  • How do you render specific parts of timeline without rendering the whole sequence? cs5

    New to CS5 Premiere pro, im trying to render certain sections of my timeline without rendering the whole timeline, in Avid you would just mark in and mark out the area you wanted to render, is there something similar to that or do you always have to render the whole timeline?

    Place Work Area Bar over the part of the timeline you want to render and then hit Sequence/Render Whole Work Area.
    If you mean Export also place work area bar over section and make sure in the export settings, Source Range (bottom left) is set to Work Area.

  • How to set the first row as selected in single selection of table

    when the page renders how do we make the first row as selected for single selection in a table.
    Thansk a lot for your help

    set the selection Attribute's value to 'Y' for the first row. Thats enough.
    eg;
    Row row=vo.first();
    row.setAttribute("SelectionAttribute", "Y");
    --Prasanna                                                                                                                                                                                                                                                                                                                                           

  • How can i render one facet in panel splitter based on conditions?

    Jdeveloper Version - 11.1.1.5
    How can i render one facet in panel splitter based on conditions?
    Ex : In horizontal Panel splitter first facet - af table
    second facet - af table
    if any one table estimated row count is zero i nedd to render the respective facet?
    is it possible?
    Please help..
    Thanks
    sk

    Yes you can do it but not on facet you can apply rendered attribute to the any of the child component of the facet.
    Thanks
    Raghav

  • How to set render true or false in java class

    Use case:
    i have a page in which i have one inputListOfValues attributes and two LOV .initial the LOV render attribute value is false .it means it show only one attribute in run time .inputListOfValues is content two value .suppose if first value A then the first LOV have to show and is it value is B then Second LOV have to show .i bind my LOV to class .but i do not know how to set render attribute at java class.

    <af:inputListOfValues label="Branch Name"
    popupTitle="Search and Result Dialog"
    id="ilov1"
    model="#{pageFlowScope.organizationLOV.param['bindings.Organization'].listOfValuesModel}"
    converter="#{pageFlowScope.organizationLOV.param['bindings.Organization'].convert['latinDesc']}"
    valueChangeListener="#{viewScope.salaryBenefitsReportForm.branchChange}"
    binding="#{viewScope.salaryBenefitsReportForm.branchName}"
    rendered="true" visible="false"/>
    <af:inputListOfValues label="Department Name"
    popupTitle="Search and Result Dialog"
    id="ilov2"
    model="#{pageFlowScope.objectLOV.param['bindings.Department'].listOfValuesModel}"
    converter="#{pageFlowScope.objectLOV.param['bindings.Department'].convert['latinDesc']}"
    valueChangeListener="#{viewScope.salaryBenefitsReportForm.departmentChange}"
    binding="#{viewScope.salaryBenefitsReportForm.departmentName}"
    rendered="true" visible="false"/>
    this is code in jsff .
    and class code are following
    public void reportBy(ValueChangeEvent valueChangeEvent) {
    String value=(String)valueChangeEvent.getNewValue();
    System.out.println(value);
    if(value.equals("Branch")){
    branchName.setVisible(true);
    departmentName.setVisible(false);
    AdfFacesContext.getCurrentInstance().addPartialTarget(branchName);
    AdfFacesContext.getCurrentInstance().addPartialTarget(departmentName);
    if(value.equals("Department")){
    departmentName.setVisible(true);
    branchName.setVisible(false);
    AdfFacesContext.getCurrentInstance().addPartialTarget(departmentName);
    AdfFacesContext.getCurrentInstance().addPartialTarget(branchName);
    }

  • How to Conditionally Render Command link within af:forEach

    Hi,
    We have a requirement to conditionally Display/Hide CommandLink item in af:forEach Loop.And this customization is on the Fusion Compensation applications
    <af:forEach items="#{bindings.RegionalAreaPVO.rangeSet}" var="parent">
    <af:spacer height="10" id="s1"/>
    <af:commandLink inlineStyle="font-weight:bold;" text="#{parent.ItemName}" partialSubmit="true" actionListener="#{backingBeanScope.RegionalAreaBean.launchTaskflow}" id="cl1" rendered="#{backingBeanScope.XXWFCRegionalAreaBean.modelEligibleflag eq true}">
    <af:setActionListener from="#{parent.Code}" to="#{parentNode}"/>
    </af:commandLink>
    </af:forEach>
    I have added a Cutom Managed Bean Class and Returning boolean value to Control Render property which is working. But now i want to add business Logic based on 'parent.ItemName' or 'parentNode' Values in the bean method to return proper Boolean value.
    But i am unable to get the Current Iteration values in the bean method.
    I am using below EL expressions to get the values. But no luck.
    String nameel = (String)ADFUtil.evaluateEL("#{bindings.parent.ItemName}");
    String codeel = (String)ADFUtil.evaluateEL("#{parent.Code}");
    String nodeEl = (String)ADFUtil.evaluateEL("#{parentNode}");
    Also, i have tried getting the Row object like below but i am getting the First row details always. My intention is to get Current row values and use them for Business logic.
    ViewRowImpl row =
    (ViewRowImpl)ADFUtil.evaluateEL("#{bindings." + VoName +
    "Iterator.currentRow}");
    String code = (String)row.getAttribute("Code");
    Third option i have tried is to add a dummy Outputtext and have assigned #parent.Code as Value. Idea is to find Component of OutPut text in managed Bean and get the value of it. If Value is say "Model" i want to add more Logic and return true/false accordingly. In this also, i am getting all occurences of Output text in Managed bean and i a unable to identify Current Iterator Index.
    Any help is highly appreciated on how can i render Command link Conditionally based on forEach Loop values and Index.
    Thanks
    Kaja

    I have used Condition expression in Render Property to resolve this.

  • How does weblogic render shell?

    Hi,
    how does weblogic render shell?
    below is my shell file fragment,
    <netuix:head/>
    <netuix:body>
    <netuix:header>
    <netuix:jspContent contentUri="/framework/skeletons/header/pageHeader.jsp"/>
    </netuix:header>
    <netuix:jspContent contentUri="/framework/skeletons/navigation/topMenu.jsp" />
    <netuix:jspContent contentUri="/framework/skeletons/navigation/leftMenu.jsp"/>
    <netuix:footer>
    <netuix:jspContent contentUri="/framework/skeletons/footer/pageFooter.jsp"/>
    </netuix:footer>
    </netuix:body>
    Do all jsp (pageHeader.jsp, topMenu.jsp, leftMenu.jsp, pageFooter.jsp) rendered parallaly or they rendered as per the flow (as they defined in shell)?
    If I set any request attribute in head.jsp or pageHeader.jsp, will it be available in topMenu.jsp or leftMenu.jsp?

    The test-frequency-seconds property specifies the number of seconds between tests of unused connections. WebLogic Server tests unused connection and reopens any faulty connections. You must also set the Test Table Name.
    The seconds-to-trust-an-idle-pool-connection property specifies the number of seconds within a connection use that WebLogic Server trusts that the connection is still viable and will skip the connection test during the periodic connection testing process.

  • How does weblogic render portal skeleton jsps?

    Hi,
    how does weblogic render shell?
    below is my shell file fragment,
    <netuix:head/>
    <netuix:body>
    <netuix:header>
    <netuix:jspContent contentUri="/framework/skeletons/header/pageHeader.jsp"/>
    </netuix:header>
    <netuix:jspContent contentUri="/framework/skeletons/navigation/topMenu.jsp" />
    <netuix:jspContent contentUri="/framework/skeletons/navigation/leftMenu.jsp"/>
    <netuix:footer>
    <netuix:jspContent contentUri="/framework/skeletons/footer/pageFooter.jsp"/>
    </netuix:footer>
    </netuix:body>
    Do all jsp (pageHeader.jsp, topMenu.jsp, leftMenu.jsp, pageFooter.jsp) rendered parallaly or they rendered as per the flow (as they defined in shell)?
    If I set any request attribute in head.jsp or pageHeader.jsp, will it be available in topMenu.jsp or leftMenu.jsp?

    Ellen,
    I am not clear about your question.
    User A will only see the data which is retrieved based on it's principal
    name (I assume you use principal name as an argument to retrieve the data
    from DB).
    If you are using p13n cache make sure the principal name is part of the key.
    Please provide more details if you see that I did not understand your
    question.
    Regards,
    Michael Goldverg
    "ellen" <[email protected]> wrote in message
    news:3d6e46ef$[email protected]..
    >
    My application has multiple portlets which need to display very sensitiveuser
    data.
    These portlets read user principles from session (e.g. <weblogic:getproperty>)
    and make calls to an EJB to retrieve data from database and display theseuser
    specific data.
    I didn't specify any synchronize in my code. My concern is when two useraccess
    the portlet at the exact same time, will user A see user B's data?
    Any suggestions or general guide lines about synchronize in portal will bevery
    helpful.
    Thanks,
    Ellen
    These portlet (.jsp file)

  • How to display/render JTable?

    Can anyone show me how to display/render a JTable with most compact codes.
    Just set size, Scrollable. No need for manipulation, or others.
    JTable has been created:
    JTable table = new JTable(rows, columns);
    I have read the tutorial: http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#editrender
    But they are still really complex. I do not need many functions, just display.
    Thx

    xcomme wrote:
    I have tried for hours:
    table.setPreferredScrollableViewportSize(new Dimension(300, 80));
    table.setGridColor(Color.black);
    table.setVisible(true);
    None of them works.
    A JTable is a Swing component. Swing components have to be displayed as children of a frame object, typically JFrame, JDialog or the like. JTable, in particular, really expects to be part of a JScrollPane component. If you try and display it without you won't get a header.
    The minimal steps to see a JTable:
    Create a JFrame object set it's size and position with setBounds(). Get it's content pane with getContentPane()
    Set a layout manager, I suggest a BorderLayoutManager to start with, it's about the simplest to use.
    Create your JTable
    Wrap it in a JScrollPane.
    Add the JScrollPane to the content pane. Use BorderLayout.CENTER as the second argument of the add.
    Call setVisible(true) on the JFrame.
    The standard way to organise this is to create a subclass of JFrame and set up the content in the constructor or an initGui method.

  • How do i render in FInal Cut Express? Every time i click render all the load box pops up for about a second and then disappears :(

    how do i render in final cut express? I am a film student and i've been using final cut for 2 years i have never had this problem. i click render all and the load bar comes up for a second and then flashes away, leaving all my shots unrendered? what is this? how do i fix this?:((

    Go to menu toolbar and to Sequence>Render All and ensure that all the items you need rendered are checked.
    Good luck,
    Russ

  • How long did your first wireless back up take??

    After doing the initial back up via ethernet, how long did your first wireless back up take?? I can't seem to get past the preparing stage. However I have recently learned that the first time backing up wirelessly, the finder indexes the back up & this can take a while. I'm leaving it a little longer now. It has been preparing for about half an hour now.
    Is this normal?
    How long does this indexing take?
    What are your experiences?
    Thanks.

    So far for me it's been five days. I hooked up Time Capsule Thursday night, and after monitoring the progress for a few hours, I calculated that it should take three days, which I figured would mean that it should finish up by Sunday evening. (My MacBookPro had 103 gigs on it.)
    It would have been nice if the instructions that came with the **** thing said something up front about hooking up via an ethernet cable for the initial backup. If I had seen those instructions before I started this nightmare, I might be done by now. Instead I started the backup wirelessly, which I'm sure accounts for some of the delay and hassle.
    Unfortunately, the backup pace slowed steadily over the course of the weekend. By Saturday night, it had only done about 60 gigabyites, and by Sunday afternoon, it was only up to around 65. At that pace I figured I might be waiting another week before it finished, and since I actually take my computer with me when I leave my house, this would have deprived me of my computer for an unacceptable period. After doing some internet research and learning that using an ethernet cable would speed up the process, I therefore stopped the wireless backup, hooked up a cable, and restarted it at around 4 p.m. on Sunday afternoon.
    The backup then proceeded steadily at a faster (although not exactly zippy) pace. By midnight it had gotten through about 60 gigabytes, and after timing the rate at which it was proceeding by that time, I estimated that it should finish sometime around 8 p.m. tonight (Monday).
    I left the computer along during the day while I ran errands away from home. When I got back around 6:30, it appeared to have finished the initial backup and to be in the process of finishing up an incremental backup. The progress bar said "backing up 12,443 items...51.3 MB of 51.3 MB." Unfortunately, it seems to be stuck there. It's now 8 p.m., and it still says it's working on those 51.3 MB. I don't know how much longer I should wait before deciding that it's frozen.
    I'd like to just set this thing on fire. I bought the Time Capsule because I liked the idea of wireless, automatic backups. It was supposed to make my life easier, not make it a living ****.

Maybe you are looking for

  • Iomega external hard drive not appearing in Disk Utility

    I have a MacBook Pro (from 2011) and I'm running OS X 10.9.5. I have an old Iomega external hard drive. I'm not certain but this thing might be about 3-4 years old? When I connect the drive to my MBP, it shows up in Finder under Devices. But what app

  • Eprint= Ajax submit failed: error = 403, Forbidden

    i have a photosmart b210 and my laptop is a macintosh but the issue is not with the printer but with the eprint wireless site. i can't sign in using my email and password. i get this message Ajax submit failed: error =403, Forbidden. when i put my em

  • Preparing photos for iPhone 4 - resolution and aspect ratio

    Is there an optimum photo size when preparing photos for display on the iPhone 4 or does the iPhone optimize the size automatically upon import? Also, what is the recommended aspect ratio?

  • Album Artwork is gone

    Yes I know I have another topic exactly like this one, but I didn't really fully explain it. What going on, is the area where the artwork is pitch black and there's no scroll bar to browse through them or anything. To aid me is a screenshot: http://i

  • Can we Implement TREX for searching of PO in SRM?

    Hello Experts, Can we implement TREX for searching of purchase order in SRM portal? I dont want to use SAP NW Enterprise search 7.2 tool using which we can directly search B.O. in SRM. I want to implement it using TREX in SRM portal.