All Downloads are FREE. Search and download functionalities are using the official Maven repository.

editor.util.ProgressWindow Maven / Gradle / Ivy

There is a newer version: 1.18.1
Show newest version
package editor.util;

import editor.Scheme;

import javax.swing.*;
import java.awt.*;

public class ProgressWindow extends JWindow
{
  private Window _window;

  public ProgressWindow( ProgressPanel panel )
  {
    super( getFrameWindow() );
    configUI( panel );
  }

  private static Frame getFrameWindow()
  {
    Window activeWindow = EditorUtilities.getActiveWindow();
    if( activeWindow == null )
    {
      return getActiveFrameFromApp();
    }
    if( activeWindow instanceof Frame )
    {
      return (Frame)activeWindow;
    }
    return (Frame)activeWindow.getOwner();
  }

  private static Frame getActiveFrameFromApp()
  {
    Frame[] frames = Frame.getFrames();
    for( int i = 0; i < frames.length; i++ )
    {
      Frame frame = frames[i];
      if( frame.isShowing() )
      {
        return frame;
      }
    }
    return null;
  }

  private void configUI( ProgressPanel panel )
  {
    ContainerMoverSizer contentPane = new ContainerMoverSizer( null );
    contentPane.setLayout( new BorderLayout() );
    contentPane.setBackground( Scheme.active().getWindow() );
    setContentPane( contentPane );
    add( panel, BorderLayout.CENTER );
  }

  public void show()
  {
    pack();
    /*
    if( getWidth() < 400 )
    {
      setSize( 400, getHeight() );
    }
    */

    EditorUtilities.centerWindowInFrame( this, getOwner() );
    super.show();

    _window = EditorUtilities.getActiveWindow();
    if( _window != null )
    {
      _window.setEnabled( false );
    }
  }

  public void dispose()
  {
    if( _window != null )
    {
      _window.setEnabled( true );
    }

    setVisible( false );
    super.dispose();
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy