Example usage for java.awt Window repaint

List of usage examples for java.awt Window repaint

Introduction

In this page you can find the example usage for java.awt Window repaint.

Prototype

public void repaint() 

Source Link

Document

Repaints this component.

Usage

From source file:Main.java

/**
 * {@link Window#pack() Packs} the given window and positions it so that its
 * center stays the same./*w w w  . j av  a 2  s . c om*/
 *
 * @param window
 *            The window to pack and recenter
 */
public static void repackCentered(Window window) {
    Point center = getCenter(window.getBounds());
    window.pack();
    window.setLocation((center.x - window.getWidth() / 2), (center.y - window.getHeight() / 2));
    window.repaint();
}

From source file:com.diversityarrays.kdxplore.trials.TrialExplorerPanel.java

private void handleServiceDetected(String msgTitle, Trial trial, TrialDataEditorService service) {
    CurationParams params = new CurationParams();
    params.title = msgTitle;// w  w  w  . j a  v  a2  s  .  c  o  m
    params.trial = trial;
    params.offlineData = offlineData;
    params.messageLogger = messageLogger;
    params.component = TrialExplorerPanel.this;
    params.windowOpener = windowOpener;

    long start = System.currentTimeMillis();

    Consumer<Either<InitError, TrialDataEditorResult>> onComplete = new Consumer<Either<InitError, TrialDataEditorResult>>() {
        @Override
        public void accept(Either<InitError, TrialDataEditorResult> either) {

            long elapsed = System.currentTimeMillis() - start;
            Shared.Log.i(TAG, "doEditTrial.generateResult: Time to load trialData for trialId#"
                    + params.trial.getTrialId() + "=" + elapsed + " ms");

            if (either.isRight()) {
                TrialDataEditorResult result = either.right();

                result.curationData.addSamplesSavedListener(samplesSavedListener);

                result.frame.addWindowListener(new WindowAdapter() {
                    @Override
                    public void windowClosed(WindowEvent e) {
                        result.frame.removeWindowListener(this);

                        result.curationData.removeSamplesSavedListener(samplesSavedListener);

                        Window ownerWindow = GuiUtil.getOwnerWindow(TrialExplorerPanel.this);
                        if (ownerWindow != null) {
                            ownerWindow.toFront();
                            ownerWindow.repaint();
                        }
                    }
                });

                GuiUtil.ensureMaximized(result.frame);
            } else {
                InitError initError = either.left();
                if (initError.throwable == null) {
                    messageLogger.e(TAG, params.title);
                    MsgBox.error(TrialExplorerPanel.this, initError.message,
                            trial.getTrialName() + ": Unable to create editor");
                } else {
                    Throwable error = initError.throwable;
                    messageLogger.e(TAG, params.title, error);
                    MsgBox.error(TrialExplorerPanel.this, error.getMessage(),
                            trial.getTrialName() + ": Unable to create editor");
                }
            }
        }
    };
    service.createUserInterface(backgroundRunner, params, onComplete);
}

From source file:org.pgptool.gui.ui.tools.UiUtils.java

/**
 * Hack to make sure window is visible. On windows it's sometimes created but on
 * a background. User can see "flashing" icon in a task bar but window stays on
 * a background./*from  www .  j  a  v  a  2  s.  c o  m*/
 * 
 * PRESUMING: setVisible(true) was already called
 * 
 * More ion tihs jere:
 * http://stackoverflow.com/questions/309023/how-to-bring-a-window-to-the-front
 */
public static void makeSureWindowBroughtToFront(Window window) {
    // int state = dialog.getExtendedState();
    // state &= ~JFrame.ICONIFIED;
    // dialog.setExtendedState(state);
    window.setAlwaysOnTop(true);
    window.toFront();
    window.requestFocus();
    window.setAlwaysOnTop(false);
    window.repaint();
}