List of usage examples for java.awt Toolkit getDefaultToolkit
public static synchronized Toolkit getDefaultToolkit()
From source file:heimerdinger.HeimerdingerFrame.java
/** * Creates new form HeimerdingerFrame/*from w ww .j a va 2 s. co m*/ */ public HeimerdingerFrame() { initComponents(); if (!connectDB()) { JOptionPane.showMessageDialog(null, "Could not connect to database. Check LOG for more infomation.", "ERROR", JOptionPane.ERROR_MESSAGE); System.exit(0); } this.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - (this.getWidth() / 2), (Toolkit.getDefaultToolkit().getScreenSize().height / 2) - (this.getHeight() / 2)); initLastSession(); }
From source file:TelasBanzos.TelaRelatorioAproveitamento.java
/** * Creates new form TelaNovoOrcamento/*from ww w.ja v a 2s.c o m*/ */ public TelaRelatorioAproveitamento() { initComponents(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(80, "0", "Nota"); dataset.setValue(70, "0", "Frequncia"); JFreeChart chart = ChartFactory.createBarChart("Aproveitamento", "Aproveitamento", "", dataset, PlotOrientation.VERTICAL, false, true, false); //colocar cor nas barras CategoryPlot plot = chart.getCategoryPlot(); BarRenderer render = (BarRenderer) plot.getRenderer(); render.setSeriesPaint(0, Color.blue); ChartPanel myChartPanel = new ChartPanel(chart, true); pnGraf.add(myChartPanel); setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("BanzosIcon.png")));//para setar um icone na janela }
From source file:ui.Interface.java
public Interface() throws UnsupportedLookAndFeelException, ParseException { UIManager.setLookAndFeel(new SyntheticaSilverMoonLookAndFeel()); initComponents();//from w w w. j a v a 2s.co m setResizable(false); Dimension screenSize = new Dimension(Toolkit.getDefaultToolkit().getScreenSize()); Dimension windowSize = new Dimension(getPreferredSize()); int wdwLeft = 50 + screenSize.width / 2 - windowSize.width / 2; int wdwTop = screenSize.height / 2 - windowSize.height / 2; pack(); setLocation(wdwLeft, wdwTop); setTitle("Sorting Algo Simulator v2.0"); }
From source file:Utils.java
/** * <p>//ww w. j a v a 2 s . c o m * Returns the <code>Point</code> at which a window should be placed to * center that window on the screen. * </p> * <p> * Some thought was taken as to whether to implement a method such as this, * or to simply make a method that, given a window, will center it. It was * decided that it is better to not alter an object within a method. * </p> * * @param window The window to calculate the center point for. This object * can not be null. * * @return the <code>Point</code> at which the window should be placed to * center that window on the screen. */ private static Rectangle getUsableDeviceBounds(Window window) { Window owner = window.getOwner(); GraphicsConfiguration gc = null; if (owner == null) { gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDefaultConfiguration(); } else { gc = owner.getGraphicsConfiguration(); } Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc); Rectangle bounds = gc.getBounds(); bounds.x += insets.left; bounds.y += insets.top; bounds.width -= (insets.left + insets.right); bounds.height -= (insets.top + insets.bottom); return bounds; }
From source file:SplashScreen.java
/** * Create a new splash screen object of the specified image. * The image file is located and referred to through the deployment, not * the local file system; A typical value might be "/com/company/splash.jpg". * /* w w w. j av a 2s.c o m*/ * @param imageFileName Name of image file resource to act as splash screen. */ public SplashScreen(String imageFileName) { super(new Frame()); try { Toolkit toolkit = Toolkit.getDefaultToolkit(); URL imageUrl = getClass().getResource(imageFileName); image_ = toolkit.getImage(imageUrl); MediaTracker mediaTracker = new MediaTracker(this); mediaTracker.addImage(image_, 0); mediaTracker.waitForID(0); width_ = image_.getWidth(this); height_ = image_.getHeight(this); Dimension screenSize = toolkit.getScreenSize(); x_ = (screenSize.width - width_) / 2; y_ = (screenSize.height - height_) / 2; } catch (Exception exception) { exception.printStackTrace(); image_ = null; } }
From source file:GUI.ResponseStatistics.java
/** * Creates a sample dataset */ private void InitPieChart(JFreeChart chart) { ChartPanel chartPanel = new ChartPanel(chart); // default size chartPanel.setSize(560, 800);/*from ww w.j av a2 s. c o m*/ Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - chartPanel.getWidth()) / 2); int y = (int) ((dimension.getHeight() - chartPanel.getHeight()) / 2); chartPanel.setLocation(WIDTH, WIDTH); // add it to our application setContentPane(chartPanel); chartPanel.addChartMouseListener(new ChartMouseListener() { public void chartMouseClicked(ChartMouseEvent e) { wait = false; } public void chartMouseMoved(ChartMouseEvent e) { } }); }
From source file:ModalMessage.java
private void initComponents()//GEN-BEGIN:initComponents { //this.setUndecorated(true); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); setTitle("BORG"); this.setSize(165, 300); this.setContentPane(getJPanel()); pack();/* w w w. j a v a2 s .c o m*/ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension labelSize = jScrollPane.getPreferredSize(); setLocation(screenSize.width / 2 - (labelSize.width / 2), screenSize.height / 2 - (labelSize.height / 2)); }
From source file:IntroExample.java
public IntroExample() { JMenu fileMenu = new JMenu("File"); JMenu editMenu = new JMenu("Edit"); JMenu otherMenu = new JMenu("Other"); JMenu subMenu = new JMenu("SubMenu"); JMenu subMenu2 = new JMenu("SubMenu2"); // Assemble the File menus with mnemonics ActionListener printListener = new ActionListener() { public void actionPerformed(ActionEvent event) { System.out.println("Menu item [" + event.getActionCommand() + "] was pressed."); }/* w w w . j av a 2s . co m*/ }; for (int i = 0; i < fileItems.length; i++) { JMenuItem item = new JMenuItem(fileItems[i], fileShortcuts[i]); item.addActionListener(printListener); fileMenu.add(item); } // Assemble the File menus with keyboard accelerators for (int i = 0; i < editItems.length; i++) { JMenuItem item = new JMenuItem(editItems[i]); item.setAccelerator(KeyStroke.getKeyStroke(editShortcuts[i], Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); item.addActionListener(printListener); editMenu.add(item); } // Insert a separator in the Edit Menu in Position 1 after "Undo" editMenu.insertSeparator(1); // Assemble the submenus of the Other Menu JMenuItem item; subMenu2.add(item = new JMenuItem("Extra 2")); item.addActionListener(printListener); subMenu.add(item = new JMenuItem("Extra 1")); item.addActionListener(printListener); subMenu.add(subMenu2); // Assemble the Other Menu itself otherMenu.add(subMenu); otherMenu.add(item = new JCheckBoxMenuItem("Check Me")); item.addActionListener(printListener); otherMenu.addSeparator(); ButtonGroup buttonGroup = new ButtonGroup(); otherMenu.add(item = new JRadioButtonMenuItem("Radio 1")); item.addActionListener(printListener); buttonGroup.add(item); otherMenu.add(item = new JRadioButtonMenuItem("Radio 2")); item.addActionListener(printListener); buttonGroup.add(item); otherMenu.addSeparator(); otherMenu.add(item = new JMenuItem("Potted Plant", new ImageIcon("image.gif"))); item.addActionListener(printListener); // Finally, add all the menus to the menu bar add(fileMenu); add(editMenu); add(otherMenu); }
From source file:Main.java
public Main() { toolkit = Toolkit.getDefaultToolkit(); timer = new Timer(); timer.scheduleAtFixedRate(new RemindTask(), 0, //initial delay 1 * 1000); //subsequent rate }
From source file:CursorUtil.java
public static Cursor createCursor(BufferedImage img, Point hotspot, String name) throws IndexOutOfBoundsException, Exception { Toolkit tk = Toolkit.getDefaultToolkit(); Dimension d = tk.getBestCursorSize(img.getWidth(), img.getHeight()); if ((d.width == img.getWidth()) && (d.height == img.getHeight())) return tk.createCustomCursor(img, hotspot, name); if ((d.width + d.height) < 2) throw new Exception("Invalid Size"); BufferedImage newImg = GraphicsUtil.createImage(d.width, d.height); Graphics2D g2 = newImg.createGraphics(); g2.drawImage(img, // what to draw 0, // dest left 0, // dest top newImg.getWidth(), // dest right newImg.getHeight(), // dest bottom 0, // src left 0, // src top img.getWidth(), // src right img.getHeight(), // src bottom null // to notify of image updates );//from www. j a v a 2 s.co m return tk.createCustomCursor(newImg, hotspot, name); }