java.awt.Frame Java Examples

The following examples show how to use java.awt.Frame. 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 File: StringRequester.java    From pdfxtk with Apache License 2.0 6 votes vote down vote up
public StringRequester(Frame parent, String title,
  String lines, String posText_, String negText) {
  
  super(parent, title, true);
  setLayout(new GridBagLayout());
  posText = posText_;
  
  add(new MultiLineLabel(lines), Awt.constraints(true));
  
  text = new TextField(30);
  add(text, Awt.constraints(true, 10, 4, GridBagConstraints.HORIZONTAL));
  
  Button pos = new Button(posText);
  add(pos, Awt.constraints(false, 10, 4, GridBagConstraints.HORIZONTAL));
  pos.addActionListener(this);
  
  Button neg = new Button(negText);
  add(neg, Awt.constraints(true, 10, 4, GridBagConstraints.HORIZONTAL));
  neg.addActionListener(this);
  
  pack();
}
 
Example #2
Source File: WindowsLeak.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Robot r = new Robot();
    for (int i = 0; i < 100; i++) {
        Frame f = new Frame();
        f.pack();
        f.dispose();
    }
    r.waitForIdle();

    Disposer.addRecord(new Object(), () -> disposerPhantomComplete = true);

    while (!disposerPhantomComplete) {
        Util.generateOOME();
    }

    Vector<WeakReference<Window>> windowList =
                    (Vector<WeakReference<Window>>) AppContext.getAppContext().get(Window.class);

    if (windowList != null && !windowList.isEmpty()) {
        throw new RuntimeException("Test FAILED: Window list is not empty: " + windowList.size());
    }

    System.out.println("Test PASSED");
}
 
Example #3
Source File: JTicketsBagSharedList.java    From nordpos with GNU General Public License v3.0 6 votes vote down vote up
public static JTicketsBagSharedList newJDialog(JTicketsBagShared ticketsbagshared) {
    
    Window window = getWindow(ticketsbagshared);
    JTicketsBagSharedList mydialog;
    if (window instanceof Frame) { 
        mydialog = new JTicketsBagSharedList((Frame) window, true);
    } else {
        mydialog = new JTicketsBagSharedList((Dialog) window, true);
    } 
    
    mydialog.initComponents();
    
    mydialog.jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35));
    
    return mydialog;
}
 
Example #4
Source File: BrissGUI.java    From Briss-2.0 with GNU General Public License v3.0 6 votes vote down vote up
private void setStateAfterClusteringFinished(ClusterDefinition newClusters, PageExcludes newPageExcludes,
                                             File newSource) {
    updateWorkingSet(newClusters, newPageExcludes, newSource);

    previewPanel.removeAll();
    mergedPanels = new ArrayList<MergedPanel>();

    for (PageCluster cluster : workingSet.getClusterDefinition().getClusterList()) {
        MergedPanel p = new MergedPanel(cluster, this);
        previewPanel.add(p);
        mergedPanels.add(p);
    }
    progressBar.setString(Messages.getString("BrissGUI.clusteringRenderingFinished")); //$NON-NLS-1$

    setIdleState(); //$NON-NLS-1$
    pack();
    setExtendedState(Frame.MAXIMIZED_BOTH);
    previewPanel.repaint();
    showPreview.setVisible(true);
    startCropping.setVisible(true);
    progressBar.setVisible(false);
    repaint();
}
 
Example #5
Source File: MissingEventsOnModalDialogTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void showModalDialog(Frame targetFrame) {

        Dialog dialog = new Dialog(targetFrame, true);

        dialog.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                passed = true;
                dialog.dispose();
            }
        });

        dialog.setSize(400, 300);
        dialog.setTitle("Modal Dialog!");

        clickOnModalDialog(dialog);
        dialog.setVisible(true);
    }
 
Example #6
Source File: DeadKeySystemAssertionDialog.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Frame frame = new Frame();
        frame.setSize(300, 200);

        TextField textField = new TextField();
        frame.add(textField);

        frame.setVisible(true);
        toolkit.realSync();

        textField.requestFocus();
        toolkit.realSync();

        // Check that the system assertion dialog does not block Java
        Robot robot = new Robot();
        robot.setAutoDelay(50);
        robot.keyPress(KeyEvent.VK_A);
        robot.keyRelease(KeyEvent.VK_A);
        toolkit.realSync();

        frame.setVisible(false);
        frame.dispose();
    }
 
Example #7
Source File: D3DGraphicsDevice.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void addFSWindowListener(Window w) {
    // if the window is not a toplevel (has an owner) we have to use the
    // real toplevel to enter the full-screen mode with (4933099).
    if (!(w instanceof Frame) && !(w instanceof Dialog) &&
        (realFSWindow = getToplevelOwner(w)) != null)
    {
        ownerOrigBounds = realFSWindow.getBounds();
        WWindowPeer fp = (WWindowPeer)realFSWindow.getPeer();

        ownerWasVisible = realFSWindow.isVisible();
        Rectangle r = w.getBounds();
        // we use operations on peer instead of component because calling
        // them on component will take the tree lock
        fp.reshape(r.x, r.y, r.width, r.height);
        fp.setVisible(true);
    } else {
        realFSWindow = w;
    }

    fsWindowWasAlwaysOnTop = realFSWindow.isAlwaysOnTop();
    ((WWindowPeer)realFSWindow.getPeer()).setAlwaysOnTop(true);

    fsWindowListener = new D3DFSWindowAdapter();
    realFSWindow.addWindowListener(fsWindowListener);
}
 
Example #8
Source File: ListRepaint.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    for (int i = 0; i < 10; ++i) {
        final Frame frame = new Frame();
        frame.setSize(300, 300);
        frame.setLocationRelativeTo(null);
        ListRepaint list = new ListRepaint();
        list.add("1");
        list.add("2");
        list.add("3");
        list.add("4");
        list.select(0);
        frame.add(list);
        frame.setVisible(true);
        sleep();
        list.test();
        frame.dispose();
    }
}
 
Example #9
Source File: BiomeExporterDialog.java    From amidst with GNU General Public License v3.0 6 votes vote down vote up
public BiomeExporterDialog(BiomeExporter biomeExporter, Frame parentFrame, BiomeProfileSelection biomeProfileSelection,
		Supplier<AmidstMenu> menuBarSupplier, Setting<String> lastBiomeExportPath) {
	// @formatter:off
	this.lastBiomeExportPath   = lastBiomeExportPath;
	this.biomeExporter         = biomeExporter;
	this.parentFrame           = parentFrame;
	this.menuBarSupplier       = menuBarSupplier;
	this.biomeProfileSelection = biomeProfileSelection;
	this.constraints           = new GridBagConstraints();
	this.labelPaneConstraints  = new GridBagConstraints();

	this.leftSpinner           = createCoordinateSpinner();
	this.topSpinner            = createCoordinateSpinner();
	this.rightSpinner          = createCoordinateSpinner();
	this.bottomSpinner         = createCoordinateSpinner();
	this.fullResCheckBox       = createFullResCheckbox();
	this.pathField             = createPathField();
	this.browseButton          = createBrowseButton();
	this.exportButton          = createExportButton();
	this.previewImage          = new BufferedImage(PREVIEW_SIZE, PREVIEW_SIZE, BufferedImage.TYPE_INT_ARGB);
	this.previewIcon           = new ImageIcon(new BufferedImage(PREVIEW_SIZE * 2, PREVIEW_SIZE * 2, BufferedImage.TYPE_INT_ARGB));
	this.previewLabel          = createPreviewLabel();
	this.dialog                = createDialog();
	// @formatter:on
}
 
Example #10
Source File: ScrollPanePreferredSize.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final Dimension expected = new Dimension(300, 300);
    final Frame frame = new Frame();
    final ScrollPane sp = new ScrollPane();
    sp.setSize(expected);
    frame.add(sp);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    final Dimension size = frame.getSize();
    if (size.width < expected.width || size.height < expected.height) {
        throw new RuntimeException(
                "Expected size: >= " + expected + ", actual size: " + size);
    }
    frame.dispose();
}
 
Example #11
Source File: WorldBrowserLine.java    From tectonicus with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public WorldBrowserLine(Frame parent)
{
	// Try and find a single player world to default to
	File worldDir = null;
	for (int i=0; i<5; i++)
	{
		File dir = Minecraft.findWorldDir(i);
		if (Minecraft.isValidWorldDir(dir.toPath()))
		{
			worldDir = dir;
			break;
		}
	}
	
	line = new FileBrowserLine(parent, "World: ", "Open", worldDir, JFileChooser.DIRECTORIES_ONLY, null);		
	line.setFileListener( new FileChangedHandler() );

	onInternalFileChanged();
}
 
Example #12
Source File: ListRepaint.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    for (int i = 0; i < 10; ++i) {
        final Frame frame = new Frame();
        frame.setSize(300, 300);
        frame.setLocationRelativeTo(null);
        ListRepaint list = new ListRepaint();
        list.add("1");
        list.add("2");
        list.add("3");
        list.add("4");
        list.select(0);
        frame.add(list);
        frame.setVisible(true);
        sleep();
        list.test();
        frame.dispose();
    }
}
 
Example #13
Source File: MaximizedNormalBoundsUndecoratedTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
boolean doTest() {
    Dimension beforeMaximizeCalled = new Dimension(300,300);

    frame = new Frame("Test Frame");
    frame.setUndecorated(true);
    frame.setFocusable(true);
    frame.setSize(beforeMaximizeCalled);
    frame.setVisible(true);
    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    frame.setExtendedState(Frame.NORMAL);

    Dimension afterMaximizedCalled= frame.getBounds().getSize();

    frame.dispose();

    if (beforeMaximizeCalled.equals(afterMaximizedCalled)) {
        return true;
    }
    return false;
}
 
Example #14
Source File: OpenTextFileListener.java    From collect-earth with MIT License 6 votes vote down vote up
public OpenTextFileListener(Frame owner, String filePath, String title) {
	
	this.filePath = filePath;
	dialog = new JDialog(owner, title + " " + filePath); //$NON-NLS-1$
	dialog.setLocationRelativeTo(owner);
	dialog.setSize(new Dimension(300, 400));
	dialog.setModal(true);

	final BorderLayout layoutManager = new BorderLayout();

	final JPanel panel = new JPanel(layoutManager);

	dialog.add(panel);

	disclaimerTextArea = new JTextArea();
	disclaimerTextArea.setEditable(false);
	disclaimerTextArea.setLineWrap(true);
	disclaimerTextArea.setWrapStyleWord(true);
	final JScrollPane scrollPane = new JScrollPane(disclaimerTextArea);
	panel.add(scrollPane, BorderLayout.CENTER);
	scrollPane.setPreferredSize(new Dimension(250, 250));

	final JButton close = new JButton(Messages.getString("CollectEarthWindow.5")); //$NON-NLS-1$
	close.addActionListener( e -> dialog.setVisible(false) );
	panel.add(close, BorderLayout.SOUTH);
}
 
Example #15
Source File: XFramePeer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
void preInit(XCreateWindowParams params) {
    super.preInit(params);
    Frame target = (Frame)(this.target);
    // set the window attributes for this Frame
    winAttr.initialState = target.getExtendedState();
    state = 0;
    undecorated = Boolean.valueOf(target.isUndecorated());
    winAttr.nativeDecor = !target.isUndecorated();
    if (winAttr.nativeDecor) {
        winAttr.decorations = winAttr.AWT_DECOR_ALL;
    } else {
        winAttr.decorations = winAttr.AWT_DECOR_NONE;
    }
    winAttr.functions = MWMConstants.MWM_FUNC_ALL;
    winAttr.isResizable = true; // target.isResizable();
    winAttr.title = target.getTitle();
    winAttr.initialResizability = target.isResizable();
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        log.fine("Frame''s initial attributes: decor {0}, resizable {1}, undecorated {2}, initial state {3}",
                 Integer.valueOf(winAttr.decorations), Boolean.valueOf(winAttr.initialResizability),
                 Boolean.valueOf(!winAttr.nativeDecor), Integer.valueOf(winAttr.initialState));
    }
}
 
Example #16
Source File: FileDialogForDirectories.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void init() {
    if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
        Sysout.createDialogWithInstructions(new String[]{
                "Press PASS, this test is for MacOS X only."});
        return;
    }

    System.setProperty("apple.awt.fileDialogForDirectories", "true");

    setLayout(new GridLayout(1, 1));

    fd = new FileDialog(new Frame(), "Open");

    showBtn = new Button("Show File Dialog");
    showBtn.addActionListener(this);
    add(showBtn);
    String[] instructions = {
            "1) Click on 'Show File Dialog' button. A file dialog will come up.",
            "2) Check that files can't be selected.",
            "3) Check that directories can be selected.",
            "4) Repeat steps 1 - 3 a few times for different files and directories.",
            "5) If it's true then the test passed, otherwise it failed."};
    Sysout.createDialogWithInstructions(instructions);
}
 
Example #17
Source File: MultiResolutionCursorTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void start() {
    //Get things going.  Request focus, set size, et cetera
    setSize(200, 200);
    setVisible(true);
    validate();

    final Image image = new MultiResolutionCursor();

    int center = sizes[0] / 2;
    Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
            image, new Point(center, center), "multi-resolution cursor");

    Frame frame = new Frame("Test Frame");
    frame.setSize(300, 300);
    frame.setLocation(300, 50);
    frame.add(new Label("Move cursor here"));
    frame.setCursor(cursor);
    frame.setVisible(true);
}
 
Example #18
Source File: MegaMekGUI.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent e) {
    // Update to reflect new skin
    if (e.getName().equals(GUIPreferences.SKIN_FILE)) {
        showMainMenu();
        frame.repaint();
    } else if (e.getName().equals(GUIPreferences.UI_THEME)) {
        try {
            UIManager.setLookAndFeel((String)e.getNewValue());
            // We went all Oprah and gave everybody frames...
            // so now we have to let everybody who got a frame
            // under their chair know that we updated our look
            // and feel.
            for (Frame f : Frame.getFrames()) {
                SwingUtilities.updateComponentTreeUI(f);
            }
            // ...and also all of our windows and dialogs, etc.
            for (Window w : Window.getWindows()) {
                SwingUtilities.updateComponentTreeUI(w);
            }
        } catch (Exception ex) {
            DefaultMmLogger.getInstance().error(getClass(), "preferenceChange(GUIPreferences.UI_THEME)", ex);
        }
    }
}
 
Example #19
Source File: TextAreaTwicePack.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final Frame frame = new Frame();
    final TextArea ta = new TextArea();
    frame.add(ta);
    frame.pack();
    frame.setVisible(true);
    sleep();
    final Dimension before = frame.getSize();
    frame.pack();
    final Dimension after = frame.getSize();
    if (!after.equals(before)) {
        throw new RuntimeException(
                "Expected size: " + before + ", actual size: " + after);
    }
    frame.dispose();
}
 
Example #20
Source File: MultiMonPrintDlgTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void executeTest() {

        GraphicsDevice defDev = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        int x = 0;
        Frame f = null;
        for (x = 0; x < gd.length; x ++) {
            if (gd[x] != defDev) {
                secFrame = new Frame("Screen " + x + " - secondary", gd[x].getDefaultConfiguration());
                f = secFrame;
            } else {
                primaryFrame = new Frame("Screen " + x + " - primary", gd[x].getDefaultConfiguration());
                f = primaryFrame;
            }
            Button b = new Button("Print");
            b.addActionListener(this);
            f.add("South", b);
            f.addWindowListener (new WindowAdapter() {
                public void windowClosing(WindowEvent we) {
                    ((Window) we.getSource()).dispose();
                }
            });
            f.setSize(200, 200);
            f.setVisible(true);
        }
    }
 
Example #21
Source File: bug7170657.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final int mask = InputEvent.META_DOWN_MASK | InputEvent.CTRL_MASK;

    Frame f = new Frame();

    MouseEvent mwe = new MouseWheelEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
                                         1, 1, 1);
    MouseEvent mdme = new MenuDragMouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1,
                                             true, null, null);
    MouseEvent me = new MouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
                                   MouseEvent.NOBUTTON);

    test(f, mwe);
    test(f, mdme);
    test(f, me);

    if (FAILED) {
        throw new RuntimeException("Wrong mouse event");
    }
}
 
Example #22
Source File: MaximizedToMaximized.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

       Frame frame = new Frame();
        final Toolkit toolkit = Toolkit.getDefaultToolkit();
        final GraphicsEnvironment graphicsEnvironment =
                GraphicsEnvironment.getLocalGraphicsEnvironment();
        final GraphicsDevice graphicsDevice =
                graphicsEnvironment.getDefaultScreenDevice();

        final Dimension screenSize = toolkit.getScreenSize();
        final Insets screenInsets = toolkit.getScreenInsets(
                graphicsDevice.getDefaultConfiguration());

        final Rectangle availableScreenBounds = new Rectangle(screenSize);

        availableScreenBounds.x += screenInsets.left;
        availableScreenBounds.y += screenInsets.top;
        availableScreenBounds.width -= (screenInsets.left + screenInsets.right);
        availableScreenBounds.height -= (screenInsets.top + screenInsets.bottom);

        frame.setBounds(availableScreenBounds.x, availableScreenBounds.y,
                availableScreenBounds.width, availableScreenBounds.height);
        frame.setVisible(true);

        Rectangle frameBounds = frame.getBounds();
        frame.setExtendedState(Frame.MAXIMIZED_BOTH);
        ((SunToolkit) toolkit).realSync();

        Rectangle maximizedFrameBounds = frame.getBounds();
        if (maximizedFrameBounds.width < frameBounds.width
                || maximizedFrameBounds.height < frameBounds.height) {
            throw new RuntimeException("Maximized frame is smaller than non maximized");
        }
    }
 
Example #23
Source File: InputVerifierTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void createDialog( )
{
    dialog = new TestDialog( new Frame(), "Instructions" );
    String[] defInstr = { "Instructions will appear here. ", "" } ;
    dialog.printInstructions( defInstr );
    dialog.setVisible(true);
    println( "Any messages for the tester will display here." );
}
 
Example #24
Source File: InputVerifierTest3.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void createDialog( )
{
    dialog = new TestDialog( new Frame(), "Instructions" );
    String[] defInstr = { "Instructions will appear here. ", "" } ;
    dialog.printInstructions( defInstr );
    dialog.setVisible(true);
    println( "Any messages for the tester will display here." );
}
 
Example #25
Source File: VSyncedBufferStrategyTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void createBS(boolean requestVSync) {
    if (bs != null && requestVSync == currentBSVSynced) {
        return;
    }

    BufferCapabilities bc = defaultBC;
    if (requestVSync) {
        bc = new sun.java2d.pipe.hw.ExtendedBufferCapabilities(
                new ImageCapabilities(true),
                new ImageCapabilities(true),
                FlipContents.COPIED,
                sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.VSYNC_ON);
    }
    try {
        createBufferStrategy(2, bc);
    } catch (AWTException e) {
        System.err.println("Warning: cap is not supported: "+bc);
        e.printStackTrace();
        createBufferStrategy(2);
    }
    currentBSVSynced = requestVSync;
    bs = getBufferStrategy();
    String s =
        getParent() instanceof Frame ?
            ((Frame)getParent()).getTitle() : "parent";
    System.out.println("Created BS for \"" + s + "\" frame, bs="+bs);
}
 
Example #26
Source File: SelectionInvisibleTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        Frame frame = new Frame();
        frame.setSize(300, 200);
        TextField textField = new TextField(TEXT + LAST_WORD, 30);
        Panel panel = new Panel(new FlowLayout());
        panel.add(textField);
        frame.add(panel);
        frame.setVisible(true);

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        toolkit.realSync();

        Robot robot = new Robot();
        robot.setAutoDelay(50);

        Point point = textField.getLocationOnScreen();
        int x = point.x + textField.getWidth() / 2;
        int y = point.y + textField.getHeight() / 2;
        robot.mouseMove(x, y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        toolkit.realSync();

        robot.mousePress(InputEvent.BUTTON1_MASK);
        int N = 10;
        int dx = textField.getWidth() / N;
        for (int i = 0; i < N; i++) {
            x += dx;
            robot.mouseMove(x, y);
        }
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        toolkit.realSync();

        if (!textField.getSelectedText().endsWith(LAST_WORD)) {
            throw new RuntimeException("Last word is not selected!");
        }
    }
 
Example #27
Source File: PageableTable.java    From jdal with Apache License 2.0 5 votes vote down vote up
@Override
public void mouseClicked(MouseEvent e) {
	Point point = e.getPoint();
	int row = table.rowAtPoint(point);
	int col = table.columnAtPoint(point);
	// check Actions
	if (col != -1 && row != -1 && tableModel.isActionColumn(col)) {
		TableRowAction action = (TableRowAction) tableModel.getValueAt(row, col);
		action.setTable(PageableTable.this);
		action.setRow(tableModel.getList().get(row));
		action.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "clicked"));
		
	}
	// check double click on rows
	if (row != -1 && e.getClickCount() == 2) {
		Object toEdit = tableModel.getList().get(row);
		Window dlg = getEditor(toEdit);
		if (dlg != null) {
			if (dlg instanceof Frame) {
				((Frame) dlg).setState(Frame.NORMAL);
				((Frame) dlg).requestFocus();
			}
			dlg.setLocationRelativeTo(null);
			dlg.setVisible(true);
		}
	}
}
 
Example #28
Source File: StrikeDisposalCrashTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void renderText(Frame frame, Font f1) {
    VolatileImage vi = frame.createVolatileImage(256, 32);
    vi.validate(frame.getGraphicsConfiguration());

    Graphics2D g = vi.createGraphics();
    g.setFont(f1);
    g.drawString(text, 0, vi.getHeight()/2);
    g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                       RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g.drawString(text, 0, vi.getHeight()/2);
    g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                       RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
    g.drawString(text, 0, vi.getHeight()/2);
    Toolkit.getDefaultToolkit().sync();
}
 
Example #29
Source File: EditableResources.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
void checkKey(String id) {
    JPasswordField password = new JPasswordField();
    if(currentPassword != null) {
        password.setText(currentPassword);
    }
    int v = JOptionPane.showConfirmDialog(java.awt.Frame.getFrames()[0], password, "Enter Password", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    if(v == JOptionPane.OK_OPTION) {
        currentPassword = password.getText();
        setPassword(currentPassword);
        try {
            key = currentPassword.getBytes("UTF-8");
        } catch (UnsupportedEncodingException ex) {
            ex.printStackTrace();
        }
        char l = (char)encode(id.charAt(0));
        char w = (char)encode(id.charAt(1));
        //keyOffset = 0;
        if(l != 'l' || w != 'w') {
            // incorrect password!
            JOptionPane.showMessageDialog(java.awt.Frame.getFrames()[0],
                    "Incorrect Password!", "Error", JOptionPane.ERROR_MESSAGE);
            throw new IllegalStateException("Incorrect password");
        }
        return;
    }
    super.checkKey(id);
}
 
Example #30
Source File: D3DGraphicsDevice.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the owning Frame for a given Window.  Used in setFSWindow below
 * to set the properties of the owning Frame when a Window goes
 * into fullscreen mode.
 */
private Frame getToplevelOwner(Window w) {
    Window owner = w;
    while (owner != null) {
        owner = owner.getOwner();
        if (owner instanceof Frame) {
            return (Frame) owner;
        }
    }
    // could get here if passed Window is an owner-less Dialog
    return null;
}