Is there a way to refresh?

Is there a way to refresh a window through a method? I've been using setVisible(boolean) to do so, but I was hoping that there was another way to do so.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.sound.sampled.AudioFormat;
import com.brackeen.javagamebook.sound.*;
import com.brackeen.javagamebook.input.*;
import com.brackeen.javagamebook.graphics.*;
import com.brackeen.javagamebook.test.*;
class DuelingScreen extends JFrame implements ActionListener
    private JButton exitButton, deckButton;
    private static int cardsHand = 5;
    private boolean starting = true;
    private static ImagePanel ip = new ImagePanel("Dueling Screen.jpg");
    protected GameAction exit;
    MYGOTCGD drawProgram = new MYGOTCGD ("Master of Dragons", false);
    String[] drawnCards = new String[50];
    AudioFormat PLAYBACK_FORMAT = new AudioFormat(44100, 16, 2, true, false);
        SoundManager soundManagerM = new SoundManager(PLAYBACK_FORMAT);
     public DuelingScreen()
          //Makes it Full Screen.
          setUndecorated(true);
          BorderLayout x = new BorderLayout(0, 500);
          ip.setLayout(x);
          JPanel buttonPanel = new JPanel();
          GridBagConstraints grid = new GridBagConstraints();
          //Creates the Exit Button.
          exitButton = createButton("Exit.jpg");
          deckButton = createButton("Deck.gif");
          grid.gridwidth = GridBagConstraints.SOUTH;
          //Sets the Location of the Title.
          ip.setLocation (0, 500);
          ip.addImage ("Field Zone.jpg", 53, 150);
          ip.addImage ("Monster Zone.jpg", 186, 150);
          ip.addImage ("Monster Zone.jpg", 319, 150);
          ip.addImage ("Monster Zone.jpg", 452, 150);
          ip.addImage ("Monster Zone.jpg", 585, 150);
          ip.addImage ("Monster Zone.jpg", 718, 150);
          ip.addImage ("Graveyard Zone.jpg", 851, 150);
          ip.addImage ("Fusion Zone.jpg", 53, 366);
          ip.addImage ("Trap Zone.jpg", 186, 366);
          ip.addImage ("Trap Zone.jpg", 319, 366);
          ip.addImage ("Trap Zone.jpg", 452, 366);
          ip.addImage ("Trap Zone.jpg", 585, 366);
          ip.addImage ("Trap Zone.jpg", 718, 366);
          ip.addImage ("Deck Zone.jpg", 851, 366);
          buttonPanel.setOpaque(false);
          exitButton.setBounds(767, 700, 256, 67);
          deckButton.setBounds(861, 376, 100, 140);
          buttonPanel.add(exitButton);
          buttonPanel.add(deckButton);
          buttonPanel.setLayout(null);
          ip.add(buttonPanel);
          //Adds it to the Content Pane.
          getContentPane().add(ip);
          //Makes it pop up.
          setExtendedState(MAXIMIZED_BOTH);
          //drawProgram.drawFive();
          addKeyListener(new KeyListener()
               public void keyPressed(KeyEvent event)
                    //Does nothing until released.
               public void keyReleased(KeyEvent event)
                    if (event.getKeyChar() == KeyEvent.VK_ESCAPE)
                         //Exits the program.
                         System.exit(0);
               public void keyTyped(KeyEvent event) {}
          exitButton.addActionListener(new ActionListener()
              public void actionPerformed(ActionEvent e)
                  soundManagerM.close();
                    new MenuScreen().setVisible(true);
                    dispose();
         deckButton.addActionListener(new ActionListener()
              public void actionPerformed(ActionEvent e)
                  if (starting)
                       for (int k = cardsHand; k > 0; k--)
                            System.out.println ("CARDS in HAND: "+cardsHand);
                            System.out.println ("K: "+k);
                            drawnCards[k] = drawProgram.drawOne();
                            int c = 622-k*117;
                            c += 117;
                            ip.addImage(drawnCards[k]+"2.jpg", c, 600);
                       starting = false;
                         new DuelingScreen().setVisible(true);
                         dispose();
                  else
                       cardsHand++;
                       System.out.println ("CARDS in HAND: "+cardsHand);
                       drawnCards[cardsHand] = drawProgram.drawOne();
                       int c = 622-cardsHand*117;
                           c += 117;
                           ip.addImage(drawnCards[cardsHand]+"2.jpg", c, 600);
                           new DuelingScreen().setVisible(true);
                         dispose();
     public Image loadImage(String fileName)
        return new ImageIcon(fileName).getImage();
     public JButton createButton(String name)
         String imagePath = name;
         ImageIcon iconRollover = new ImageIcon(imagePath);
         Cursor cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
         // create the button
         JButton button = new JButton();
         button.addActionListener(this);
         button.setIgnoreRepaint(true);
         button.setFocusable(false);
         button.setBorder(null);
         button.setContentAreaFilled(false);
         button.setCursor(cursor);
         button.setIcon(iconRollover);
         button.setRolloverIcon(iconRollover);
         button.setPressedIcon(iconRollover);
         return button;
       public void actionPerformed(ActionEvent e)
        Object src = e.getSource();
}

In the future, Swing related questions should be posted in the Swing forum.
The code you posted is of little use since it uses custom classes so we can't see the behaviour of your code.
In general if you add a component to a Container at run time then you just use
container.revalidate()
This will invoke the LayoutManager and repaint the components in the container based on the new layout.

Similar Messages

  • I have lost all artwork since the recent upgrade, is there a way to refresh the 160gb classic ?

    I have lost all artwork since the recent upgrade, is there a way to refresh the 160gb classic ?

    You'll have to restore the iPod to factory settings.  Then sync all your content from your iTunes library back over to it.
    B-rock

  • I bought a itunes card and regestered it on itunes. When they sent ito my emails i forgot my emails password. Is there a way of refreshing the card?

    I bought a itunes card and registered it on itunes. When they sent me a email i forgot my emails password. Is there a way of refreshing the card?

    iTunes Store: Invalid, inactive, or illegible codes - Support - Apple

  • Is there a way to refresh a subscribed calendar in iOS?

    I'm pretty confident at this point I'm out of luck, but I thought I'd ask the question with maybe different (or maybe not) phrasing than it has before.
    Basically, via iCal on Lion, I subscribed to a google calendar .ics feed. I set the refresh to every 5 minutes, plus I can manually refresh. When they add a new event, I get it pretty quickly using one of those methods.
    I have it set as an iCloud calendar, so I can see the subscription on my iPhone. However, when they add a new event, I do NOT see that show up on my iPhone at any particular interval.
    I've tried looking at my list of calendars and hitting the refresh button, but that's no help. The one thing that definitely works is to restart the phone, but that, of course, is not convenient.
    Is there a way to force iOS to refresh subscribed (not shared) calendars?
    Thanks.

    it looks like they took out the "Show" option under Mail settings completely and added a Flag choice instead. Don't know why.
    apple.com/feedback

  • Thumbnails wrong in Finder -- is there a way to refresh them?

    When I edit a photo in Preview the small thumbnail changes to a generic jpg icon (in list and column view,) and the larger thumbnail (in icon view) remains that of the photo before it was edited. I can't figure out any way to refresh the thumbnail directly. I've found a workaround is to import it into iPhoto then immediately export it; now the thumbnail appears correctly, but the teeny tiny thumbnail is still the generic jpg icon. This is making me crazy. There must be a way to refresh the icons?

    Just a suggestion: try this.
    Others may diss it.
    Try it anyway. It isn't a hack. If you like it, you'll no longer need to worry about the length of file names.

  • Is there a way to 'refresh' all the titles in iTunes?

    I recently accidentally deleted all my iTunes files.  I'm resigned to the fact that I'll have to import all my CDs again, and have already started this process.  The problem is that the old titles are all still there, but when I click on them it says they can't be played because the original file is missing.  Do I need to go through and delete all the unplayable titles and playlists manually, or is there a way to automatically delete the 'empty' titles?

    Not en masse, but if you select each element that has an overlay applied, there is a reset button at the bottom of the Overlay Creator window.

  • Is there any way to refresh the zfs snapshot other than creating another on

    Hi,
    I want to use the zfs send / recv replication, after I create the snapshot and do send/ recv to the remote filesystem, is there any way to do send and recv from the same snapshot after making some changes to the original filesystem other than creating another snapshot every time before send / recv
    Thanking you
    Ushas Symon

    No, you'd have to take another snapshot and then send it, but you don't need to save all the snapshots after you are done. If you script it out to take snapshots fairly often during the day, the amount of data would be small. You can also send to a file and then backup that file to tape or whatever, you wouldn't have to save a million snapshots. You can also look into OpenSolaris' Time Slider function.

  • Is there a way to refresh Messages in Mountain Lion?

    I have noticed a reoccurring issue in regards to the Messages app in Mountain Lion. It often times does not sync messages correctly. Or sometimes it has a long delay for receiving messages, and out of order. The messages app for ios has a pull down to refresh option, is there any similar feature for the Mac OS version? If there currently is how do you force a refresh?

    HI,
    At present the Out of Order iMessages is a "known Issue".
    The current best "fix" is to relaunch the app after an sync period has caught up.
    10:03 PM      Saturday; April 27, 2013
      iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.3)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • In C# is there a way of refreshing query in EXCEL (REFRESH ALL)

    Hi All,
    Need C# code in SSIS Sript task which should refresh all excel data which extracts from a table using Microsoft query.
    Can anyone help at all ?
    Thanks 
    Sri.Tummala

    Hi All,
    Found the code to refresh excel data the above code is saving before refrshing so I added application wait for 20 seconds so that it refrshes first than saves it.
    Microsoft SQL Server Integration Services Script Task
    Write scripts using Microsoft Visual C# 2008.
    The ScriptMain is the entry point class of the script.
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    using Microsoft.Office.Interop.Excel;
    namespace ST_53932a75e92c44f086535fc017a56e6a.csproj
    [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    #region VSTA generated code
    enum ScriptResults
    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    #endregion
    The execution engine calls this method when the task executes.
    To access the object model, use the Dts property. Connections, variables, events,
    and logging features are available as members of the Dts property as shown in the following examples.
    To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
    To post a log entry, call Dts.Log("This is my log text", 999, null);
    To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);
    To use the connections collection use something like the following:
    ConnectionManager cm = Dts.Connections.Add("OLEDB");
    cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";
    Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
    To open Help, press F1.
    public void Main()
    // TODO: Add your code here
    ExcelRefresh(@"C:\Documents and Settings\ST84879\Desktop\ROBERT_DATA_SET\TEST.xls");
    Dts.TaskResult = (int)ScriptResults.Success;
    private void ExcelRefresh(string Filename)
    object NullValue = System.Reflection.Missing.Value;
    Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
    excelApp.DisplayAlerts = false;
    Microsoft.Office.Interop.Excel.Workbook Workbook = excelApp.Workbooks.Open(
    Filename, NullValue, NullValue, NullValue, NullValue,
    NullValue, NullValue, NullValue, NullValue, NullValue,
    NullValue, NullValue, NullValue, NullValue, NullValue);
    Workbook.RefreshAll();
    System.Threading.Thread.Sleep(20000);
    Workbook.Save();
    Workbook.Close(false, Filename, null);
    excelApp.Quit();
    Workbook = null;
    System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
    Thanks All
    Sri.Tummala

  • While fetching the Audit Log Programmatically last Downloaded document is not fetched from Auditing Log. To update the events it is taking 5 to 10 mins. After that i can fetch the data. Is there any way to refresh the log to be reflected immediatly?

    SPAuditQuery wssQuery = new SPAuditQuery(SPContext.Current.Web.Site);
    wssQuery.RestrictToUser(SPContext.Current.Web.CurrentUser.ID);
    wssQuery.AddEventRestriction(SPAuditEventType.View);
    wssQuery.RestrictToList(list)       
    //set the query date range
    wssQuery.SetRangeEnd(DateTime.Now);
    wssQuery.SetRangeStart(DateTime.Now.AddMinutes(-30));// To get the last 30 Mins of data
    SPContext.Current.Web.Site.Audit.Update();
    SPContext.Current.Web.Update();                     
    SPAuditEntryCollection auditCol = SPContext.Current.Web.Site.Audit.GetEntries(wssQuery); 

    From your response, I understood that, The coding is okay. So no need to change the code.
    I am not sure what/How to be validated the Lag. Can you please suggest more on detail ?
    One more thing observed based on the below steps
    1. Downloaded 3 documents sequentially
    2. Gave pause for 15 seconds
    3. Downloaded next 2  documents sequentially
    4. Executed my above mentioned program
    Result : Fetched only first 3 documents, documents which are downloaded after pause is not retrieved
    5. Generated the custom report (or ) Do new Download
    Result : I can See 5 Documents (In case of 5th step is new download, I can See 5 Documents instead of 6 documents)
    6:  Executed my above mentioned program
    Result : I can See 5 Documents (In case of 5th step is new download, I can See 5 Documents instead of 6 documents)
    Conclusion: Most recent download event is pushed by other relevant(Custom Report Generation or Download or Page Refresh) event
    Am i Missing anything to obtain the proper result ?

  • Is there any way to turn my Bluetooth LED on again?

    My Bluetooth is working (send/receive).
    But the Bluetooth LED indicator doesn't on.
    Anyone got the same problem?
    Z60m 2529 EAU
    Bluetooth Firmware's version is 299 and the software is 7kbf09ww.

    I thought that too, but I am 100% sure it is not now.
    I made it light on again some times, by reinstall XP and did some configure of wireless and Bluetooth.
    I just can't make it light on again in the recent couple try.
    I am thinking about the firmware problems.
    ( After I got problem with Bluetooth firmware update, some times ago. I got this problem)
    Is there any way to refresh my Bluetooth firmware back to version 208?
    Bluetooth is working fine. Just don't feel good about that indicator is not working.

  • Way to refresh cache for only one service

    Is there a way to refresh cache for only one service?
    Rewards points guaranteed.
    Regards.

    Is this really a problem? Why not invalidating the cache alt all
    when it seems to be necessary?
    regards
    Tobias

  • Is there a way to change the pictures that I have showing up as a screensaver on Apple TV?

    I have all pictures selected in iTunes, but it keeps showing the same ones over and over. Is there a way to refresh which ones are shown? Thanks.

    Settings > Screensaver > Photos, scroll down to computers were you should see the ones you've chosen to home share in iTunes.

  • Is there a way to force adf to not refresh the page after a certain action?

    Hi Adf'rs
    Another question for ya.
    I'm not sure how possible this is? But I have piece of javascript code that runs after the adf page is loaded. I then execute something in my javascript when the user cliciks a NON ADF button (just an html button). At that point, adf is refreshing the entire page even though I don't want it to. Is there a way to tell adf not to do this?

    Hi Puthanampatt,
    Thank you soooo much!! That did the trick!! Now, when I submit my javascript, it only refreshes the components that my javascript manipulates, and that container does not reload!!!
    Thanks again!!!

  • Is there a way to automatically refresh a webpage in Firefox 3.6.10?

    hi there,
    I am hoping the Firefox team can help with a small problem, is there a way of automatically refreshing webpages within Firefox 3.6.10 and 4.06 beta? We are building an interesting website at the moment and the client is using Firefox 3.6.10to view the site. Each time they go onto the new website to see the changes we have done, they are shown old pages. We need to rectify this problem as quickly as possible, for our client without requesting that they refresh the page each time they go onto the site.

    You can do that by changing a hidden preference.
    # Type '''about:config''' into the location bar and press enter
    # Accept the warning message that appears, you will be taken to a list of preferences
    # In the filter box type '''browser.cache''' to bring up a small number of preferences
    # Double-click on the preference '''browser.cache.check_doc_frequency''' and change its value to '''1'''
    For more details on that preference see http://kb.mozillazine.org/Browser.cache.check_doc_frequency

Maybe you are looking for

  • How to create a multi-level configuration sales order?

    Hi,     My client use configurable material to sell computers. And the production mode is MTO. One sales order item correspond with a production order     Now my client also sell array which consist of two computers, two storage, one UPS power etc. T

  • How to intercept touchscreen events

    Hi,Everyone I can use RegisterRawInputDevices, Monitor global Touch events, but is there any way you can intercept it? I try to write a touch screen gestures Software , used to control the desktop environment does not support touch software. Anything

  • IDoc to File interface

    Hi Experts Team, My scenario is IDoc to File interface. I need to create 12 different files based on the Plant code (WERKS). At the end of the day, i need to ftp the file to different locations. How can I do the design and is there any need for BPM h

  • Chart Display

    Hi Friends, I am facing problem with the chart. Problem: If data is small then chart is displaying fine but if data is huge, chart was disappering. Can anybody fix this issue.I am using BI7 Regards Madhu

  • Pixel limitations for GPU, running a PB filter in Photoshop?

    Hi there: I have searched but can't seem to locate any discussion of image dimensions limitations when using Pixel Bender filters in Photoshop. I loaded an image of 7000x3500 pixels into Photoshop CS4, went to open the Pixel Bender gallery, and got t