类javax.swing.WindowConstants源码实例Demo

下面列出了怎么用javax.swing.WindowConstants的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: CQL   文件: EasikFrame.java
/**
 *
 *
 * @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);
}
 
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);
}
 
源代码3 项目: usergrid   文件: LogViewerFrame.java
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 );
}
 
源代码4 项目: LambdaAttack   文件: MainGui.java
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");
}
 
源代码5 项目: stendhal   文件: ProgressLog.java
/**
 * 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);
			}
		}
	});
}
 
源代码6 项目: openjdk-jdk8u-backup   文件: bug8136998.java
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);
}
 
源代码7 项目: pcgen   文件: PCGenFrame.java
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();
		}

	});
}
 
源代码8 项目: knopflerfish.org   文件: GraphDisplayer.java
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);
}
 
源代码9 项目: jdk8u_jdk   文件: Popup401.java
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);
}
 
源代码10 项目: jdk8u_jdk   文件: bug8136998.java
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);
}
 
源代码11 项目: org.alloytools.alloy   文件: OurDialog.java
/** 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;
}
 
源代码12 项目: osp   文件: ComplexDataset.java
/**
 * 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;
}
 
源代码13 项目: openjdk-jdk9   文件: ScreenMenuMemoryLeakTest.java
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);
}
 
源代码14 项目: wpcleaner   文件: PageCommentsWindow.java
/**
 * 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;
          }
        }
      });
}
 
源代码15 项目: jdk8u_jdk   文件: LinearGradientPrintingTest.java
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);
}
 
源代码16 项目: ImShow-Java-OpenCV   文件: Imshow.java
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);
		}

	}
 
源代码17 项目: cstc   文件: View.java
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);
	}
 
源代码18 项目: MeteoInfo   文件: MeteoInfoScript.java
/**
 * 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();
}
 
源代码19 项目: MeteoInfo   文件: MeteoInfoScript.java
/**
 * 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);
}
 
源代码20 项目: MeteoInfo   文件: MeteoInfoPlot.java
/**
 * 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();
}
 
源代码21 项目: MeteoInfo   文件: MeteoInfoMap.java
/**
 * 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);
}
 
源代码22 项目: audiveris   文件: ChartPlotter.java
/**
 * 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);
}
 
源代码23 项目: osp   文件: Launcher.java
/**
 * 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);
  }
}
 
源代码24 项目: dragonwell8_jdk   文件: TexturePaintPrintingTest.java
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);
}
 
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);
}
 
源代码26 项目: pcgen   文件: SourceSelectionDialog.java
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();
}
 
源代码27 项目: dragonwell8_jdk   文件: bug8057893.java
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!");
    }
}
 
源代码28 项目: pentaho-reporting   文件: CSVTableExportPlugin.java
/**
 * 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;
}
 
源代码29 项目: hottub   文件: bug8057893.java
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!");
    }
}
 
源代码30 项目: TencentKona-8   文件: MissingGlyphTest.java
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);
}
 
 类所在包
 类方法
 同包方法