Example usage for java.awt Frame setTitle

List of usage examples for java.awt Frame setTitle

Introduction

In this page you can find the example usage for java.awt Frame setTitle.

Prototype

public void setTitle(String title) 

Source Link

Document

Sets the title for this frame to the specified string.

Usage

From source file:GraphicsInfo.java

public static void main(String args[]) {
    Frame f = new GraphicsInfo();
    f.setTitle("GraphicsInfo");
    f.setSize(300, 250);/*from w w  w .  j  a  v  a2  s  .c  o m*/
    f.show();
}

From source file:ConvolveIt.java

public static void main(String args[]) {
    Frame f = new ConvolveIt();
    f.setTitle("ConvolveIt");
    f.setSize(300, 250);//from w w  w. j a  va 2  s .  c o m
    f.show();
}

From source file:ClassForName.java

public static void main(String[] av) {
    Class c = null;//from  w ww . j  av  a  2  s  .co  m
    Object o = null;
    try {
        // Load the class, return a Class for it
        c = Class.forName("java.awt.Frame");
        // Construct an object, as if new Type()
        o = c.newInstance();
    } catch (Exception e) {
        System.err.println("That didn't work. " + " Try something else" + e);
    }
    if (o != null && o instanceof Frame) {
        Frame f = (Frame) o;
        f.setTitle("Testing");
        f.setVisible(true);
    } else
        throw new IllegalArgumentException("Huh? What gives?");
}

From source file:Snippet156.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("SWT Image");
    ImageData data;/*from  w  w  w .j  a  v  a2s.  co m*/
    if (args.length > 0) {
        String fileName = args[0];
        data = new ImageData(fileName);
    } else {
        data = createSampleImage(display);
    }
    final Image swtImage = new Image(display, data);
    final BufferedImage awtImage = convertToAWT(data);
    final Image swtImage2 = new Image(display, convertToSWT(awtImage));
    shell.addListener(SWT.Paint, new Listener() {
        public void handleEvent(Event e) {
            int y = 10;
            if (swtImage != null) {
                e.gc.drawImage(swtImage, 10, y);
                y += swtImage.getBounds().height + 10;
            }
            if (swtImage2 != null) {
                e.gc.drawImage(swtImage2, 10, y);
            }
        }
    });
    Frame frame = new Frame() {
        public void paint(Graphics g) {
            Insets insets = getInsets();
            if (awtImage != null) {
                g.drawImage(awtImage, 10 + insets.left, 10 + insets.top, null);
            }
        }
    };
    frame.setTitle("AWT Image");
    shell.setLocation(50, 50);
    Rectangle bounds = swtImage.getBounds();
    shell.setSize(bounds.width + 50, bounds.height * 2 + 100);
    Point size = shell.getSize();
    Point location = shell.getLocation();
    Insets insets = frame.getInsets();
    frame.setLocation(location.x + size.x + 10, location.y);
    frame.setSize(size.x - (insets.left + insets.right), size.y - (insets.top + insets.bottom));
    frame.setVisible(true);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    if (swtImage != null)
        swtImage.dispose();
    if (swtImage2 != null)
        swtImage.dispose();
    frame.dispose();
    System.exit(0);
}

From source file:AWTBufferedImageSWTImage.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("SWT Image");
    ImageData data;//from  w ww  .j a  v a2s  . c om
    if (args.length > 0) {
        String fileName = args[0];
        data = new ImageData(fileName);
    } else {
        data = createSampleImage(display);
    }
    final Image swtImage = new Image(display, data);
    final BufferedImage awtImage = convertToAWT(data);
    final Image swtImage2 = new Image(display, convertToSWT(awtImage));
    shell.addListener(SWT.Paint, new Listener() {
        public void handleEvent(Event e) {
            int y = 10;
            if (swtImage != null) {
                e.gc.drawImage(swtImage, 10, y);
                y += swtImage.getBounds().height + 10;
            }
            if (swtImage2 != null) {
                e.gc.drawImage(swtImage2, 10, y);
            }
        }
    });
    Frame frame = new Frame() {
        public void paint(Graphics g) {
            Insets insets = getInsets();
            if (awtImage != null) {
                g.drawImage(awtImage, 10 + insets.left, 10 + insets.top, null);
            }
        }
    };
    frame.setTitle("AWT Image");
    shell.setLocation(50, 50);
    Rectangle bounds = swtImage.getBounds();
    shell.setSize(bounds.width + 50, bounds.height * 2 + 100);
    Point size = shell.getSize();
    Point location = shell.getLocation();
    Insets insets = frame.getInsets();
    frame.setLocation(location.x + size.x + 10, location.y);
    frame.setSize(size.x - (insets.left + insets.right), size.y - (insets.top + insets.bottom));
    frame.setVisible(true);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    if (swtImage != null)
        swtImage.dispose();
    if (swtImage2 != null)
        swtImage.dispose();
    frame.dispose();
    display.dispose();
    /*
     * Note: If you are using JDK 1.3.x, you need to use System.exit(0) at the
     * end of your program to exit AWT. This is because in 1.3.x, AWT does not
     * exit when the frame is disposed, because the AWT thread is not a daemon.
     * This was fixed in JDK 1.4.x with the addition of the AWT Shutdown thread.
     */
}

From source file:org.eclipse.swt.snippets.Snippet156.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("SWT Image");
    ImageData data;//from w  w  w  . jav  a  2s.  co  m
    if (args.length > 0) {
        String fileName = args[0];
        data = new ImageData(fileName);
    } else {
        data = createSampleImage(display);
    }
    final Image swtImage = new Image(display, data);
    final BufferedImage awtImage = convertToAWT(data);
    final Image swtImage2 = new Image(display, convertToSWT(awtImage));
    shell.addListener(SWT.Paint, e -> {
        int y = 10;
        if (swtImage != null) {
            e.gc.drawImage(swtImage, 10, y);
            y += swtImage.getBounds().height + 10;
        }
        if (swtImage2 != null) {
            e.gc.drawImage(swtImage2, 10, y);
        }
    });
    Frame frame = new Frame() {
        @Override
        public void paint(Graphics g) {
            Insets insets = getInsets();
            if (awtImage != null) {
                g.drawImage(awtImage, 10 + insets.left, 10 + insets.top, null);
            }
        }
    };
    frame.setTitle("AWT Image");
    shell.setLocation(50, 50);
    Rectangle bounds = swtImage.getBounds();
    shell.setSize(bounds.width + 50, bounds.height * 2 + 100);
    Point size = shell.getSize();
    Point location = shell.getLocation();
    Insets insets = frame.getInsets();
    frame.setLocation(location.x + size.x + 10, location.y);
    frame.setSize(size.x - (insets.left + insets.right), size.y - (insets.top + insets.bottom));
    frame.setVisible(true);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    if (swtImage != null)
        swtImage.dispose();
    if (swtImage2 != null)
        swtImage.dispose();
    frame.dispose();
    display.dispose();
    /* Note: If you are using JDK 1.3.x, you need to use System.exit(0) at the end of your program to exit AWT.
     * This is because in 1.3.x, AWT does not exit when the frame is disposed, because the AWT thread is not a daemon.
     * This was fixed in JDK 1.4.x with the addition of the AWT Shutdown thread.
     */
}

From source file:Main.java

private static void doSetTitleInEDT(final Frame frame, final String title) {
    frame.setTitle(title);
}

From source file:Main.java

public static void setTitle(final Frame frame, final String title) {
    if (frame != null) {
        runInEDT(() -> frame.setTitle(title));
    }//  www. j a  va 2 s. com
}

From source file:HelloUniverse.java

public VirtualInputDevice(String[] args) {

    // default user-definable values
    printvalues = false;//  w  ww  . j a  va 2 s.  c o  m
    xscreeninitloc = 400;
    yscreeninitloc = 0;
    xscreensize = 400;
    yscreensize = 200;
    xobjinitloc = 0.0f;
    yobjinitloc = 0.0f;
    zobjinitloc = 2.2f;
    xaxisrotinit = 0.0f;
    yaxisrotinit = 0.0f;
    zaxisrotinit = 0.0f;

    for (int i = 0; i < args.length; i += 2) {
        if (args[i] == null)
            break;
        else if (args[i] == "printvalues")
            printvalues = (Boolean.valueOf(args[i + 1])).booleanValue();
        else if (args[i] == "xscreeninitloc")
            xscreeninitloc = (Integer.valueOf(args[i + 1])).intValue();
        else if (args[i] == "yscreeninitloc")
            yscreeninitloc = (Integer.valueOf(args[i + 1])).intValue();
        else if (args[i] == "xscreensize")
            xscreensize = (Integer.valueOf(args[i + 1])).intValue();
        else if (args[i] == "yscreensize")
            yscreensize = (Integer.valueOf(args[i + 1])).intValue();
        else if (args[i] == "xobjinitloc")
            xobjinitloc = (Float.valueOf(args[i + 1])).floatValue();
        else if (args[i] == "yobjinitloc")
            yobjinitloc = (Float.valueOf(args[i + 1])).floatValue();
        else if (args[i] == "zobjinitloc")
            zobjinitloc = (Integer.valueOf(args[i + 1])).floatValue();
    }

    if (printvalues == true) {
        System.out.println("Initial values for VirtualInputDevice:");
        System.out.println("xscreeninitloc = " + xscreeninitloc);
        System.out.println("yscreeninitloc = " + yscreeninitloc);
        System.out.println("xscreeninitsize = " + xscreensize);
        System.out.println("yscreeninitsize = " + yscreensize);
        System.out.println("xobjinitloc = " + xobjinitloc);
        System.out.println("yobjinitloc = " + yobjinitloc);
        System.out.println("zobjinitloc = " + zobjinitloc);
        System.out.println("xaxisrotinit = " + xaxisrotinit);
        System.out.println("yaxisrotinit = " + yaxisrotinit);
        System.out.println("zaxisrotinit = " + zaxisrotinit);
    }

    // initialize the InputDevice GUI
    Frame deviceFrame = new Frame();
    deviceFrame.setSize(xscreensize, yscreensize);
    deviceFrame.setLocation(xscreeninitloc, yscreeninitloc);
    deviceFrame.setTitle("Virtual Input Device");
    ButtonPositionControls positionControls;
    // initialize position with initial x, y, and z position
    positionControls = new ButtonPositionControls(xobjinitloc, yobjinitloc, zobjinitloc);
    WheelControls rotControls;
    // initialize rotations with initial angles in radians)
    rotControls = new WheelControls(xaxisrotinit, yaxisrotinit, zaxisrotinit);
    positionControls.setDevice(this);
    Panel devicePanel = new Panel();
    devicePanel.setLayout(new BorderLayout());
    devicePanel.add("East", positionControls);
    devicePanel.add("West", rotControls);
    deviceFrame.add(devicePanel);
    deviceFrame.pack();
    deviceFrame.setVisible(true);

    initPos.set(xobjinitloc, yobjinitloc, zobjinitloc);

    this.positionControls = positionControls;
    this.rotControls = rotControls;

    // default processing mode
    processingMode = InputDevice.DEMAND_DRIVEN;

    sensors[0] = new Sensor(this);
}

From source file:org.sleuthkit.autopsy.casemodule.Case.java

private static void doCaseChange(Case toChangeTo) {
    logger.log(Level.INFO, "Changing Case to: {0}", toChangeTo); //NON-NLS
    if (toChangeTo != null) { // new case is open

        // clear the temp folder when the case is created / opened
        Case.clearTempFolder();/*from  w  ww .ja v  a2s .  c om*/
        checkSubFolders(toChangeTo);

        if (RuntimeProperties.coreComponentsAreActive()) {
            // enable these menus
            SwingUtilities.invokeLater(() -> {
                CallableSystemAction.get(AddImageAction.class).setEnabled(true);
                CallableSystemAction.get(CaseCloseAction.class).setEnabled(true);
                CallableSystemAction.get(CasePropertiesAction.class).setEnabled(true);
                CallableSystemAction.get(CaseDeleteAction.class).setEnabled(true); // Delete Case menu
            });

            if (toChangeTo.hasData()) {
                // open all top components
                SwingUtilities.invokeLater(() -> {
                    CoreComponentControl.openCoreWindows();
                });
            } else {
                // close all top components
                SwingUtilities.invokeLater(() -> {
                    CoreComponentControl.closeCoreWindows();
                });
            }
        }

        if (RuntimeProperties.coreComponentsAreActive()) {
            SwingUtilities.invokeLater(() -> {
                updateMainWindowTitle(currentCase.name);
            });
        } else {
            SwingUtilities.invokeLater(() -> {
                Frame f = WindowManager.getDefault().getMainWindow();
                f.setTitle(Case.getAppName()); // set the window name to just application name           
            });
        }

    } else { // case is closed
        if (RuntimeProperties.coreComponentsAreActive()) {

            SwingUtilities.invokeLater(() -> {
                // close all top components first
                CoreComponentControl.closeCoreWindows();

                // disable these menus
                CallableSystemAction.get(AddImageAction.class).setEnabled(false); // Add Image menu
                CallableSystemAction.get(CaseCloseAction.class).setEnabled(false); // Case Close menu
                CallableSystemAction.get(CasePropertiesAction.class).setEnabled(false); // Case Properties menu
                CallableSystemAction.get(CaseDeleteAction.class).setEnabled(false); // Delete Case menu
            });
        }

        //clear pending notifications
        SwingUtilities.invokeLater(() -> {
            MessageNotifyUtil.Notify.clear();
        });

        SwingUtilities.invokeLater(() -> {
            Frame f = WindowManager.getDefault().getMainWindow();
            f.setTitle(Case.getAppName()); // set the window name to just application name
        });

        //try to force gc to happen
        System.gc();
        System.gc();
    }

    //log memory usage after case changed
    logger.log(Level.INFO, PlatformUtil.getAllMemUsageInfo());

}