Search in sources :

Example 1 with Frame

use of java.awt.Frame in project pcgen by PCGen.

the class CharacterHPDialog method showHPDialog.

public static void showHPDialog(Component parent, CharacterFacade character) {
    Frame frame = JOptionPane.getFrameForComponent(parent);
    CharacterHPDialog dialog = new CharacterHPDialog(frame, character);
    Utility.setComponentRelativeLocation(frame, dialog);
    dialog.setVisible(true);
}
Also used : Frame(java.awt.Frame)

Example 2 with Frame

use of java.awt.Frame in project pcgen by PCGen.

the class PostLevelUpDialog method showPostLevelUpDialog.

/**
	 * Display the post levelling dialog for a character. This will display a 
	 * list of levels just added along with the hit points and skill points 
	 * gained. The hit points gained may be edited.
	 * 
	 * @param parent The component we should appear above.
	 * @param character The character that has been levelled up.
	 * @param oldLevel The character's level before the level up action.
	 */
public static void showPostLevelUpDialog(Component parent, CharacterFacade character, int oldLevel) {
    int size = character.getCharacterLevelsFacade().getSize();
    if (size - oldLevel + 1 < 1) {
        return;
    }
    Frame frame = JOptionPane.getFrameForComponent(parent);
    PostLevelUpDialog dialog = new PostLevelUpDialog(frame, character, oldLevel);
    Utility.setComponentRelativeLocation(frame, dialog);
    dialog.setVisible(true);
}
Also used : Frame(java.awt.Frame)

Example 3 with Frame

use of java.awt.Frame in project voltdb by VoltDB.

the class Transfer method _main.

/**
     * @throws IllegalArgumentException for the obvious reason
     */
void _main(String[] arg) {
    /*
         ** What function is asked from the transfer tool?
         */
    iTransferMode = TRFM_TRANSFER;
    if (arg != null) {
        if (arg.length != 1) {
            throw new IllegalArgumentException();
        }
        if ((arg[0].toLowerCase().equals("-r")) || (arg[0].toLowerCase().equals("--restore"))) {
            iTransferMode = TRFM_RESTORE;
        } else if ((arg[0].toLowerCase().equals("-d")) || (arg[0].toLowerCase().equals("--dump"))) {
            iTransferMode = TRFM_DUMP;
        } else if ((arg[0].toLowerCase().equals("-h")) || (arg[0].toLowerCase().equals("--help"))) {
            System.out.println(Transfer.SYNTAX_MSG);
            return;
        } else {
            throw new IllegalArgumentException();
        }
    }
    fMain = new Frame("HSQL Transfer Tool");
    imgEmpty = createImage(new MemoryImageSource(2, 2, new int[4 * 4], 2, 2));
    fMain.setIconImage(imgEmpty);
    fMain.addWindowListener(this);
    fMain.setSize(640, 480);
    fMain.add("Center", this);
    MenuBar bar = new MenuBar();
    String[] extras = { "Insert 10 rows only", "Insert 1000 rows only", "Insert all rows", "-", "Load Settings...", "Save Settings...", "-", "Exit" };
    Menu menu = new Menu("Options");
    addMenuItems(menu, extras);
    bar.add(menu);
    fMain.setMenuBar(bar);
    initGUI();
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension size = fMain.getSize();
    // (ulrivo): full size on screen with less than 640 width
    if (d.width >= 640) {
        fMain.setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
    } else {
        fMain.setLocation(0, 0);
        fMain.setSize(d);
    }
    fMain.setVisible(true);
    CurrentTransfer = CurrentAlter = 0;
    try {
        if ((iTransferMode == TRFM_DUMP) || (iTransferMode == TRFM_TRANSFER)) {
            sourceDb = new TransferDb(ConnectionDialog.createConnection(fMain, "Source Database"), this);
            if (!sourceDb.isConnected()) {
                exit();
                return;
            }
        } else {
            FileDialog f = new FileDialog(fMain, "Restore FileName", FileDialog.LOAD);
            f.show();
            String sFileName = f.getFile();
            String Path = f.getDirectory();
            if ((sFileName == null) || (sFileName.equals(""))) {
                exit();
                return;
            } else {
                sourceDb = new TransferSQLText(Path + sFileName, this);
            }
        }
        if ((iTransferMode == TRFM_RESTORE) || (iTransferMode == TRFM_TRANSFER)) {
            targetDb = new TransferDb(ConnectionDialog.createConnection(fMain, "Target Database"), this);
            if (!targetDb.isConnected()) {
                exit();
                return;
            }
        } else {
            FileDialog f = new FileDialog(fMain, "Dump FileName", FileDialog.SAVE);
            f.show();
            String sFileName = f.getFile();
            String Path = f.getDirectory();
            if ((sFileName == null) || (sFileName.equals(""))) {
                exit();
                return;
            } else {
                targetDb = new TransferSQLText(Path + sFileName, this);
            }
        }
    } catch (Exception e) {
        exit();
        e.printStackTrace();
        return;
    }
    if ((iTransferMode == TRFM_DUMP) || (iTransferMode == TRFM_TRANSFER)) {
        iSelectionStep = SELECT_SOURCE_CATALOG;
        sSourceCatalog = null;
    } else {
        iSelectionStep = SELECT_DEST_CATALOG;
        sDestCatalog = null;
    }
    ProcessNextStep();
    fMain.show();
    return;
}
Also used : Frame(java.awt.Frame) MenuBar(java.awt.MenuBar) Menu(java.awt.Menu) Dimension(java.awt.Dimension) MemoryImageSource(java.awt.image.MemoryImageSource) FileDialog(java.awt.FileDialog)

Example 4 with Frame

use of java.awt.Frame in project jdk8u_jdk by JetBrains.

the class MultimonFullscreenTest method actionPerformed.

public void actionPerformed(ActionEvent ae) {
    GraphicsDevice dev = deviceMap.get(ae.getSource());
    System.err.println("Setting FS on device:" + dev);
    final Window fsWindow;
    if (useFSWindow) {
        fsWindow = new Window(this, dev.getDefaultConfiguration()) {

            public void paint(Graphics g) {
                renderDimensions(g, getBounds(), this.getGraphicsConfiguration());
            }
        };
    } else if (useFSDialog) {
        fsWindow = new Dialog((Frame) null, "FS Dialog on device " + dev, false, dev.getDefaultConfiguration());
        fsWindow.add(new Component() {

            public void paint(Graphics g) {
                renderDimensions(g, getBounds(), this.getGraphicsConfiguration());
            }
        });
    } else {
        fsWindow = new Frame("FS Frame on device " + dev, dev.getDefaultConfiguration()) {

            public void paint(Graphics g) {
                renderDimensions(g, getBounds(), this.getGraphicsConfiguration());
            }
        };
        if (addHWChildren) {
            fsWindow.add("South", new Panel() {

                public void paint(Graphics g) {
                    g.setColor(Color.red);
                    g.fillRect(0, 0, getWidth(), getHeight());
                }
            });
            fsWindow.add("North", new Button("Button, sucka!"));
        }
    }
    fsWindow.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1) {
                done = true;
                fsWindow.dispose();
            }
        }
    });
    fsWindow.addWindowListener(new WindowHandler());
    dev.setFullScreenWindow(fsWindow);
    if (dmChange && dev.isDisplayChangeSupported()) {
        DisplayMode[] dms = dev.getDisplayModes();
        DisplayMode myDM = null;
        for (DisplayMode dm : dms) {
            if (dm.getWidth() == 800 && dm.getHeight() == 600 && (dm.getBitDepth() >= 16 || dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) && (dm.getRefreshRate() >= 60 || dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN)) {
                myDM = dm;
                break;
            }
        }
        if (myDM != null) {
            System.err.println("Setting Display Mode: " + myDM.getWidth() + "x" + myDM.getHeight() + "x" + myDM.getBitDepth() + "@" + myDM.getRefreshRate() + "Hz on device" + dev);
            dev.setDisplayMode(myDM);
        } else {
            System.err.println("Can't find suitable display mode.");
        }
    }
    done = false;
    if (runRenderLoop) {
        Thread updateThread = new Thread(new Runnable() {

            public void run() {
                BufferStrategy bs = null;
                if (useBS) {
                    fsWindow.createBufferStrategy(2);
                    bs = fsWindow.getBufferStrategy();
                }
                while (!done) {
                    if (useBS) {
                        Graphics g = bs.getDrawGraphics();
                        renderDimensions(g, fsWindow.getBounds(), fsWindow.getGraphicsConfiguration());
                        bs.show();
                    } else {
                        fsWindow.repaint();
                    }
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                    }
                }
                if (useBS) {
                    bs.dispose();
                }
            }
        });
        updateThread.start();
    }
}
Also used : Window(java.awt.Window) Frame(java.awt.Frame) MouseEvent(java.awt.event.MouseEvent) BufferStrategy(java.awt.image.BufferStrategy) MouseAdapter(java.awt.event.MouseAdapter) Graphics(java.awt.Graphics) DisplayMode(java.awt.DisplayMode) Panel(java.awt.Panel) GraphicsDevice(java.awt.GraphicsDevice) Button(java.awt.Button) Dialog(java.awt.Dialog) Component(java.awt.Component)

Example 5 with Frame

use of java.awt.Frame in project jdk8u_jdk by JetBrains.

the class DisplayModeChanger method main.

public static void main(String[] args) throws InterruptedException, InvocationTargetException {
    final GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    EventQueue.invokeAndWait(new Runnable() {

        public void run() {
            Frame f = null;
            if (gd.isFullScreenSupported()) {
                try {
                    f = new Frame("DisplayChanger Frame");
                    gd.setFullScreenWindow(f);
                    if (gd.isDisplayChangeSupported()) {
                        DisplayMode dm = findDisplayMode(gd);
                        if (gd != null) {
                            gd.setDisplayMode(dm);
                        }
                    }
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException ex) {
                        ex.printStackTrace();
                    }
                    gd.setFullScreenWindow(null);
                } finally {
                    if (f != null) {
                        f.dispose();
                    }
                }
            }
        }
    });
}
Also used : DisplayMode(java.awt.DisplayMode) Frame(java.awt.Frame) GraphicsDevice(java.awt.GraphicsDevice)

Aggregations

Frame (java.awt.Frame)276 Dialog (java.awt.Dialog)36 Dimension (java.awt.Dimension)35 JFrame (javax.swing.JFrame)30 Window (java.awt.Window)29 WindowEvent (java.awt.event.WindowEvent)26 JDialog (javax.swing.JDialog)25 Point (java.awt.Point)23 WindowAdapter (java.awt.event.WindowAdapter)23 Container (java.awt.Container)22 File (java.io.File)22 Robot (java.awt.Robot)21 Graphics (java.awt.Graphics)20 IOException (java.io.IOException)19 Component (java.awt.Component)18 Panel (java.awt.Panel)18 JPanel (javax.swing.JPanel)17 FileDialog (java.awt.FileDialog)16 JButton (javax.swing.JButton)16 BorderLayout (java.awt.BorderLayout)15