Example usage for java.awt Toolkit getDefaultToolkit

List of usage examples for java.awt Toolkit getDefaultToolkit

Introduction

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

Prototype

public static synchronized Toolkit getDefaultToolkit() 

Source Link

Document

Gets the default toolkit.

Usage

From source file:Main.StaticTools.java

/** Generates a windows beep */
public static void beep() {
    final Runnable runnable = (Runnable) Toolkit.getDefaultToolkit()
            .getDesktopProperty("win.sound.exclamation");
    if (runnable != null)
        runnable.run();//w ww  . ja  v  a2s.  co  m
}

From source file:DataBufferGrabber.java

/**
 * Perform and time several drawImage() calls with the given parameters
 * and return the number of milliseconds that the operation took.
 *//*from w  ww  .  ja  v a  2  s  .  c  o m*/
private long copyImage(Graphics g, BufferedImage image, int x, int y) {
    long startTime = System.nanoTime();
    // Do the operation several times to make the timings more significant
    for (int i = 0; i < 100; ++i) {
        g.drawImage(image, x, y, null);
    }
    // Make sure any graphics commands in hardware get flushed before
    // stopping the clock
    Toolkit.getDefaultToolkit().sync();
    long endTime = System.nanoTime();
    return (endTime - startTime) / 1000000;
}

From source file:mytrack.SimpleModelView.java

/**
 * Defines basic properties of this window.
 *//*from  www . ja  v  a  2s .c o  m*/
private void configureWindow() {
    setTitle("Basic Java3D Program");
    setSize(640, 480);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int locationX = (screenSize.width - getWidth()) / 2;
    int locationY = (screenSize.height - getHeight()) / 2;
    setLocation(locationX, locationY);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:de.tor.tribes.util.GlobalDefaults.java

/**
 * Add a property/*from w ww .j a  va2 s  .c  o  m*/
 */

public static void loadDefaults() {
    GLOBAL_DEFAULTS = new PropertiesConfiguration();
    GLOBAL_DEFAULTS.addProperty("attack.movement", false);
    GLOBAL_DEFAULTS.addProperty("attack.planer.check.amount", 20000);
    GLOBAL_DEFAULTS.addProperty("attack.planer.enable.check", true);
    GLOBAL_DEFAULTS.addProperty("attack.script.attacks.in.overview", true);
    GLOBAL_DEFAULTS.addProperty("attack.script.attacks.in.place", true);
    GLOBAL_DEFAULTS.addProperty("attack.script.attacks.in.village.info", true);
    GLOBAL_DEFAULTS.addProperty("attack.script.attacks.on.confirm.page", true);
    GLOBAL_DEFAULTS.addProperty("check.updates.on.startup", true);
    GLOBAL_DEFAULTS.addProperty("church.frame.alwaysOnTop", false);
    GLOBAL_DEFAULTS.addProperty("clipboard.notification", true);
    GLOBAL_DEFAULTS.addProperty("clock.alwaysOnTop", false);
    GLOBAL_DEFAULTS.addProperty("command.sleep.time", 150);
    GLOBAL_DEFAULTS.addProperty("conquers.frame.alwaysOnTop", false);
    GLOBAL_DEFAULTS.addProperty("default.browser", "");
    GLOBAL_DEFAULTS.addProperty("default.mark", 0);
    GLOBAL_DEFAULTS.addProperty("default.skin", "default");
    GLOBAL_DEFAULTS.addProperty("delete.farm.reports.on.exit", true);
    GLOBAL_DEFAULTS.addProperty("draw.attacks.by.default", false);
    GLOBAL_DEFAULTS.addProperty("extended.attack.vectors", false);
    GLOBAL_DEFAULTS.addProperty("extended.text.attacks", false);
    GLOBAL_DEFAULTS.addProperty("form.config.frame.alwaysOnTop", false);
    GLOBAL_DEFAULTS.addProperty("half.ribbon.size", false);
    GLOBAL_DEFAULTS.addProperty("highlight.tribes.villages", false);
    GLOBAL_DEFAULTS.addProperty("include.support", true);
    GLOBAL_DEFAULTS.addProperty("inform.on.updates", true);
    GLOBAL_DEFAULTS.addProperty("main.size.height",
            (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() - 50);
    GLOBAL_DEFAULTS.addProperty("main.size.width",
            (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight() - 50);
    GLOBAL_DEFAULTS.addProperty("map.marker.transparency", 80);
    GLOBAL_DEFAULTS.addProperty("map.showcontinents", true);
    GLOBAL_DEFAULTS.addProperty("map.zoom.max", 3.0);
    GLOBAL_DEFAULTS.addProperty("map.zoom.min", 0.4);
    GLOBAL_DEFAULTS.addProperty("map.zoom.in.out.factor", 1.06);
    GLOBAL_DEFAULTS.addProperty("mark.villages.on.minimap", true);
    GLOBAL_DEFAULTS.addProperty("max.density.troops", 65000);
    GLOBAL_DEFAULTS.addProperty("max.farm.space", 20000);
    GLOBAL_DEFAULTS.addProperty("farm.popup.use.real", false);
    GLOBAL_DEFAULTS.addProperty("max.loss.ratio", 50);
    GLOBAL_DEFAULTS.addProperty("max.sim.rounds", 500);
    GLOBAL_DEFAULTS.addProperty("no.welcome", false);
    GLOBAL_DEFAULTS.addProperty("notify.duration", 1);
    GLOBAL_DEFAULTS.addProperty("obst.server", "");
    GLOBAL_DEFAULTS.addProperty("parser.movement.plan", "imported");
    GLOBAL_DEFAULTS.addProperty("parser.movement.delete.all.on.import", "false");
    GLOBAL_DEFAULTS.addProperty("proxySet", false);
    GLOBAL_DEFAULTS.addProperty("proxyHost", "");
    GLOBAL_DEFAULTS.addProperty("proxyPort", 8080);
    GLOBAL_DEFAULTS.addProperty("proxyType", 0);
    GLOBAL_DEFAULTS.addProperty("proxyUser", "");
    GLOBAL_DEFAULTS.addProperty("proxyPassword", "");
    GLOBAL_DEFAULTS.addProperty("radar.size", 60); //in minutes
    GLOBAL_DEFAULTS.addProperty("red.width", 0);
    GLOBAL_DEFAULTS.addProperty("red.height", 0);
    GLOBAL_DEFAULTS.addProperty("report.server.port", 8080);
    GLOBAL_DEFAULTS.addProperty("ribbon.minimized", false);
    GLOBAL_DEFAULTS.addProperty("screen.dir", ".");
    GLOBAL_DEFAULTS.addProperty("search.frame.alwaysOnTop", false);
    GLOBAL_DEFAULTS.addProperty("show.barbarian", true);
    GLOBAL_DEFAULTS.addProperty("show.live.countdown", true);
    GLOBAL_DEFAULTS.addProperty("show.map.popup", true);
    GLOBAL_DEFAULTS.addProperty("show.mouseover.info", false);
    GLOBAL_DEFAULTS.addProperty("show.popup.conquers", true);
    GLOBAL_DEFAULTS.addProperty("show.popup.farm.space", true);
    GLOBAL_DEFAULTS.addProperty("show.popup.ranks", true);
    GLOBAL_DEFAULTS.addProperty("show.sectors", true);
    GLOBAL_DEFAULTS.addProperty("show.ruler", true);
    GLOBAL_DEFAULTS.addProperty("show.church", true);
    GLOBAL_DEFAULTS.addProperty("show.watchtower", true);
    GLOBAL_DEFAULTS.addProperty("show.ruler", true);
    GLOBAL_DEFAULTS.addProperty("sos.mark.all.duplicates.as.fake", "true");
    GLOBAL_DEFAULTS.addProperty("standard.defense.split", "heavy=0/spy=50/sword=500/archer=500/spear=500");
    GLOBAL_DEFAULTS.addProperty("standard.off", "catapult=50/light=3000/ram=300/axe=7000/marcher=500");
    GLOBAL_DEFAULTS.addProperty("stats.frame.alwaysOnTop", false);
    GLOBAL_DEFAULTS.addProperty("support.tolerance", 0);
    GLOBAL_DEFAULTS.addProperty("systray.enabled", SystrayHelper.isSystraySupported());
    GLOBAL_DEFAULTS.addProperty("tag.frame.menu.visible", true);
    GLOBAL_DEFAULTS.addProperty("tag.frame.table.visibility", "true;true;true;false");
    GLOBAL_DEFAULTS.addProperty("tap.height", 0);
    GLOBAL_DEFAULTS.addProperty("tap.width", 0);
    GLOBAL_DEFAULTS.addProperty("text.attacks.per.file", "10");
    GLOBAL_DEFAULTS.addProperty("village.order", 0);
    GLOBAL_DEFAULTS.addProperty("watchtower.frame.alwaysOnTop", false);
    GLOBAL_DEFAULTS.addProperty("zip.text.attacks", false);

    for (UnitHolder unit : DataHolder.getSingleton().getUnits()) {
        GLOBAL_DEFAULTS.addProperty(unit.getName() + ".color", "#ff0000");
    }

    GLOBAL_DEFAULTS.addProperty("layer.order",
            "Markierungen;" + "Drfer;" + "Dorfsymbole;" + "Truppendichte;" + "Notizmarkierungen;"
                    + "Angriffe;" + "Untersttzungen;" + "Zeichnungen;" + "Kirchenradien;" + "Wachturmradien");

    //Default templates
    GLOBAL_DEFAULTS.addProperty("attack.template.header", "<Standard>");
    GLOBAL_DEFAULTS.addProperty("attack.template.header.internal", "templates/attack_header.tmpl");
    GLOBAL_DEFAULTS.addProperty("attack.template.block", "<Standard>");
    GLOBAL_DEFAULTS.addProperty("attack.template.block.internal", "templates/attack_block.tmpl");
    GLOBAL_DEFAULTS.addProperty("attack.template.footer", "<Standard>");
    GLOBAL_DEFAULTS.addProperty("attack.template.footer.internal", "templates/attack_footer.tmpl");
    GLOBAL_DEFAULTS.addProperty("report.list.bbexport.template",
            de.tor.tribes.util.bb.ReportListFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("attack.bbexport.template",
            de.tor.tribes.util.AttackToBBCodeFormater.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("ally.report.stats.bbexport.template",
            de.tor.tribes.util.bb.AllyReportStatsFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("attack.list.bbexport.template",
            de.tor.tribes.util.bb.AttackListFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("def.stats.bbexport.template",
            de.tor.tribes.util.bb.DefStatsFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("form.list.bbexport.template",
            de.tor.tribes.util.bb.FormListFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("kills.stats.bbexport.template",
            de.tor.tribes.util.bb.KillStatsFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("marker.list.bbexport.template",
            de.tor.tribes.util.bb.MarkerListFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("note.list.bbexport.template",
            de.tor.tribes.util.bb.NoteListFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("overall.report.stats.bbexport.template",
            de.tor.tribes.util.bb.OverallReportStatsFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("point.stats.bbexport.template",
            de.tor.tribes.util.bb.PointStatsFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("report.list.bbexport.template",
            de.tor.tribes.util.bb.ReportListFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("sos.list.bbexport.template",
            de.tor.tribes.util.bb.SosListFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("tag.list.bbexport.template",
            de.tor.tribes.util.bb.TagListFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("tribe.report.stats.bbexport.template",
            de.tor.tribes.util.bb.TribeReportStatsFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("troops.list.bbexport.template",
            de.tor.tribes.util.bb.TroopListFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("village.list.bbexport.template",
            de.tor.tribes.util.bb.VillageListFormatter.STANDARD_TEMPLATE);

    GLOBAL_DEFAULTS.addProperty("winner.loser.stats.bbexport.template",
            de.tor.tribes.util.bb.WinnerLoserStatsFormatter.STANDARD_TEMPLATE);

    //TODO set to true after Moral is working
    GLOBAL_DEFAULTS.addProperty("show.popup.moral",
            ServerSettings.getSingleton().getMoralType() == ServerSettings.POINTBASED_MORAL);
}

From source file:TextTransferTest.java

/**
 * Copies the selected text to the system clipboard.
 *///w  ww .j  av  a 2  s  .co m
private void copy() {
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    String text = textArea.getSelectedText();
    if (text == null)
        text = textArea.getText();
    StringSelection selection = new StringSelection(text);
    clipboard.setContents(selection, null);
}

From source file:com.limegroup.gnutella.gui.tables.ActionIconAndNameEditor.java

public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, int row,
        int column) {
    ActionIconAndNameHolder in = (ActionIconAndNameHolder) value;
    action = in.getAction();//from w  ww. j a v  a  2 s.  c o m

    final Component component = new ActionIconAndNameRenderer().getTableCellRendererComponent(table, value,
            isSelected, true, row, column);
    component.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                if (actionRegion == null) {
                    component_mousePressed(e);
                } else {
                    if (actionRegion.contains(e.getPoint())) {
                        component_mousePressed(e);
                    } else {
                        if (e.getClickCount() >= 2) {
                            Toolkit.getDefaultToolkit().getSystemEventQueue()
                                    .postEvent(new MouseEvent(table, MouseEvent.MOUSE_CLICKED, e.getWhen(),
                                            e.getModifiers(), component.getX() + e.getX(),
                                            component.getY() + e.getY(), e.getClickCount(), false));
                        }
                    }
                }
            } else if (e.getButton() == MouseEvent.BUTTON3) {
                Toolkit.getDefaultToolkit().getSystemEventQueue()
                        .postEvent(new MouseEvent(table, e.getID(), e.getWhen(), e.getModifiers(),
                                component.getX() + e.getX(), component.getY() + e.getY(), e.getClickCount(),
                                true));
            }
        }
    });

    return component;
}

From source file:SerialTransferTest.java

/**
 * Copies the chooser's color into the system clipboard.
 *//*from   www.java 2  s.  c o  m*/
private void copy() {
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    Color color = chooser.getColor();
    SerialTransferable selection = new SerialTransferable(color);
    clipboard.setContents(selection, null);
}

From source file:net.sf.keystore_explorer.gui.actions.GenerateCsrAction.java

/**
 * Construct action./*from   w  ww.ja  v  a2 s .  c  o  m*/
 *
 * @param kseFrame
 *            KeyStore Explorer frame
 */
public GenerateCsrAction(KseFrame kseFrame) {
    super(kseFrame);

    putValue(LONG_DESCRIPTION, res.getString("GenerateCsrAction.statusbar"));
    putValue(NAME, res.getString("GenerateCsrAction.text"));
    putValue(SHORT_DESCRIPTION, res.getString("GenerateCsrAction.tooltip"));
    putValue(SMALL_ICON, new ImageIcon(Toolkit.getDefaultToolkit()
            .createImage(getClass().getResource(res.getString("GenerateCsrAction.image")))));
}

From source file:com.artistech.tuio.mouse.MouseDriver.java

/**
 * Add Cursor Event.//from www .  j a  v  a 2s.  c om
 *
 * @param tcur
 */
@Override
public void addTuioCursor(TuioCursor tcur) {
    logger.trace(MessageFormat.format("add tuio cursor id: {0}", tcur.getCursorID()));

    int width = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
    int height = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();

    boolean found = false;
    for (MutableTriple<Long, Integer, Integer> trip : curs) {
        if (trip.getLeft() == tcur.getSessionID()) {
            found = true;
            break;
        }
    }
    if (!found) {
        curs.add(new MutableTriple<>(tcur.getSessionID(), tcur.getScreenX(width), tcur.getScreenY(height)));
    }

    if (curs.size() == 1) {
        logger.debug(MessageFormat.format("add mouse move: ({0}, {1})",
                new Object[] { tcur.getScreenX(width), tcur.getScreenY(height) }));
        robot.mouseMove(tcur.getScreenX(width), tcur.getScreenY(height));
    } else {
        logger.debug(MessageFormat.format("add mouse press: {0}", tcur.getCursorID()));
        if (curs.size() == 2) {
            robot.mousePress(InputEvent.BUTTON1_MASK);
        } else {
            robot.mousePress(InputEvent.BUTTON3_MASK);
            robot.mouseRelease(InputEvent.BUTTON3_MASK);
        }
    }
}

From source file:GUIUtils.java

/**
 * Centers <CODE>wind</CODE> within the screen. If centering would cause the
 * title bar to go off the top of the screen then move the window down.
 * //from ww  w  .j  a  v  a  2s.c  o  m
 * @param wind
 *          The Window to be centered.
 * 
 * @throws IllegalArgumentException
 *           If <TT>wind</TT> is <TT>null</TT>.
 */
public static void centerWithinScreen(Window wind) {
    if (wind == null) {
        throw new IllegalArgumentException("null Window passed");
    }
    final Toolkit toolKit = Toolkit.getDefaultToolkit();
    final Rectangle rcScreen = new Rectangle(toolKit.getScreenSize());
    final Dimension windSize = wind.getSize();
    final Dimension parentSize = new Dimension(rcScreen.width, rcScreen.height);
    if (windSize.height > parentSize.height) {
        windSize.height = parentSize.height;
    }
    if (windSize.width > parentSize.width) {
        windSize.width = parentSize.width;
    }
    center(wind, rcScreen);
}