Java Code Examples for javax.swing.WindowConstants

The following examples show how to use javax.swing.WindowConstants. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: CQL   Source File: EasikFrame.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 *
 *
 * @param title
 */
public EasikFrame(String title) {
	super(title);

	getContentPane().setBackground(Color.white);

	_settings = Easik.getInstance().getSettings();

	this.addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent evt) {
			closeWindow();
		}
	});
	this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
}
 
Example 2
private static void showUI() {
    sFrame = new JFrame();
    sFrame.add(new JLabel("Some dummy content"));

    JMenuBar menuBar = new JMenuBar();

    sMenu = new JMenu("Menu");
    JMenuItem item = new JMenuItem("Item");
    sMenu.add(item);

    sMenuItem = new WeakReference<>(item);

    menuBar.add(sMenu);

    sFrame.setJMenuBar(menuBar);

    sFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    sFrame.pack();
    sFrame.setVisible(true);
}
 
Example 3
Source Project: usergrid   Source File: LogViewerFrame.java    License: Apache License 2.0 6 votes vote down vote up
public LogViewerFrame( App app ) throws IOException {
    super( "Log" );
    this.app = app;

    // Add a scrolling text area
    textArea.setEditable( false );
    textArea.setRows( 20 );
    textArea.setColumns( 50 );
    getContentPane().add( new JScrollPane( textArea ), BorderLayout.CENTER );
    pack();
    // setLocationRelativeTo(app.getLauncher());
    setLocation( 100, 100 );
    setDefaultCloseOperation( WindowConstants.HIDE_ON_CLOSE );
    setVisible( false );

    Log4jAppender appender = new Log4jAppender();
    Logger.getRootLogger().addAppender( appender );
}
 
Example 4
Source Project: LambdaAttack   Source File: MainGui.java    License: MIT License 6 votes vote down vote up
public MainGui(LambdaAttack botManager) {
    this.botManager = botManager;

    this.frame.setResizable(false);
    this.frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    setLookAndFeel();

    JPanel topPanel = setTopPane();
    JScrollPane buttonPane = setButtonPane();

    this.frame.add(topPanel, BorderLayout.PAGE_START);
    this.frame.add(buttonPane, BorderLayout.CENTER);
    this.frame.pack();
    this.frame.setVisible(true);

    LambdaAttack.getLogger().info("Starting program");
}
 
Example 5
Source Project: stendhal   Source File: ProgressLog.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a new ProgressLog.
 *
 * @param name name of the window
 */
ProgressLog(String name) {
	window = new JDialog(j2DClient.get().getMainFrame(), name);

	tabs = new JTabbedPane();
	tabs.setPreferredSize(new Dimension(PAGE_WIDTH, PAGE_HEIGHT));
	tabs.addChangeListener(new TabChangeListener());

	WindowUtils.closeOnEscape(window);
	window.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	window.add(tabs);
	window.pack();
	WindowUtils.watchFontSize(window);
	WindowUtils.trackLocation(window, "travel_log", true);

	WtWindowManager.getInstance().registerSettingChangeListener("ui.logfont",
			new SettingChangeAdapter("ui.logfont", FONT_NAME) {
		@Override
		public void changed(String newValue) {
			fontName = newValue;
			for (Page page : pages) {
				page.setFontName(newValue);
			}
		}
	});
}
 
Example 6
private void setupUI() {
    frame = new JFrame();
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    comboBox = new JComboBox<>(ITEMS);

    JPanel scrollable = new JPanel();
    scrollable.setLayout(new BoxLayout(scrollable, BoxLayout.Y_AXIS));

    scrollable.add(Box.createVerticalStrut(200));
    scrollable.add(comboBox);
    scrollable.add(Box.createVerticalStrut(200));

    scrollPane = new JScrollPane(scrollable);

    frame.add(scrollPane);

    frame.setSize(100, 200);
    frame.setVisible(true);
}
 
Example 7
Source Project: pcgen   Source File: PCGenFrame.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
private void initSettings()
{
	setSize(1060, 725); //this is the default frame dimensions

	setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
	addWindowListener(new WindowAdapter()
	{

		@Override
		public void windowClosing(WindowEvent e)
		{
			PCGenUIManager.closePCGen();
		}

	});
}
 
Example 8
void addWindow() {
  Bundle newB;
  final Bundle[] bl = Activator.desktop.getSelectedBundles();
  if(bl != null && bl.length > 0) {
    newB = bl[0];
  } else {
    newB = Activator.getTargetBC_getBundle(0);
  }
  final JMainBundles comp = new JMainBundles(newB);
  comp.frame = new JFrame(makeTitle(newB));
  comp.frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
  comp.frame.addWindowListener(new WindowAdapter() {
      @Override
      public void windowClosing(WindowEvent e) {
        comp.close();
      }
    });
  comp.frame.getContentPane().add(comp);
  comp.frame.pack();
  comp.frame.setVisible(true);

  windows.add(comp);
}
 
Example 9
Source Project: jdk8u_jdk   Source File: Popup401.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static void createAndShowGUI() {
    frame = new JFrame("HangPopupTest");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.setSize(1000, 1000);

    test = new Popup401();
    frame.add(test);
    frame.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentShown(ComponentEvent e) {
            super.componentShown(e);
            test.run();
            synchronized (testCompleted) {
                testCompleted.notifyAll();
            }
        }
    });
    frame.pack();
    frame.setVisible(true);
}
 
Example 10
Source Project: jdk8u_jdk   Source File: bug8136998.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void setupUI() {
    frame = new JFrame();
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    comboBox = new JComboBox<>(ITEMS);

    JPanel scrollable = new JPanel();
    scrollable.setLayout(new BoxLayout(scrollable, BoxLayout.Y_AXIS));

    scrollable.add(Box.createVerticalStrut(200));
    scrollable.add(comboBox);
    scrollable.add(Box.createVerticalStrut(200));

    scrollPane = new JScrollPane(scrollable);

    frame.add(scrollPane);

    frame.setSize(100, 200);
    frame.setVisible(true);
}
 
Example 11
Source Project: org.alloytools.alloy   Source File: OurDialog.java    License: Apache License 2.0 6 votes vote down vote up
/** Display a simple non-modal window showing some text. */
public static JFrame showtext(String title, String text) {
    JFrame window = new JFrame(title);
    JButton done = new JButton("Close");
    done.addActionListener(Runner.createDispose(window));
    JScrollPane scrollPane = OurUtil.scrollpane(OurUtil.textarea(text, 20, 60, false, false));
    window.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    window.getContentPane().setLayout(new BorderLayout());
    window.getContentPane().add(scrollPane, BorderLayout.CENTER);
    window.getContentPane().add(done, BorderLayout.SOUTH);
    window.pack();
    window.setSize(500, 500);
    window.setLocationRelativeTo(null);
    window.setVisible(true);
    return window;
}
 
Example 12
Source Project: osp   Source File: ComplexDataset.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Shows the phase legend.
 */
public JFrame showLegend() {
  InteractivePanel panel = new InteractivePanel();
  panel.setPreferredGutters(5, 5, 5, 25);
  DrawingFrame frame = new DrawingFrame(DisplayRes.getString("GUIUtils.PhaseLegend"), panel); //$NON-NLS-1$
  frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  frame.setJMenuBar(null);
  panel.addDrawable(new Phase());
  XAxis xaxis = new XAxis(DisplayRes.getString("ComplexDataset.Legend.XAxis")); //$NON-NLS-1$
  xaxis.setLocationType(XYAxis.DRAW_AT_LOCATION);
  xaxis.setEnabled(true); // enable the dragging
  panel.setClipAtGutter(false);
  panel.addDrawable(xaxis);
  panel.setSquareAspect(false);
  panel.setPreferredMinMax(-Math.PI, Math.PI, -1, 1);
  frame.setSize(300, 120);
  frame.setVisible(true);
  return frame;
}
 
Example 13
private static void showUI() {
    sFrame = new JFrame();
    sFrame.add(new JLabel("Some dummy content"));

    JMenuBar menuBar = new JMenuBar();

    sMenu = new JMenu("Menu");
    JMenuItem item = new JMenuItem("Item");
    sMenu.add(item);

    sMenuItem = new WeakReference<>(item);

    menuBar.add(sMenu);

    sFrame.setJMenuBar(menuBar);

    sFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    sFrame.pack();
    sFrame.setVisible(true);
}
 
Example 14
Source Project: wpcleaner   Source File: PageCommentsWindow.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create and display a PageCommentsWindow.
 * 
 * @param page Page.
 * @param wikipedia Wikipedia.
 */
public static void createPageCommentsWindow(
    final Page    page,
    EnumWikipedia wikipedia) {
  createWindow(
      "PageCommentsWindow",
      wikipedia,
      WindowConstants.DISPOSE_ON_CLOSE,
      PageCommentsWindow.class,
      new DefaultBasicWindowListener() {
        @Override
        public void initializeWindow(BasicWindow window) {
          if (window instanceof PageCommentsWindow) {
            PageCommentsWindow pageComments = (PageCommentsWindow) window;
            pageComments.page = page;
          }
        }
      });
}
 
Example 15
public static void createUI() {
    f = new JFrame("LinearGradient Printing Test");
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    final LinearGradientPrintingTest gpt = new LinearGradientPrintingTest();
    Container c = f.getContentPane();
    c.add(BorderLayout.CENTER, gpt);

    final JButton print = new JButton("Print");
    print.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PrinterJob job = PrinterJob.getPrinterJob();
            job.setPrintable(gpt);
            final boolean doPrint = job.printDialog();
            if (doPrint) {
                try {
                    job.print();
                } catch (PrinterException ex) {
                    throw new RuntimeException(ex);
                }
            }
        }
    });
    c.add(print, BorderLayout.SOUTH);

    f.pack();
    f.setVisible(true);
}
 
Example 16
Source Project: ImShow-Java-OpenCV   Source File: Imshow.java    License: Apache License 2.0 5 votes vote down vote up
public void setCloseOption(int option) {

		switch (option) {
		case 0:
			Window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
			break;
		case 1:
			Window.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
			break;
		default:
			Window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		}

	}
 
Example 17
Source Project: cstc   Source File: View.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) {
		JFrame frame = new JFrame("CSTC");
		frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		View view = new View();

		frame.setContentPane(view);
		frame.setSize(800, 600);
		frame.setVisible(true);
//		frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
	}
 
Example 18
/**
 * Show figure form
 */
public void showfigure() {        
    ChartForm form = new ChartForm(this.chartPanel);
    form.setSize(600, 500);
    form.setLocationRelativeTo(null);
    form.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    form.setVisible(true);
    this.chartPanel.paintGraphics();
}
 
Example 19
/**
 * Create and show map figure form
 */
public void showmap() {
    MapForm frame = new MapForm(this.mapLayout);
    frame.setSize(750, 540);
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.setVisible(true);
}
 
Example 20
/**
 * Show figure form
 */
public void show() {        
    ChartForm form = new ChartForm(this.charPanel);
    form.setSize(600, 500);
    form.setLocationRelativeTo(null);
    form.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    form.setVisible(true);
    this.charPanel.paintGraphics();
}
 
Example 21
/**
 * Create and show map figure form
 */
public void show() {
    MapForm frame = new MapForm(this.mapLayout);
    frame.setSize(750, 540);
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.setVisible(true);
}
 
Example 22
/**
 * Wrap chart into a frame with specific title and display the frame at provided
 * location.
 *
 * @param title    frame title
 * @param location frame location
 */
public void display (String title,
                     Point location)
{
    ChartFrame frame = new ChartFrame(title, chart, true);
    frame.pack();
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.setLocation(location);
    frame.setVisible(true);
}
 
Example 23
Source Project: osp   Source File: Launcher.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Exits this application.
 */
protected void exit() {
  if(!terminateApps()) {
    // change default close operation to prevent window closing
    final int op = frame.getDefaultCloseOperation();
    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    // restore default close operation later
    Runnable runner = new Runnable() {
      public void run() {
        frame.setDefaultCloseOperation(op);
      }

    };
    SwingUtilities.invokeLater(runner);
    return;
  }
  // HIDE_ON_CLOSE apps should exit
  if((OSPRuntime.applet==null)&&(frame.getDefaultCloseOperation()==WindowConstants.HIDE_ON_CLOSE)) {
    if (canExit) System.exit(0);
    else {
      exitCurrentApps(); // close existing programs
      frame.setVisible(false);
    }
  }
  // all applets and non-HIDE_ON_CLOSE apps should just hide themselves
  else {
    exitCurrentApps(); // close existing programs
    frame.setVisible(false);
  }
}
 
Example 24
private static void printTexture() {
    f = new JFrame("Texture Printing Test");
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    final TexturePaintPrintingTest gpt = new TexturePaintPrintingTest();
    Container c = f.getContentPane();
    c.add(BorderLayout.CENTER, gpt);

    final JButton print = new JButton("Print");
    print.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PrinterJob job = PrinterJob.getPrinterJob();
            job.setPrintable(gpt);
            final boolean doPrint = job.printDialog();
            if (doPrint) {
                try {
                    job.print();
                } catch (PrinterException ex) {
                    throw new RuntimeException(ex);
                }
            }
        }
    });
    c.add(print, BorderLayout.SOUTH);

    f.pack();
    f.setVisible(true);
}
 
Example 25
public static void createUI() {
    f = new JFrame("LinearGradient Printing Test");
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    final LinearGradientPrintingTest gpt = new LinearGradientPrintingTest();
    Container c = f.getContentPane();
    c.add(BorderLayout.CENTER, gpt);

    final JButton print = new JButton("Print");
    print.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PrinterJob job = PrinterJob.getPrinterJob();
            job.setPrintable(gpt);
            final boolean doPrint = job.printDialog();
            if (doPrint) {
                try {
                    job.print();
                } catch (PrinterException ex) {
                    throw new RuntimeException(ex);
                }
            }
        }
    });
    c.add(print, BorderLayout.SOUTH);

    f.pack();
    f.setVisible(true);
}
 
Example 26
public SourceSelectionDialog(PCGenFrame frame, UIContext uiContext)
{
	super(frame, true);
	this.frame = frame;
	setTitle(LanguageBundle.getString("in_mnuSourcesLoadSelect")); //$NON-NLS-1$
	this.tabs = new JTabbedPane();
	this.basicPanel = new QuickSourceSelectionPanel();
	this.advancedPanel = new AdvancedSourceSelectionPanel(frame, uiContext);
	this.buttonPanel = new JPanel();
	this.loadButton = new JButton();
	CommonMenuText.name(loadButton, "load"); //$NON-NLS-1$
	this.cancelButton = new JButton();
	CommonMenuText.name(cancelButton, "cancel"); //$NON-NLS-1$

	this.deleteButton = new JButton();
	CommonMenuText.name(deleteButton, "delete"); //$NON-NLS-1$
	this.installDataButton = new JButton();
	CommonMenuText.name(installDataButton, "mnuSourcesInstallData"); //$NON-NLS-1$
	this.saveButton = new JButton();
	CommonMenuText.name(saveButton, "saveSelection"); //$NON-NLS-1$
	this.alwaysAdvancedCheck = new JCheckBox(LanguageBundle.getString("in_sourceAlwaysAdvanced"), //$NON-NLS-1$
		!UIPropertyContext.getInstance().initBoolean(UIPropertyContext.SOURCE_USE_BASIC_KEY, true));
	setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
	initComponents();
	initDefaults();
	pack();
}
 
Example 27
Source Project: dragonwell8_jdk   Source File: bug8057893.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Robot robot = new Robot();
    robot.setAutoDelay(50);
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();

    EventQueue.invokeAndWait(() -> {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        JComboBox<String> comboBox = new JComboBox<>(new String[]{"one", "two"});
        comboBox.setEditable(true);
        comboBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if ("comboBoxEdited".equals(e.getActionCommand())) {
                    isComboBoxEdited = true;
                }
            }
        });
        frame.add(comboBox);
        frame.pack();
        frame.setVisible(true);
        comboBox.requestFocusInWindow();
    });

    toolkit.realSync();

    robot.keyPress(KeyEvent.VK_A);
    robot.keyRelease(KeyEvent.VK_A);
    robot.keyPress(KeyEvent.VK_ENTER);
    robot.keyRelease(KeyEvent.VK_ENTER);
    toolkit.realSync();

    if(!isComboBoxEdited){
        throw new RuntimeException("ComboBoxEdited event is not fired!");
    }
}
 
Example 28
/**
 * Creates the report progress dialog used to monitor the export.
 *
 * @return the created dialog.
 */
protected ReportProgressDialog createProgressDialog() {
  final ReportProgressDialog progressDialog = super.createProgressDialog();
  progressDialog.setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE );
  progressDialog.setMessage( resources.getString( "cvs-export.progressdialog.message" ) ); //$NON-NLS-1$
  progressDialog.pack();
  LibSwingUtil.positionFrameRandomly( progressDialog );
  return progressDialog;
}
 
Example 29
Source Project: hottub   Source File: bug8057893.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Robot robot = new Robot();
    robot.setAutoDelay(50);
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();

    EventQueue.invokeAndWait(() -> {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        JComboBox<String> comboBox = new JComboBox<>(new String[]{"one", "two"});
        comboBox.setEditable(true);
        comboBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if ("comboBoxEdited".equals(e.getActionCommand())) {
                    isComboBoxEdited = true;
                }
            }
        });
        frame.add(comboBox);
        frame.pack();
        frame.setVisible(true);
        comboBox.requestFocusInWindow();
    });

    toolkit.realSync();

    robot.keyPress(KeyEvent.VK_A);
    robot.keyRelease(KeyEvent.VK_A);
    robot.keyPress(KeyEvent.VK_ENTER);
    robot.keyRelease(KeyEvent.VK_ENTER);
    toolkit.realSync();

    if(!isComboBoxEdited){
        throw new RuntimeException("ComboBoxEdited event is not fired!");
    }
}
 
Example 30
private static void glyphTest() {
    frame = new JFrame("Test");
    frame.add(new MyComponent());
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.setSize(200, 200);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}