Example usage for java.awt Toolkit getScreenSize

List of usage examples for java.awt Toolkit getScreenSize

Introduction

In this page you can find the example usage for java.awt Toolkit getScreenSize.

Prototype

public abstract Dimension getScreenSize() throws HeadlessException;

Source Link

Document

Gets the size of the screen.

Usage

From source file:de.tud.kom.p2psim.impl.skynet.visualization.SkyNetVisualization.java

private SkyNetVisualization() {
    super("Metric-Visualization");
    createLookAndFeel();//from   w w w .  ja va 2 s .co m
    displayedMetrics = new HashMap<String, MetricsPlot>();
    setLayout(new GridLayout(1, 1));
    addWindowListener(this);
    graphix = new JPanel(new GridBagLayout());
    graphix.setLayout(new BoxLayout(graphix, BoxLayout.PAGE_AXIS));
    mb = new JMenuBar();
    JScrollPane scroller = new JScrollPane(graphix, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    // calculating the size of the application-window as well as of all
    // components, that depend on the size of the window
    Toolkit kit = Toolkit.getDefaultToolkit();
    int appWidth = kit.getScreenSize().width * 3 / 4;
    int appHeight = kit.getScreenSize().height * 3 / 4;
    scroller.setPreferredSize(new Dimension(appWidth, appHeight));
    getContentPane().add(scroller);
    maxPlotsPerRow = 1;
    while ((maxPlotsPerRow + 1) * PLOT_WIDTH < appWidth) {
        maxPlotsPerRow++;
    }
    log.warn("Creating the visualization...");
    mb.add(new JMenu("File"));
    JMenu met = new JMenu("Available Metrics");
    met.setEnabled(false);
    mb.add(met);
    setJMenuBar(mb);
}

From source file:org.peerfact.impl.service.aggregation.skyeye.visualization.SkyNetVisualization.java

private SkyNetVisualization() {
    super("Metric-Visualization");
    createLookAndFeel();/*from   w w  w.j  a va 2s  . c  om*/
    displayedMetrics = new LinkedHashMap<String, MetricsPlot>();
    setLayout(new GridLayout(1, 1));
    addWindowListener(this);
    graphix = new JPanel(new GridBagLayout());
    graphix.setLayout(new BoxLayout(graphix, BoxLayout.PAGE_AXIS));
    mb = new JMenuBar();
    JScrollPane scroller = new JScrollPane(graphix, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    // calculating the size of the application-window as well as of all
    // components, that depend on the size of the window
    Toolkit kit = Toolkit.getDefaultToolkit();
    int appWidth = kit.getScreenSize().width * 3 / 4;
    int appHeight = kit.getScreenSize().height * 3 / 4;
    scroller.setPreferredSize(new Dimension(appWidth, appHeight));
    getContentPane().add(scroller);
    maxPlotsPerRow = 1;
    while ((maxPlotsPerRow + 1) * PLOT_WIDTH < appWidth) {
        maxPlotsPerRow++;
    }
    log.warn("Creating the visualization...");
    mb.add(new JMenu("File"));
    JMenu met = new JMenu("Available Metrics");
    met.setEnabled(false);
    mb.add(met);
    setJMenuBar(mb);
}

From source file:com.jwmsolutions.timeCheck.gui.TodoForm.java

private void myInitComponents() {
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();
    int screenHeight = screenSize.height;
    int screenWidth = screenSize.width;
    setLocation(screenWidth - getSize().width - 20, screenHeight - getSize().height - 60);
}

From source file:com.qumasoft.guitools.compare.CompareFrame.java

void fitToScreen() {
    if (parentFrame == null) {
        Toolkit screenToolkit = java.awt.Toolkit.getDefaultToolkit();
        Dimension screenSize = screenToolkit.getScreenSize();
        // <editor-fold>
        setLocation(0, 20);/*w w  w  . j  a  v  a2s . co m*/
        screenSize.setSize((screenSize.width * 90) / 100, (screenSize.height * 90) / 100);
        // </editor-fold>
        setSize(screenSize);
    } else {
        setLocation(parentFrame.getLocation());
        setSize(parentFrame.getSize());
    }
}

From source file:org.genedb.jogra.plugins.TermRationaliser.java

private Box createRationaliserPanel(final String name, final RationaliserJList rjlist) {

    int preferredHeight = 500; //change accordingly
    int preferredWidth = 500;

    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension size = tk.getScreenSize();
    int textboxHeight = 10; //change accordingly
    int textboxWidth = size.width;

    Box box = Box.createVerticalBox();
    box.add(new JLabel(name));

    JTextField searchField = new JTextField(20); //Search field on top
    /* We don't want this textfield's height to expand when
     * the Rationaliser is dragged to exapnd. So we set it's
     * height to what we want and the width to the width of
     * the screen  /*  www .  j  av a 2 s .co m*/
     */
    searchField.setMaximumSize(new Dimension(textboxWidth, textboxHeight));
    rjlist.installJTextField(searchField);
    box.add(searchField);

    JScrollPane scrollPane = new JScrollPane(); //scroll pane
    scrollPane.setViewportView(rjlist);
    scrollPane.setPreferredSize(new Dimension(preferredWidth, preferredHeight));
    box.add(scrollPane);

    TitledBorder sysidBorder = BorderFactory.createTitledBorder("Systematic IDs"); //systematic ID box
    sysidBorder.setTitleColor(Color.DARK_GRAY);

    final JTextArea idField = new JTextArea(1, 1);
    idField.setMaximumSize(new Dimension(textboxWidth, textboxHeight));
    idField.setEditable(false);
    idField.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    idField.setForeground(Color.DARK_GRAY);
    JScrollPane scroll = new JScrollPane(idField);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    Box sysidBox = Box.createVerticalBox();
    sysidBox.add(scroll /*idField*/);
    sysidBox.setBorder(sysidBorder);
    box.add(sysidBox);

    rjlist.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            Term highlightedTerm = (Term) rjlist.getSelectedValue();
            if (highlightedTerm != null) {
                /* For each list, call the relevant methods
                 * to get the systematic IDs. Then for the
                 * right list, add the term name in the
                 * text box below
                 */
                if (name.equals(FROM_LIST_NAME)) {
                    idField.setText(StringUtils.collectionToCommaDelimitedString(
                            termService.getSystematicIDs(highlightedTerm, selectedTaxons)));
                } else if (name.equals(TO_LIST_NAME)) {
                    idField.setText(StringUtils.collectionToCommaDelimitedString(
                            termService.getSystematicIDs(highlightedTerm, null)));
                    /* We allow the user to edit the term name */
                    textField.setText(highlightedTerm.getName());
                }

            }
        }
    });

    return box;

}

From source file:org.gcaldaemon.core.notifier.GmailNotifierWindow.java

GmailNotifierWindow(String style, String sound) throws Exception {
    super(new Frame());

    // Load background
    int w = 300;/*from  w  ww. j a  va  2s  .  com*/
    int h = 110;
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    InputStream in;
    try {
        if (style.indexOf('.') == -1) {
            in = GmailNotifierWindow.class.getResourceAsStream(style + ".gif");
        } else {
            in = new FileInputStream(style);
        }
    } catch (Exception loadError) {
        log.error(loadError.getMessage(), loadError);
        in = GmailNotifierWindow.class.getResourceAsStream("default.gif");
    }
    ImageIO.setUseCache(false);
    background = ImageIO.read(in);
    in.close();
    Dimension size = toolkit.getScreenSize();
    setBounds((size.width - w) / 2, (size.height - h) / 2, w, h);
    metrics = getFontMetrics(PLAIN);

    // Set colors
    for (;;) {
        if (style.equals("metal")) {
            fromColor = Color.WHITE;
            break;
        }
        if (style.equals("green")) {
            titleColor = Color.GREEN;
            dateColor = new Color(0, 145, 0);
            break;
        }
        if (style.equals("blue")) {
            fromColor = Color.WHITE;
            titleColor = new Color(212, 235, 255);
            dateColor = titleColor;
            break;
        }
        if (style.equals("mail")) {
            titleColor = new Color(139, 128, 118);
            dateColor = titleColor;
            break;
        }
        break;
    }

    // Create offscreen buffer
    buffer = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    offscreen = buffer.getGraphics();

    // Set notification sound
    if (sound == null || sound.equals("beep")) {
        clip = null;
    } else {
        try {
            URL url;
            if (sound.indexOf('.') == -1) {
                url = GmailNotifierWindow.class.getResource(sound + ".wav");
            } else {
                sound = sound.replace(File.separatorChar, '/');
                url = new URL("file", "", sound);
            }
            clip = Applet.newAudioClip(url);
        } catch (Exception soundError) {
            log.warn("Unable to load sound: " + sound, soundError);
            clip = null;
        }
    }

    // Init window
    setAlwaysOnTop(true);
    addMouseListener(this);
    addMouseMotionListener(this);
    validate();
}

From source file:kr.ac.kaist.swrc.jhannanum.demo.GUIDemo.java

/**
 * Sets the GUI up and launch the demo.//from www.ja v  a  2  s. co  m
 */
public void run() {
    ///////////////////////////////////////////////////////////////////
    // Basic setting for the mainFrame                                    
    ///////////////////////////////////////////////////////////////////
    mainFrame = new JFrame();

    Toolkit kit = mainFrame.getToolkit();
    Dimension windowSize = kit.getScreenSize();

    mainFrame.setBounds(windowSize.width / 20, windowSize.height / 20, windowSize.width * 18 / 20,
            windowSize.height * 18 / 20);
    mainFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    mainFrame.setTitle("HanNanum Korean Morphological Analyzer - A Plug-in Component based System (GUI Demo)");

    Font font = new Font("MonoSpaced", Font.PLAIN, 12);
    UIManager.put("TextArea.font", font);

    ///////////////////////////////////////////////////////////////////
    // Layout setting for the mainFrame                  
    ///////////////////////////////////////////////////////////////////
    mainFrame.setLayout(new BorderLayout());
    mainFrame.getContentPane().add(createPaneCenter(), BorderLayout.CENTER);
    mainFrame.getContentPane().add(createPaneNorth(), BorderLayout.NORTH);

    ///////////////////////////////////////////////////////////////////
    // Menu Setting                                 
    ///////////////////////////////////////////////////////////////////      
    menuBar = new JMenuBar();
    menuFile = new JMenu("File");
    menuItemFileOpen = new JMenuItem("Open", KeyEvent.VK_O);
    menuHelp = new JMenu("Help");
    menuItemHelp = new JMenuItem("Help", KeyEvent.VK_H);

    menuItemFileOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.ALT_MASK));
    menuItemHelp.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK));

    menuBar.add(menuFile);
    menuBar.add(menuHelp);
    menuFile.add(menuItemFileOpen);
    menuHelp.add(menuItemHelp);
    mainFrame.setJMenuBar(menuBar);

    ///////////////////////////////////////////////////////////////////
    // Event Handler Setting                                 
    ///////////////////////////////////////////////////////////////////
    menuItemFileOpen.addActionListener(new SharedActionHandler());
    menuItemHelp.addActionListener(new SharedActionHandler());
    buttonActivate.addActionListener(new SharedActionHandler());
    buttonAnalysis.addActionListener(new SharedActionHandler());
    buttonReset.addActionListener(new SharedActionHandler());
    radioMultiThread.addActionListener(new SharedActionHandler());
    radioSingleThread.addActionListener(new SharedActionHandler());

    listPluginMajor2.addMouseListener(new PluginListMouseListener(listPluginMajor2, listModelMajor2));
    listPluginMajor3.addMouseListener(new PluginListMouseListener(listPluginMajor3, listModelMajor3));
    listPluginSupplement1
            .addMouseListener(new PluginListMouseListener(listPluginSupplement1, listModelSupplement1));
    listPluginSupplement2
            .addMouseListener(new PluginListMouseListener(listPluginSupplement2, listModelSupplement2));
    listPluginSupplement3
            .addMouseListener(new PluginListMouseListener(listPluginSupplement3, listModelSupplement3));

    listPluginMajor2.setTransferHandler(new PluginTransferHandler(PluginInfo.PHASE2, PluginInfo.MAJOR));
    listPluginMajor3.setTransferHandler(new PluginTransferHandler(PluginInfo.PHASE3, PluginInfo.MAJOR));
    listPluginSupplement1
            .setTransferHandler(new PluginTransferHandler(PluginInfo.PHASE1, PluginInfo.SUPPLEMENT));
    listPluginSupplement2
            .setTransferHandler(new PluginTransferHandler(PluginInfo.PHASE2, PluginInfo.SUPPLEMENT));
    listPluginSupplement3
            .setTransferHandler(new PluginTransferHandler(PluginInfo.PHASE3, PluginInfo.SUPPLEMENT));

    listPluginSupplement1.setDropMode(DropMode.ON_OR_INSERT);
    listPluginSupplement2.setDropMode(DropMode.ON_OR_INSERT);
    listPluginSupplement3.setDropMode(DropMode.ON_OR_INSERT);
    listPluginMajor2.setDropMode(DropMode.ON_OR_INSERT);
    listPluginMajor3.setDropMode(DropMode.ON_OR_INSERT);

    listPluginMajor2.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listPluginMajor3.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listPluginSupplement1.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listPluginSupplement2.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listPluginSupplement3.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    listPluginMajor2.setDragEnabled(true);
    listPluginMajor3.setDragEnabled(true);
    listPluginSupplement1.setDragEnabled(true);
    listPluginSupplement2.setDragEnabled(true);
    listPluginSupplement3.setDragEnabled(true);

    tree.setDragEnabled(true);
    tempPlugin = new PluginInfo("", 0, 0);

    workflow = new Workflow();

    // Show the main frame on the screen
    mainFrame.setVisible(true);

    for (int i = 0; i < tree.getRowCount(); i++) {
        tree.expandRow(i);
    }

    splitPaneTop.setDividerLocation(0.3);
    splitPaneBottom.setDividerLocation(0.5);
}

From source file:UI.SecurityDashboard.java

/**
 * Creates new form Main/*from   w ww  . jav a2 s.  c  o m*/
 */
public SecurityDashboard() {
    //this.setUndecorated(true);
    //this.setAlwaysOnTop(true);

    this.setVisible(true);
    initComponents();
    MainViewPanel mvp = new MainViewPanel();
    performMetric1(mvp);
    performMetric2(mvp);
    performMetric3(mvp);
    performMetric4(mvp);
    performMetric5(mvp);
    performMetric6(mvp);
    performMetric7(mvp);
    performMetric8(mvp);
    performMetric9();

    //        Metric6Panel.setVisible(false);
    //        Metric7Panel.setVisible(false);
    //        Metric8Panel.setVisible(false);
    //        Metric9Panel.setVisible(false);

    Toolkit tk;
    tk = Toolkit.getDefaultToolkit();
    this.setSize((int) tk.getScreenSize().getWidth(), (int) tk.getScreenSize().getHeight());
    this.setTitle("Security Dashboard");
    sourceFolder.setBorder(new LineBorder(Color.BLACK));
    sourceFolder.setBorderPainted(true);

}

From source file:gui.EspecificacionesAnimal.java

private void cargarComponentes() {

    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension pantallaTamano = tk.getScreenSize();
    //        setSize(pantallaTamano); /*Dar tamao mximo a la pantalla*/
    fondo1.cargar(pantallaTamano);//from w ww .j  av  a 2s.  com
    //        jPanel1.setLocation((pantallaTamano.width / 2) - (jPanel1.getWidth() / 2), (pantallaTamano.height / 2) - (jPanel1.getHeight() / 2));
    //        setExtendedState(JFrame.MAXIMIZED_BOTH);
    setResizable(false); /*Boton de minimizar*/

}

From source file:com.virtusa.isq.rft.runtime.RFTCommandBase.java

/**
 * Support method for mouseMoveAndClick <br>
 * Resize the screen./*w w w . j  a va2s  .  c  om*/
 * 
 * @return the dimension
 */
private static Dimension resizeScreen() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    return toolkit.getScreenSize();
}