List of usage examples for java.awt Toolkit getDefaultToolkit
public static synchronized Toolkit getDefaultToolkit()
From source file:ImageTransferTest.java
/** * Pastes the image from the system clipboard into the image label. *///from www .j a v a2s. c o m private void paste() { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); DataFlavor flavor = DataFlavor.imageFlavor; if (clipboard.isDataFlavorAvailable(flavor)) { try { image = (Image) clipboard.getData(flavor); label.setIcon(new ImageIcon(image)); } catch (UnsupportedFlavorException exception) { JOptionPane.showMessageDialog(this, exception); } catch (IOException exception) { JOptionPane.showMessageDialog(this, exception); } } }
From source file:Java2DExample.java
public ImagePanel(URL imageURL) { image = Toolkit.getDefaultToolkit().createImage(imageURL); MediaTracker mediaTracker = new MediaTracker(this); mediaTracker.addImage(image, 0);/* w w w . j a va 2 s.co m*/ try { mediaTracker.waitForAll(); } catch (InterruptedException e) { e.printStackTrace(); } originalImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB); displayImage = originalImage; Graphics2D graphics = displayImage.createGraphics(); graphics.drawImage(image, null, null); }
From source file:at.gv.egiz.bku.local.stal.LocalGetCertificateSTALFactory.java
@Override public STAL createSTAL() { final LocalBKUWorker stal; //http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html // use undecorated JFrame instead of JWindow, // which creates an invisible owning frame and therefore cannot getFocusInWindow() JFrame dialog = new JFrame("Brgerkarte"); log.debug("AlwaysOnTop supported: {}.", dialog.isAlwaysOnTopSupported()); // [#439] make mocca dialog alwaysOnTop dialog.setAlwaysOnTop(true);/*w w w. j a v a 2s. co m*/ dialog.setIconImages(BKUIcons.icons); // dialog.setUndecorated(true); // dialog.getRootPane().setWindowDecorationStyle(JRootPane.NONE); if (locale != null) { dialog.setLocale(locale); } LocalHelpListener helpListener = null; if (helpURL != null) { helpListener = new LocalHelpListener(helpURL, locale); } else { log.warn("No HELP URL configured, help system disabled."); } GetCertificateGUIFacade gui = new GetCertificateGUI(dialog.getContentPane(), dialog.getLocale(), null, new ResourceFontLoader(), helpListener); BKUGUIFacade proxy = (BKUGUIFacade) GUIProxy.newInstance(gui, dialog, new Class[] { GetCertificateGUIFacade.class, }); stal = new LocalBKUWorker(proxy, dialog); dialog.setPreferredSize(PREFERRED_SIZE); dialog.pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = dialog.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } dialog.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); return stal; }
From source file:at.gv.egiz.bku.local.stal.LocalGetHardwareInfoSTALFactory.java
@Override public STAL createSTAL() { final LocalBKUWorker stal; //http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html // use undecorated JFrame instead of JWindow, // which creates an invisible owning frame and therefore cannot getFocusInWindow() JFrame dialog = new JFrame("Brgerkarte"); log.debug("AlwaysOnTop supported: {}.", dialog.isAlwaysOnTopSupported()); // [#439] make mocca dialog alwaysOnTop dialog.setAlwaysOnTop(true);/* ww w . j a v a2s . c om*/ dialog.setIconImages(BKUIcons.icons); // dialog.setUndecorated(true); // dialog.getRootPane().setWindowDecorationStyle(JRootPane.NONE); if (locale != null) { dialog.setLocale(locale); } LocalHelpListener helpListener = null; if (helpURL != null) { helpListener = new LocalHelpListener(helpURL, locale); } else { log.warn("No HELP URL configured, help system disabled."); } GetHardwareInfoGUIFacade gui = new GetHardwareInfoGUI(dialog.getContentPane(), dialog.getLocale(), null, new ResourceFontLoader(), helpListener); BKUGUIFacade proxy = (BKUGUIFacade) GUIProxy.newInstance(gui, dialog, new Class[] { GetHardwareInfoGUIFacade.class, }); stal = new LocalBKUWorker(proxy, dialog); dialog.setPreferredSize(PREFERRED_SIZE); dialog.pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = dialog.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } dialog.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); return stal; }
From source file:de.interactive_instruments.ShapeChange.UI.DefaultDialog.java
public void initialise(Converter c, Options o, ShapeChangeResult r, String m) { converter = c;//w w w .j a v a2 s. com options = o; result = r; mdl = m; // frame setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent newContentPane = new JPanel(new BorderLayout()); newContentPane.setOpaque(true); setContentPane(newContentPane); // pane JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Main options", createTab1()); tabbedPane.addTab("Secondary options", createTab2()); newContentPane.add(tabbedPane); // frame size int height = 480; int width = 720; pack(); Insets fI = getInsets(); setSize(width + fI.right + fI.left, height + fI.top + fI.bottom); Dimension sD = Toolkit.getDefaultToolkit().getScreenSize(); setLocation((sD.width - width) / 2, (sD.height - height) / 2); }
From source file:com.mirth.connect.client.ui.components.MirthTable.java
public MirthTable(String prefix, Set<String> defaultVisibleColumns) { super();/*from ww w . j av a 2 s. c o m*/ this.prefix = prefix; this.defaultVisibleColumns = defaultVisibleColumns; userPreferences = Preferences.userNodeForPackage(Mirth.class); columnOrderMap = new HashMap<String, Integer>(); if (StringUtils.isNotEmpty(prefix)) { try { userPreferences = Preferences.userNodeForPackage(Mirth.class); String columns = userPreferences.get(prefix + "ColumnOrderMap", ""); if (StringUtils.isNotEmpty(columns)) { columnOrderMap = (Map<String, Integer>) ObjectXMLSerializer.getInstance().deserialize(columns, Map.class); } } catch (Exception e) { } sortKeys = new ArrayList<SortKey>(); try { String sortOrder = userPreferences.get(prefix + "SortOrder", ""); if (StringUtils.isNotEmpty(sortOrder)) { sortKeys = ObjectXMLSerializer.getInstance().deserialize(sortOrder, List.class); } } catch (Exception e) { } } setDragEnabled(true); addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { boolean isAccelerated = (((e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) > 0) || ((e.getModifiers() & InputEvent.CTRL_MASK) > 0)); if ((e.getKeyCode() == KeyEvent.VK_S) && isAccelerated) { PlatformUI.MIRTH_FRAME.doContextSensitiveSave(); } } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } }); /* * Swingx 1.0 has this set to true by default, which doesn't allow dragging and dropping * into tables. Swingx 0.8 had this set to false. Tables that want it set to true can * override it. */ putClientProperty("terminateEditOnFocusLost", Boolean.FALSE); getTableHeader().addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { saveColumnOrder(); } }); final JButton columnControlButton = new JButton(new ColumnControlButton(this).getIcon()); columnControlButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JPopupMenu columnMenu = getColumnMenu(); Dimension buttonSize = columnControlButton.getSize(); int xPos = columnControlButton.getComponentOrientation().isLeftToRight() ? buttonSize.width - columnMenu.getPreferredSize().width : 0; columnMenu.show(columnControlButton, xPos, columnControlButton.getHeight()); } }); setColumnControl(columnControlButton); }
From source file:NewGUI.Statistics.java
public Statistics(User user) { filter = new Filter(this, user); this.user = user; Database.setState();// ww w .j a va 2 s .c om initComponents(); jpChart.setLayout(new BorderLayout()); jpChart.add(chartPanel); initStatistics(); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); int w = this.getWidth(); int h = this.getHeight(); int x = (dim.width - w) / 2; int y = (dim.height - h) / 2; this.setLocation(x, y); }
From source file:net.chris54721.infinitycubed.utils.Utils.java
public static Image getImageResource(String imageName) { ImageIcon image = new ImageIcon(Toolkit.getDefaultToolkit().getImage(getResource(imageName, "png"))); if (image.getImageLoadStatus() == MediaTracker.COMPLETE) return image.getImage(); else {/*from www. jav a 2 s. c o m*/ LogHelper.error("Failed loading image resource " + imageName); return null; } }
From source file:pi.bestdeal.gui.InterfacePrincipale.java
/** * Creates new form InterfacePrincipale// w w w . j av a 2s.com */ public InterfacePrincipale() { initComponents(); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2); jTable1.removeColumn(jTable1.getColumn("ID")); jTable1.removeColumn(jTable1.getColumn("Description")); jTable1.removeColumn(jTable1.getColumn("Achat Actuel")); jTable1.removeColumn(jTable1.getColumn("Etat")); jTable1.removeColumn(jTable1.getColumn("Statut")); jTable1.removeColumn(jTable1.getColumn("Nombre d'Affichage")); jTable1.removeColumn(jTable1.getColumn("Vendeur")); jTable3.removeColumn(jTable3.getColumn("ID")); jTable3.removeColumn(jTable3.getColumn("Description")); jTable3.removeColumn(jTable3.getColumn("Achat Actuel")); jTable3.removeColumn(jTable3.getColumn("Etat")); jTable3.removeColumn(jTable3.getColumn("Statut")); jTable3.removeColumn(jTable3.getColumn("Nombre d'Affichage")); jTable3.removeColumn(jTable3.getColumn("Vendeur")); jTableMessage.removeColumn(jTableMessage.getColumn("ID")); if (jTable3.getModel().getRowCount() != 0) { jTable3.setRowSelectionInterval(0, 0); } if (jTable1.getModel().getRowCount() != 0) { jTable1.setRowSelectionInterval(0, 0); } }
From source file:com.sjsu.uidesign.iScheduleFrame.java
private void setIcon() { setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("icon_taskbar.png"))); }