List of usage examples for java.awt Toolkit getDefaultToolkit
public static synchronized Toolkit getDefaultToolkit()
From source file:com.wet.wired.jsr.recorder.DesktopScreenRecorder.java
public Rectangle initialiseScreenCapture() { try {/*from w ww. ja v a 2 s. co m*/ robot = new Robot(); } catch (AWTException awe) { awe.printStackTrace(); return null; } return new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); }
From source file:com.enderville.enderinstaller.ui.Installer.java
private void init() { JPanel p = new JPanel(); p.setLayout(new MigLayout("fill", "[fill,grow|]", "[fill,grow||]")); //lc col row p.add(getMainPane(), new CC().spanX().grow()); p.add(getProgressBar(), new CC().growX()); p.add(getCancelButton(), new CC().alignX("right")); p.add(getNextButton(), new CC().alignX("right")); setContentPane(p);/*from w ww. ja v a2 s .co m*/ Image bg = Toolkit.getDefaultToolkit().getImage(Installer.class.getResource("/wiki.png")); this.setIconImage(bg); }
From source file:com.mc.printer.model.StartTask.java
@Override public void onSucceeded(Object object) { if (object instanceof Exception) { Exception e = (Exception) object; logger.error(e.getMessage());// w w w.j a v a 2 s .co m } if (AutoPrinterApp.isRegister) { logger.info("connect to remote server,please wait..."); } new FileTask(FileTask.TYPE_DOWNLOAD, ClientConstants.GUIDE_DOWNLOAD_DIR, "") { @Override public void responseResult(String file) { if (AutoPrinterApp.isRegister) { /*video*/ new FileTask(FileTask.TYPE_DOWNLOAD, ClientConstants.VIDEO_LIB, "video") { @Override public void responseResult(String file) { logger.info("download video task completed.>" + ClientConstants.VIDEO_LIB); } }.execute(); } else { logger.debug("client has not register, can't fetch the video."); } final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); final int maxWidth = (int) screenSize.getWidth(); final int maxHeight = (int) Math.round(screenSize.getHeight() / 3); //??1/3 logger.info("load application completed. try to open guide and form..."); new BaseTask() { @Override public Object doBackgrounp() { new OpenGuidePaperTask(Constants.GUIDE_BOTTOM_FILE) { @Override public void onSucceed(Object object, HashMap<String, Integer> statusMap) { if (object == null || object instanceof Exception) { topRealHeight = maxHeight; } else if (object instanceof GuideBean) { GuideBean guideBean = (GuideBean) object; GuidePanel panel = new GuidePanel(null, guideBean, maxWidth, guideBean.getHeight()) { @Override public GuidePanel parentGuideWindow() { return null; } @Override public GuidePanel targetWindowAfterAuth() { return null; } }; panel.enableButtonByRemote(statusMap); AutoPrinterApp.getClientMain().setBottomUI(panel); topRealHeight = panel.getCurrentGuideBean().getHeight(); } } }.run(); new OpenGuidePaperTask(Constants.GUIDE_TOP_FILE) { @Override public void onSucceed(Object object, HashMap<String, Integer> statusMap) { if (object == null || object instanceof Exception) { bottomRealHeight = maxHeight; } else if (object instanceof GuideBean) { GuideBean guideBean = (GuideBean) object; GuidePanel panel = new GuidePanel(null, guideBean, maxWidth, guideBean.getHeight()) { @Override public GuidePanel parentGuideWindow() { return null; } @Override public GuidePanel targetWindowAfterAuth() { return null; } }; panel.enableButtonByRemote(statusMap); AutoPrinterApp.getClientMain().setTopUI(panel); bottomRealHeight = panel.getCurrentGuideBean().getHeight(); } } }.run(); return null; } @Override public void onSucceeded(Object object) { final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int maxHeight = screenSize.height - topRealHeight - bottomRealHeight; final int finalHeight = maxHeight > screenSize.height ? screenSize.height : maxHeight; new OpenGuidePaperTask(Constants.GUIDE_MAIN_FILE) { @Override public void onSucceed(Object object, HashMap<String, Integer> statusMap) { if (object == null || object instanceof Exception) { } else if (object instanceof GuideBean) { GuideBean guideBean = (GuideBean) object; GuidePanel panel = new GuidePanel(null, guideBean, maxWidth, finalHeight == 0 ? guideBean.getHeight() : finalHeight) { @Override public GuidePanel parentGuideWindow() { return null; } @Override public GuidePanel targetWindowAfterAuth() { return null; } }; panel.enableButtonByRemote(statusMap); AutoPrinterApp.getClientMain().setWorkUI(panel); } } }.execute(); } }.execute(); } }.execute(); }
From source file:playground.sergioo.capacitiesChanger2012.gui.NetworkPanel.java
public NetworkPanel(LayersWindow window, NetworkPainter networkPainter) { super();/*from w w w. ja v a2 s .com*/ addressLocator = new AddressLocator(TransformationFactory .getCoordinateTransformation(TransformationFactory.WGS84, TransformationFactory.WGS84_UTM48N)); this.window = window; addLayer(new Layer(networkPainter)); this.setBackground(backgroundColor); calculateBoundaries(); super.setPreferredSize(Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height); addMouseListener(this); addMouseMotionListener(this); addMouseWheelListener(this); addKeyListener(this); setFocusable(true); }
From source file:ProtocolRunner.java
/** Creates new form ProtocolRunner */ public ProtocolRunner() { // set the native look and feel try{//from w ww .j a v a2 s . c o m UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName()); }catch(Exception e) {} initComponents(); // size it so that it appears full screen Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); this.setSize(screen.width, screen.height); this.pack(); this.setExtendedState(Frame.MAXIMIZED_BOTH); }
From source file:scheduler.benchmarker.manager.CreateSimpleSplineChart.java
private void createSubChart(ChartPanel chart) { JFrame frameGraph = new JFrame();//new JFrame("FINAL RULES ARRANGEMENT"); frameGraph.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frameGraph.setForeground(new Color(76, 76, 76)); frameGraph.setBackground(new Color(246, 244, 242)); Dimension window = Toolkit.getDefaultToolkit().getScreenSize(); if (window.width < 1074 && window.height < 800) frameGraph.setPreferredSize(new Dimension(window.width, window.height)); else//from w ww . j av a 2s . c o m frameGraph.setPreferredSize(new Dimension(1074, 800)); frameGraph.setLocation((window.width - frameGraph.getPreferredSize().width) / 2, (window.height - frameGraph.getPreferredSize().height) / 2); frameGraph.setResizable(true); frameGraph.add(chart); frameGraph.pack(); frameGraph.setVisible(true); }
From source file:mergedoc.ui.MergeDocFrame.java
/** * ??????//from w ww .j a v a 2 s . com * @throws MergeDocException ????? */ private void initComponent() throws MergeDocException { // ???? preferencePanel = new PreferencePanel(); mergeManager = new MergeManager(); // ??? mainPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.X_AXIS)); mainPanel.add(preferencePanel); // ?????? JPanel outerPanel = new JPanel(); outerPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.Y_AXIS)); outerPanel.add(mainPanel); outerPanel.add(ComponentFactory.createSpacer(0, 7)); outerPanel.add(buttonBar); getContentPane().add(outerPanel); // ? initListener(); buttonBar.setState(buttonBar.INIT_STATE); // ConfigManager config = ConfigManager.getInstance(); String iconPath = config.getFile("icon.png").toString(); Image icon = Toolkit.getDefaultToolkit().createImage(iconPath); setIconImage(icon); // setTitle(SETTING_TITLE); Persister psst = Persister.getInstance(); setLocation(psst.getInt(Persister.WINDOW_X, 0), psst.getInt(Persister.WINDOW_Y, 0)); setSize(psst.getInt(Persister.WINDOW_WIDTH, 700), psst.getInt(Persister.WINDOW_HEIGHT, 570)); int state = psst.getInt(Persister.WINDOW_STATE, NORMAL); if ((state & Frame.ICONIFIED) != ICONIFIED) { setExtendedState(state); } setVisible(true); }
From source file:ProgressBarDemo.java
public ProgressBarDemo() { super(new BorderLayout()); task = new LongTask(); //Create the demo's UI. startButton = new JButton("Start"); startButton.setActionCommand("start"); startButton.addActionListener(this); progressBar = new JProgressBar(0, task.getLengthOfTask()); progressBar.setValue(0);/*from w ww .j a v a 2 s . co m*/ progressBar.setStringPainted(true); taskOutput = new JTextArea(5, 20); taskOutput.setMargin(new Insets(5, 5, 5, 5)); taskOutput.setEditable(false); taskOutput.setCursor(null); //inherit the panel's cursor //see bug 4851758 JPanel panel = new JPanel(); panel.add(startButton); panel.add(progressBar); add(panel, BorderLayout.PAGE_START); add(new JScrollPane(taskOutput), BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); //Create a timer. timer = new Timer(ONE_SECOND, new ActionListener() { public void actionPerformed(ActionEvent evt) { progressBar.setValue(task.getCurrent()); String s = task.getMessage(); if (s != null) { taskOutput.append(s + newline); taskOutput.setCaretPosition(taskOutput.getDocument().getLength()); } if (task.isDone()) { Toolkit.getDefaultToolkit().beep(); timer.stop(); startButton.setEnabled(true); setCursor(null); //turn off the wait cursor progressBar.setValue(progressBar.getMinimum()); } } }); }
From source file:com.lcdfx.pipoint.PiPoint.java
public PiPoint(String[] args) { this.addWindowListener(new WindowAdapter() { @Override/*w w w .j a v a2s . c om*/ public void windowClosing(WindowEvent ev) { shutDown(); } }); // add logging logger = Logger.getLogger(this.getClass().getName()); logger.log(Level.INFO, "PiPoint version " + PiPoint.class.getPackage().getImplementationVersion() + " running under " + System.getProperty("java.vm.name") + " v" + System.getProperty("java.vm.version")); // get command line options CommandLineParser parser = new BasicParser(); Map<String, String> cmdOptions = new HashMap<String, String>(); Options options = new Options(); options.addOption(new Option("f", "fullscreen", false, "fullscreen mode (no cursor)")); CommandLine cmd = null; try { cmd = parser.parse(options, args); for (Option option : cmd.getOptions()) { cmdOptions.put(option.getOpt(), option.getValue()); } } catch (ParseException e) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar pipoint.jar", options); System.exit(0); } if (cmd.hasOption("f")) { setUndecorated(true); BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor"); getContentPane().setCursor(blankCursor); } // instantiate the RendererManager mgr = new DlnaRendererManager(this); mgr.refreshDevices(); nowPlayingPanel = new NowPlayingPanel(this); mgr.getRenderer().addListener(nowPlayingPanel); devicePanel = new DevicePanel(this); this.getContentPane().setPreferredSize(new Dimension(DISPLAY_WIDTH, DISPLAY_HEIGHT)); this.getContentPane().add(devicePanel); }
From source file:neembuu.uploader.captcha.CaptchaForm.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor./*from ww w . j a v a 2s .c o m*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jPanel1 = new javax.swing.JPanel(); captchaImage = new neembuu.uploader.captcha.ImagePanel(imageURL, httpContext); okButton = new javax.swing.JButton(); cancelButton = new javax.swing.JButton(); captchaTextField = new javax.swing.JTextField(); jPanel3 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 100, Short.MAX_VALUE)); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 100, Short.MAX_VALUE)); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); setAlwaysOnTop(true); setIconImage(Toolkit.getDefaultToolkit() .getImage((getClass().getResource("/neembuuuploader/resources/Icon.png")))); setMinimumSize(new java.awt.Dimension(332, 178)); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); java.awt.GridBagLayout layout = new java.awt.GridBagLayout(); layout.columnWidths = new int[] { 0, 5, 0 }; layout.rowHeights = new int[] { 0, 5, 0, 5, 0 }; getContentPane().setLayout(layout); captchaImage.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, new java.awt.Color(255, 51, 51))); captchaImage.setPreferredSize(new java.awt.Dimension(300, 57)); javax.swing.GroupLayout captchaImageLayout = new javax.swing.GroupLayout(captchaImage); captchaImage.setLayout(captchaImageLayout); captchaImageLayout.setHorizontalGroup(captchaImageLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 314, Short.MAX_VALUE)); captchaImageLayout.setVerticalGroup(captchaImageLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 107, Short.MAX_VALUE)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.ipadx = 2; gridBagConstraints.ipady = 50; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); getContentPane().add(captchaImage, gridBagConstraints); okButton.setText("OK"); okButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { okButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; getContentPane().add(okButton, gridBagConstraints); cancelButton.setText("Cancel"); cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 4; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; getContentPane().add(cancelButton, gridBagConstraints); captchaTextField.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { captchaTextFieldKeyPressed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 3; gridBagConstraints.ipady = 3; gridBagConstraints.insets = new java.awt.Insets(5, 10, 5, 10); getContentPane().add(captchaTextField, gridBagConstraints); jPanel3.setLayout(new java.awt.GridBagLayout()); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 0, Short.MAX_VALUE)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 3; jPanel3.add(jPanel2, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 3; getContentPane().add(jPanel3, gridBagConstraints); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); setBounds((screenSize.width - 341) / 2, (screenSize.height - 234) / 2, 341, 234); }