Java Code Examples for java.awt.Toolkit
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project echo3, under directory /src/server-java/app/nextapp/echo/app/.
Source file: AwtImageReference.java

/** * @see java.io.Serializable */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int width=in.readInt(); int height=in.readInt(); int[] pixels=(int[])in.readObject(); if (pixels != null) { Toolkit toolkit=Toolkit.getDefaultToolkit(); ColorModel colorModel=ColorModel.getRGBdefault(); image=toolkit.createImage(new MemoryImageSource(width,height,colorModel,pixels,0,width)); } }
Example 2
From project echo2, under directory /src/app/java/nextapp/echo2/app/.
Source file: AwtImageReference.java

/** * @see java.io.Serializable */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); int width=in.readInt(); int height=in.readInt(); int[] pixels=(int[])in.readObject(); if (pixels != null) { Toolkit toolkit=Toolkit.getDefaultToolkit(); ColorModel colorModel=ColorModel.getRGBdefault(); image=toolkit.createImage(new MemoryImageSource(width,height,colorModel,pixels,0,width)); } }
Example 3
From project freemind, under directory /freemind/freemind/modes/mindmapmode/.
Source file: MindMapController.java

protected void getClipboard(){ if (clipboard == null) { Toolkit toolkit=Toolkit.getDefaultToolkit(); selection=toolkit.getSystemSelection(); clipboard=toolkit.getSystemClipboard(); } }
Example 4
From project Gmote, under directory /gmoteupdater/src/org/gmote/server/updater/.
Source file: ProgressDialog.java

private static void makeFrame(){ JFrame frame=new JFrame("Gmote Updater"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent component=getInstance(); component.setOpaque(true); frame.setContentPane(component); Toolkit toolkit=Toolkit.getDefaultToolkit(); Dimension screenSize=toolkit.getScreenSize(); frame.pack(); int x=(screenSize.width - 200) / 2; int y=(screenSize.height - 200) / 2; frame.setLocation(x,y); frame.setVisible(true); }
Example 5
From project jMemorize, under directory /src/jmemorize/gui/swing/dialogs/.
Source file: ErrorDialog.java

private void copyDebugTextToClipboard(){ Toolkit toolkit=Toolkit.getDefaultToolkit(); Clipboard clipboard=toolkit.getSystemClipboard(); StringSelection ss=new StringSelection(m_debugText); clipboard.setContents(ss,new ClipboardOwner(){ public void lostOwnership( Clipboard clipboard, Transferable contents){ } } ); }
Example 6
From project flyingsaucer, under directory /flying-saucer-core/src/main/java/org/xhtmlrenderer/swing/.
Source file: Java2DTextRenderer.java

public Java2DTextRenderer(){ scale=Configuration.valueAsFloat("xr.text.scale",1.0f); threshold=Configuration.valueAsFloat("xr.text.aa-fontsize-threshhold",25); Object dummy=new Object(); Object aaHint=Configuration.valueFromClassConstant("xr.text.aa-rendering-hint",dummy); if (aaHint == dummy) { try { Map map; Toolkit tk=Toolkit.getDefaultToolkit(); map=(Map)(tk.getDesktopProperty("awt.font.desktophints")); antiAliasRenderingHint=map.get(RenderingHints.KEY_TEXT_ANTIALIASING); } catch ( Exception e) { antiAliasRenderingHint=RenderingHints.VALUE_TEXT_ANTIALIAS_ON; } } else { antiAliasRenderingHint=aaHint; } if ("true".equals(Configuration.valueFor("xr.text.fractional-font-metrics","false"))) { fractionalFontMetricsHint=RenderingHints.VALUE_FRACTIONALMETRICS_ON; } else { fractionalFontMetricsHint=RenderingHints.VALUE_FRACTIONALMETRICS_OFF; } }
Example 7
From project JaamSim, under directory /com/sandwell/JavaSimulation3D/.
Source file: OrbitBehavior.java

/** * Creates a new OrbitBehavior * @param c The Canvas3D to add the behavior to * @param flags The option flags */ public OrbitBehavior(ModelView v,Sim3DWindow window){ super(v.getCanvas3D(),MOUSE_LISTENER | MOUSE_MOTION_LISTENER); modelView=v; this.window=window; setEnable(true); orbitCenter=new Vector3d(); orbitAngles=new Vector3d(); orbitRadius=DEFAULT_RADIUS; fov=DEFAULT_FOV; integrateTransforms(); Toolkit tk=Toolkit.getDefaultToolkit(); Dimension dim=tk.getBestCursorSize(32,32); dim.height/=2; dim.width/=2; Image cursorImage=tk.getImage(GUIFrame.class.getResource("/resources/images/rotating.png")); try { rotation=tk.createCustomCursor(cursorImage,new Point(dim.width,dim.height),"Rotating"); } catch ( Exception exc) { rotation=null; } tooltip=new JWindow(); tooltip.setAlwaysOnTop(true); textArea=new JTextArea(); textArea.setFocusable(false); textArea.setEditable(false); textArea.setFont(new Font("Verdana",Font.PLAIN,11)); JPanel contentPane=(JPanel)tooltip.getContentPane(); contentPane.setBorder(new LineBorder(Color.black)); tooltip.getContentPane().add(textArea,BorderLayout.CENTER); tooltip.getContentPane().setBackground(new Color(255,255,198)); }
Example 8
From project JsTestDriver, under directory /idea-plugin/src/com/google/jstestdriver/idea/ui/.
Source file: InfoPanel.java

public void toClipboard(String value){ SecurityManager sm=System.getSecurityManager(); if (sm != null) { try { sm.checkSystemClipboardAccess(); } catch ( Exception e) { throw new RuntimeException(e); } } Toolkit tk=Toolkit.getDefaultToolkit(); StringSelection st=new StringSelection(value); Clipboard cp=tk.getSystemClipboard(); cp.setContents(st,this); }
Example 9
/** * Repaints the text. * @param g The graphics context */ public void paint(Graphics gfx){ Graphics2D g2=(Graphics2D)gfx; Toolkit tk=Toolkit.getDefaultToolkit(); Object mapo=tk.getDesktopProperty("awt.font.desktophints"); Map<?,?> map=(Map<?,?>)(mapo); if (map != null) { g2.addRenderingHints(map); } Rectangle clipRect=g2.getClipBounds(); g2.setColor(getBackground()); g2.fillRect(clipRect.x,clipRect.y,clipRect.width,clipRect.height); int height=getLineHeight(); int firstLine=textArea.getFirstLine(); int firstInvalid=firstLine + clipRect.y / height; int lastInvalid=firstLine + (clipRect.y + clipRect.height - 1) / height; try { TokenMarker tokenMarker=textArea.getDocument().getTokenMarker(); int x=textArea.getHorizontalOffset(); for (int line=firstInvalid; line <= lastInvalid; line++) { paintLine(g2,tokenMarker,line,x); } if (tokenMarker != null && tokenMarker.isNextLineRequested()) { int h=clipRect.y + clipRect.height; repaint(0,h,getWidth(),getHeight() - h); } } catch ( Exception e) { System.err.println("Error repainting line range {" + firstInvalid + ","+ lastInvalid+ "}:"); e.printStackTrace(); } }
Example 10
From project addis, under directory /application/src/main/java/org/drugis/addis/gui/builder/.
Source file: D80ReportView.java

private void buildPanel(){ FormLayout layout=new FormLayout("fill:0:grow","p, 3dlu, p"); PanelBuilder builder=new PanelBuilder(layout); CellConstraints cc=new CellConstraints(); builder.setDefaultDialogBorder(); builder.add(new JLabel(d_d80Report),cc.xy(1,1)); JPanel buttonsPanel=new JPanel(); JButton exportButton=new JButton("Export table as html"); exportButton.addActionListener(new ActionListener(){ @Override public void actionPerformed( ActionEvent e){ saveAsHtmlDialog((Component)getParent()); } } ); buttonsPanel.add(exportButton); JButton clipboardButton=new JButton("Copy table to clipboard"); clipboardButton.addActionListener(new ActionListener(){ @Override public void actionPerformed( ActionEvent e){ D80Transferable data=null; try { data=new D80Transferable(d_d80Report); } catch ( ClassNotFoundException e1) { } Clipboard clipboard=Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(data,data); } } ); buttonsPanel.add(clipboardButton); builder.add(buttonsPanel,cc.xy(1,3)); JScrollPane scrollPane=new JScrollPane(builder.getPanel()); scrollPane.setViewportBorder(BorderFactory.createEmptyBorder()); scrollPane.getVerticalScrollBar().setUnitIncrement(6); add(scrollPane); }
Example 11
/** * @param args */ public static void main(String[] args){ final TestMainUI frame=new TestMainUI(); Dimension screen=Toolkit.getDefaultToolkit().getScreenSize(); int X=(screen.width / 2) - (960 / 2); int Y=(screen.height / 2) - (720 / 2); frame.setLocation(X,Y); System.out.println(frame.getLocation().getX()); System.out.println(frame.getLocation().getY()); frame.addWindowListener(new WindowListener(){ @Override public void windowActivated( WindowEvent e){ } @Override public void windowClosed( WindowEvent e){ } @Override public void windowClosing( WindowEvent e){ System.exit(0); } @Override public void windowDeactivated( WindowEvent e){ } @Override public void windowDeiconified( WindowEvent e){ } @Override public void windowIconified( WindowEvent e){ } @Override public void windowOpened( WindowEvent e){ } } ); frame.add(frame.new MainPanel(frame)); frame.setVisible(true); }
Example 12
From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/casemodule/.
Source file: CasePropertiesAction.java

/** * Pop-up the Case Properties Form window where user can change the case properties (example: update case name and remove the image from the case) */ @Override public void performAction(){ Logger.noteAction(this.getClass()); try { String title="Case Properties"; final JFrame frame=new JFrame(title); popUpWindow=new JDialog(frame,title,true); Case currentCase=Case.getCurrentCase(); String caseName=currentCase.getName(); String crDate=currentCase.getCreatedDate(); String caseDir=currentCase.getCaseDirectory(); int totalImage=currentCase.getRootObjectsCount(); Map<Long,String> imgPaths=currentCase.getImagePaths(currentCase.getSleuthkitCase()); CasePropertiesForm cpf=new CasePropertiesForm(currentCase,crDate,caseDir,imgPaths); cpf.setOKButtonActionListener(new ActionListener(){ @Override public void actionPerformed( ActionEvent e){ popUpWindow.dispose(); } } ); popUpWindow.add(cpf); popUpWindow.pack(); popUpWindow.setResizable(false); Dimension screenDimension=Toolkit.getDefaultToolkit().getScreenSize(); double w=popUpWindow.getSize().getWidth(); double h=popUpWindow.getSize().getHeight(); popUpWindow.setLocation((int)((screenDimension.getWidth() - w) / 2),(int)((screenDimension.getHeight() - h) / 2)); popUpWindow.setVisible(true); } catch ( Exception ex) { Logger.getLogger(CasePropertiesAction.class.getName()).log(Level.WARNING,"Error displaying Case Properties window.",ex); } }
Example 13
From project beanmill_1, under directory /src/main/java/com/traxel/lumbermill/event/.
Source file: TableView.java

/** * ------------------------------------- Instance Initialization ------------------------------------- * @param log DOCUMENT ME! * @param filterSet DOCUMENT ME! * @param columnSet DOCUMENT ME! */ public TableView(final Log log,final FilterSet filterSet,final ColumnSet columnSet){ super(new Table(log,filterSet,columnSet)); hotkeyPressed=false; getModel().addTableModelListener(new Unselector()); setColumnModel(getTable().getColumnSet()); setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener(){ @Override public void eventDispatched( final AWTEvent event){ if (LOG.isDebugEnabled()) { LOG.debug("received event: " + event); } final KeyEvent keyEvent=(KeyEvent)event; switch (keyEvent.getID()) { case KeyEvent.KEY_TYPED: { return; } case KeyEvent.KEY_PRESSED: { if (keyEvent.getKeyCode() == NbPreferences.forModule(TableView.class).getInt(NetbeansPanel.PROP_TOOLTIP_HK,-1)) { hotkeyPressed=true; } return; } case KeyEvent.KEY_RELEASED: { if (keyEvent.getKeyCode() == NbPreferences.forModule(TableView.class).getInt(NetbeansPanel.PROP_TOOLTIP_HK,-1)) { hotkeyPressed=false; } return; } default : { return; } } } } ,AWTEvent.KEY_EVENT_MASK); }
Example 14
/** * Constructor used by singleton pattern. Report variables that relate to single sessions are set here */ private UsageReporter(){ random=new Random(); if (!Prefs.get(ReporterOptions.OPTOUTKEY,false)) return; bonejSession=Prefs.get(ReporterOptions.SESSIONKEY,Integer.toString(new Random().nextInt(1000))); int inc=Integer.parseInt(bonejSession); inc++; bonejSession=Integer.toString(inc); Prefs.set(ReporterOptions.SESSIONKEY,inc); Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize(); GraphicsEnvironment ge; ge=GraphicsEnvironment.getLocalGraphicsEnvironment(); int width=0; int height=0; if (!ge.isHeadlessInstance()) { GraphicsDevice[] screens=ge.getScreenDevices(); for (int i=0; i < screens.length; i++) { GraphicsConfiguration[] gc=screens[i].getConfigurations(); for ( GraphicsConfiguration g : gc) { width=Math.max(g.getBounds().x + g.getBounds().width,width); height=Math.max(g.getBounds().y + g.getBounds().height,height); } } } utmsr="utmsr=" + screenSize.width + "x"+ screenSize.height+ "&"; utmvp="utmvp=" + width + "x"+ height+ "&"; utmsc="utmsc=24-bit&"; }
Example 15
From project CBCJVM, under directory /cbc/CBCJVM/src/cbccore/low/.
Source file: CBCSimulator.java

public CBCSimulator(){ try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch ( Exception e) { System.out.println("Error setting native LAF: " + e); } cbob=new SimulatedCBOB(this); sound=new SimulatedSound(this); sensor=new SimulatedSensor(this); device=new SimulatedDevice(this); display=new SimulatedDisplay(this); input=new SimulatedInput(this); servo=new SimulatedServo(this); motor=new SimulatedMotor(this); camera=new SimulatedCamera(this); create=new SimulatedCreate(this); for (int i=0; i < motorSpeedLabels.length; ++i) { motorSpeedLabels[i]=new JLabel(); } if (stdOut == null) { stdOut=System.out; } System.out.println("Welcome to CBCJava"); frame.getContentPane().add(new JScrollPane(display.getTextBox()),BorderLayout.CENTER); System.setOut(display.getPrintStream()); addSidebar(); addMotorLabels(); addButtons(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize(); frame.setSize(Math.min(1024,(int)(screenSize.width * .7)),Math.min(768,(int)(screenSize.height * .7))); frame.setVisible(true); new MotorSpeedUpdater(this,100).start(); }
Example 16
From project ceres, under directory /ceres-glayer/src/test/java/com/bc/ceres/glayer/jaitests/.
Source file: ImageDrawingPerformanceTest.java

public static void main(String[] args) throws IOException { final Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize(); final JFrame frame=new JFrame("ImageDrawingPerformanceTest"); frame.getContentPane().add(new TestCanvas()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(screenSize); frame.setVisible(true); }
Example 17
From project Clotho-Core, under directory /ClothoApps/SequenceChecker/src/jaligner/ui/clipboard/.
Source file: ClipboardHandlerAWT.java

/** * Gets the contents of the system clipboard * @return The text contents of the system clipboard */ public String getContents(){ String contents=null; Clipboard c=Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable data=c.getContents(null); if (data != null && data.isDataFlavorSupported(DataFlavor.stringFlavor)) { try { contents=((String)(data.getTransferData(DataFlavor.stringFlavor))); } catch ( Exception e) { logger.log(Level.WARNING,"Failed getting tranfer data: " + e.getMessage(),e); } } return contents; }
Example 18
/** * This is the main entry-point. It sets the native Look&Feel, creates and shows the MainView. * @param args the command line arguments. The first parameterwill be passed to {@link code_swarm}. It specifies the config-file. */ public static void main(final String args[]){ java.awt.EventQueue.invokeLater(new Runnable(){ public void run(){ Toolkit.getDefaultToolkit().setDynamicLayout(true); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch ( ClassNotFoundException e) { } catch ( InstantiationException e) { } catch ( IllegalAccessException e) { } catch ( UnsupportedLookAndFeelException e) { } try { File f=new File("data/log.properties"); InputStream in=new FileInputStream(f); LogManager.getLogManager().readConfiguration(in); in.close(); } catch ( IOException ex) { Logger.getLogger(MainView.class.getName()).log(Level.SEVERE,null,ex); } catch ( SecurityException ex) { Logger.getLogger(MainView.class.getName()).log(Level.SEVERE,null,ex); } new MainView(args).setVisible(true); } } ); }
Example 19
/** * This is the main entry-point. It sets the native Look&Feel, creates and shows the MainView. * @param args the command line arguments. The first parameterwill be passed to {@link code_swarm}. It specifies the config-file. */ public static void main(final String args[]){ java.awt.EventQueue.invokeLater(new Runnable(){ public void run(){ Toolkit.getDefaultToolkit().setDynamicLayout(true); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch ( ClassNotFoundException e) { } catch ( InstantiationException e) { } catch ( IllegalAccessException e) { } catch ( UnsupportedLookAndFeelException e) { } try { File f=new File("data/log.properties"); InputStream in=new FileInputStream(f); LogManager.getLogManager().readConfiguration(in); in.close(); } catch ( IOException ex) { Logger.getLogger(MainView.class.getName()).log(Level.SEVERE,null,ex); } catch ( SecurityException ex) { Logger.getLogger(MainView.class.getName()).log(Level.SEVERE,null,ex); } new MainView(args).setVisible(true); } } ); }
Example 20
From project codjo-data-process, under directory /codjo-data-process-gui/src/main/java/net/codjo/dataprocess/gui/launcher/result/table/.
Source file: ResultPanel.java

private static void centerWindow(Component cp){ if (cp == null) { throw new IllegalArgumentException(); } Dimension containerSize=Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize=cp.getSize(); if (frameSize.height > containerSize.height) { frameSize.height=containerSize.height; cp.setSize(frameSize); } if (frameSize.width > containerSize.width) { frameSize.width=containerSize.width; cp.setSize(frameSize); } cp.setLocation((containerSize.width - frameSize.width) / 2,(containerSize.height - frameSize.height) / 2); }
Example 21
From project codjo-standalone-common, under directory /src/main/java/net/codjo/gui/operation/.
Source file: ExportProgress.java

/** * DOCUMENT ME! * @param evt Description of Parameter */ public void actionPerformed(ActionEvent evt){ if (manager.done()) { progressMonitor.close(); manager.stop(); Toolkit.getDefaultToolkit().beep(); } else if (progressMonitor.isCanceled()) { timer.stop(); Object[] choix={"Non je continue","Oui je veux arr?er"}; int answer=-1; while (answer == -1) { answer=JOptionPane.showOptionDialog(null,"Etes-vous s?(e) de vouloir annuler l'export en cours ?","Arr? de l'export",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,choix,null); } if (answer == 1) { manager.getTaskWorker().interrupt(); manager.stop(); Toolkit.getDefaultToolkit().beep(); } else { progressMonitor=new ProgressMonitor(ExportProgress.this,"Export de la table " + genericTable.getTable().getTableName() + " en cours...","",0,manager.getLengthOfTask()); timer.start(); } } else { progressMonitor.setNote(manager.getMessage()); progressMonitor.setProgress(manager.getCurrent()); } }
Example 22
From project collaborative-editor, under directory /mpedit/gui/.
Source file: CDialogTemplate.java

protected void init(){ getContentPane().setLayout(new BorderLayout()); this.setResizable(false); JPanel panel_buttons=this.drawButtonPanel(); getContentPane().add(panel_buttons,BorderLayout.SOUTH); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setLocation((int)(Toolkit.getDefaultToolkit().getScreenSize().width / 4),(int)(Toolkit.getDefaultToolkit().getScreenSize().height / 4)); }
Example 23
From project core_4, under directory /impl/src/main/java/org/richfaces/application/.
Source file: InitializationListener.java

public static void initialize(){ if (!checkGetSystemClassLoaderAccess()) { LOGGER.warn("Access to system class loader restricted - AWTInitializer won't be run"); return; } Thread thread=Thread.currentThread(); ClassLoader initialTCCL=thread.getContextClassLoader(); ImageInputStream testStream=null; try { ClassLoader systemCL=ClassLoader.getSystemClassLoader(); thread.setContextClassLoader(systemCL); ImageIO.setUseCache(false); testStream=ImageIO.createImageInputStream(new ByteArrayInputStream(new byte[0])); Toolkit.getDefaultToolkit().getSystemEventQueue(); } catch ( IOException e) { LOGGER.error(e.getMessage(),e); } finally { if (testStream != null) { try { testStream.close(); } catch ( IOException e) { LOGGER.error(e.getMessage(),e); } } thread.setContextClassLoader(initialTCCL); } }
Example 24
From project CraftCommons, under directory /src/main/java/com/craftfire/commons/.
Source file: CraftCommons.java

/** * @param urlstring The url of the image. * @return Image object. */ public static Image urlToImage(String urlstring){ try { URL url=new URL(urlstring); return Toolkit.getDefaultToolkit().getDefaultToolkit().createImage(url); } catch ( MalformedURLException e) { e.printStackTrace(); } return null; }
Example 25
public HavenPanel(int w,int h,GLCapabilitiesChooser cc){ super(stdcaps,cc,null,null); setSize(this.w=w,this.h=h); newui(null); initgl(); if (Toolkit.getDefaultToolkit().getMaximumCursorColors() >= 256) cursmode="awt"; setCursor(Toolkit.getDefaultToolkit().createCustomCursor(TexI.mkbuf(new Coord(1,1)),new java.awt.Point(),"")); }
Example 26
From project dawn-common, under directory /org.dawb.hdf5/src/ncsa/hdf/view/.
Source file: DefaultImageView.java

/** * Creates a RGB indexed image of 256 colors. * @param imageData the byte array of the image data. * @param palette the color lookup table. * @param w the width of the image. * @param h the height of the image. * @return the image. */ public Image createIndexedImage(byte[] imageData,byte[][] palette,int w,int h){ Image theImage=null; IndexColorModel colorModel=new IndexColorModel(8,256,palette[0],palette[1],palette[2]); if (memoryImageSource == null) { memoryImageSource=new MemoryImageSource(w,h,colorModel,imageData,0,w); } else { memoryImageSource.newPixels(imageData,colorModel,0,w); } theImage=Toolkit.getDefaultToolkit().createImage(memoryImageSource); return theImage; }
Example 27
From project dawn-isencia, under directory /com.isencia.passerelle.engine/src/main/java/com/isencia/passerelle/actor/gui/graph/.
Source file: ModelGraphPanel.java

/** * Assuming the contents of the clipboard is MoML code, paste it into the current model by issuing a change request. */ public void paste(){ postUndoableEdit("paste"); Clipboard clipboard=java.awt.Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable transferable=clipboard.getContents(this); GraphPane graphPane=_jgraph.getGraphPane(); GraphController controller=(GraphController)graphPane.getGraphController(); GraphModel model=controller.getGraphModel(); if (transferable == null) return; try { NamedObj container=(NamedObj)model.getRoot(); StringBuffer moml=new StringBuffer(); String pastedSegment=(String)transferable.getTransferData(DataFlavor.stringFlavor); pastedSegment=translateFiguresInSegment(pastedSegment,20,20); moml.append("<group name=\"auto\">\n"); moml.append(pastedSegment); moml.append("</group>\n"); MoMLChangeRequest change=new MoMLChangeRequest(this,container,moml.toString()); change.setUndoable(true); container.requestChange(change); } catch ( Exception ex) { MessageHandler.error("Paste failed",ex); } }
Example 28
From project des, under directory /daemon/lib/apache-log4j-1.2.16/contribs/SvenReimers/gui/.
Source file: JListView.java

public Image loadIcon(String path){ Image img=null; try { URL url=ClassLoader.getSystemResource(path); img=(Image)(Toolkit.getDefaultToolkit()).getImage(url); } catch ( Exception e) { System.out.println("Exception occured: " + e.getMessage() + " - "+ e); } return (img); }
Example 29
From project drugis-common, under directory /common-gui/src/main/java/org/drugis/common/gui/table/.
Source file: TableCopyHandler.java

@SuppressWarnings("serial") public static void registerCopyAction(final JTable jtable){ KeyStroke copy=KeyStroke.getKeyStroke(KeyEvent.VK_C,Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); Action action=new AbstractAction("copy"){ public void actionPerformed( ActionEvent event){ TableCopyHandler handler=new TableCopyHandler(jtable); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(handler,handler); } } ; jtable.registerKeyboardAction(action,copy,JComponent.WHEN_FOCUSED); }
Example 30
From project erjang, under directory /src/main/java/erjang/console/.
Source file: TTYTextAreaDriverControl.java

private void visible_beep(){ { Color fg=area.getForeground(); Color bg=area.getBackground(); area.setForeground(bg); area.setBackground(fg); area.repaint(); Toolkit.getDefaultToolkit().beep(); try { Thread.sleep(100); } catch ( InterruptedException e) { } area.setForeground(fg); area.setBackground(bg); area.repaint(); } }
Example 31
From project Euclidean-Pattern-Generator, under directory /src/com/hisschemoller/sequencer/view/components/.
Source file: MenuBar.java

public MenuBar(ActionListener actionListener){ int shortcut=Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); _fileMenu=new JMenu("File"); add(_fileMenu); JMenuItem menuItem=new JMenuItem("New Project"); menuItem.addActionListener(actionListener); menuItem.setActionCommand(NEW); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,shortcut)); _fileMenu.add(menuItem); menuItem=new JMenuItem("Open Project..."); menuItem.addActionListener(actionListener); menuItem.setActionCommand(OPEN); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,shortcut)); _fileMenu.add(menuItem); menuItem=new JMenuItem("Save Project"); menuItem.addActionListener(actionListener); menuItem.setActionCommand(SAVE); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,shortcut)); _fileMenu.add(menuItem); menuItem=new JMenuItem("Save Project As..."); menuItem.addActionListener(actionListener); menuItem.setActionCommand(SAVE_AS); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,shortcut | InputEvent.SHIFT_DOWN_MASK)); _fileMenu.add(menuItem); _helpMenu=new JMenu("Help"); add(_helpMenu); menuItem=new JMenuItem("Help Contents"); menuItem.addActionListener(actionListener); menuItem.setActionCommand(HELP); _helpMenu.add(menuItem); }
Example 32
/** * Gets an image given either the image resource path or a key to lookup the resource path. * @param image The path or key. * @return The image or null if not found. */ public static Image getImage(String image){ String path=getString(image); if (path == null) { path=image; } URL url=Installer.class.getResource(path); return url != null ? Toolkit.getDefaultToolkit().createImage(url) : null; }
Example 33
From project FScape, under directory /src/main/java/de/sciss/fscape/gui/.
Source file: OpIcon.java

protected synchronized static IconBitmap getIconBitmap(){ if (opib == null) { final Image imgOp=Toolkit.getDefaultToolkit().getImage(OpIcon.class.getResource("op.gif")); opib=new IconBitmap(imgOp,ibWidth,ibHeight); basicIcons=new IconicComponent[5]; for (int i=0; i < basicIcons.length; i++) { basicIcons[i]=new IconicComponent(opib,i); } } return opib; }
Example 34
From project grid-goggles, under directory /Dependent Libraries/controlP5/src/controlP5/.
Source file: ControlP5IOHandler.java

/** * load an image with MediaTracker to prevent nullpointers e.g. in BitFontRenderer * @param theURL * @return */ @Deprecated public Image loadImage(Component theComponent,URL theURL){ if (theComponent == null) { theComponent=cp5.papplet; } Image img=null; img=Toolkit.getDefaultToolkit().createImage(theURL); MediaTracker mt=new MediaTracker(theComponent); mt.addImage(img,0); try { mt.waitForAll(); } catch ( InterruptedException e) { ControlP5.logger().severe("loading image failed." + e.toString()); } catch ( Exception e) { ControlP5.logger().severe("loading image failed." + e.toString()); } return img; }
Example 35
/** * Checks if the action can be performed. * @return True if the action is allowed */ public boolean isEnabled(){ if (comp.isEditable() && comp.isEnabled()) { Transferable contents=Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this); return contents.isDataFlavorSupported(DataFlavor.stringFlavor); } else return false; }
Example 36
From project Haven-and-Hearth-client-modified-by-Ender, under directory /src/haven/.
Source file: HavenPanel.java

public HavenPanel(int w,int h){ super(caps); setSize(this.w=w,this.h=h); initgl(); if (Toolkit.getDefaultToolkit().getMaximumCursorColors() >= 256) cursmode="awt"; setCursor(Toolkit.getDefaultToolkit().createCustomCursor(TexI.mkbuf(new Coord(1,1)),new java.awt.Point(),"")); }
Example 37
From project hudsontrayapp-plugin, under directory /client-common/src/main/java/org/hudson/trayapp/gui/.
Source file: MainFrame.java

/** * This method initializes this * @return void */ private void initialize(){ this.setSize(580,797); this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/org/hudson/trayapp/gui/icons/16x16/hudson.png"))); this.setContentPane(getJContentPane()); this.setTitle("Hudson Tray Application"); addWindowStateListener(new WindowStateListener(){ public void windowStateChanged( WindowEvent e){ if (e.getID() == WindowEvent.WINDOW_STATE_CHANGED && e.getNewState() == Frame.ICONIFIED) { setVisible(false); setState(Frame.NORMAL); dispose(); } } } ); }
Example 38
public static void initScreen(){ if (screen == null) { screen=new LoadScreen(); Dimension dim=Toolkit.getDefaultToolkit().getScreenSize(); screen.setSize(500,50); screen.setLocation((dim.width - screen.getSize().width) / 2,(dim.height - screen.getSize().height) / 2); screen.lblTitle=new javax.swing.JLabel(); screen.pbStatus=new javax.swing.JProgressBar(); screen.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); screen.setAlwaysOnTop(true); screen.setResizable(false); screen.setUndecorated(true); screen.getContentPane().setLayout(new java.awt.GridLayout(2,1)); screen.lblTitle.setFont(new java.awt.Font("DeJaVu Sans",1,14)); screen.lblTitle.setText("{%TITLE}"); screen.pbStatus.setString("Loading..."); screen.pbStatus.setStringPainted(true); screen.add(screen.lblTitle); screen.add(screen.pbStatus); screen.setVisible(true); } else { screen.setVisible(true); } }
Example 39
From project ihtika, under directory /Incubator/JavaToTray/src/main/java/khartn/javatotray/.
Source file: App.java

public void run(){ SystemTray tray=SystemTray.getSystemTray(); String imgName="favicon_1.jpg"; URL imgURL=getClass().getResource(imgName); Image image=Toolkit.getDefaultToolkit().getImage(imgURL); ActionListener exitListener=new ActionListener(){ public void actionPerformed( ActionEvent e){ System.out.println("Exiting..."); System.exit(0); } } ; PopupMenu popup=new PopupMenu(); MenuItem defaultItem=new MenuItem("Exit"); defaultItem.addActionListener(exitListener); popup.add(defaultItem); final TrayIcon trayIcon=new TrayIcon(image,"Tray Demo",popup); ActionListener actionListener=new ActionListener(){ public void actionPerformed( ActionEvent e){ trayIcon.displayMessage("Action Event","An Action Event Has Been Performed!",TrayIcon.MessageType.INFO); } } ; trayIcon.setImageAutoSize(true); trayIcon.addActionListener(actionListener); try { tray.add(trayIcon); } catch ( AWTException e) { System.err.println("TrayIcon could not be added."); } }
Example 40
public GUIController(PApplet newParent,boolean newVisible){ setParent(newParent); setVisible(newVisible); contents=new GUIComponent[5]; lookAndFeel=new IFLookAndFeel(parent,IFLookAndFeel.DEFAULT); userState=new IFPGraphicsState(); SecurityManager security=System.getSecurityManager(); if (security != null) { try { security.checkSystemClipboardAccess(); clipboard=Toolkit.getDefaultToolkit().getSystemClipboard(); } catch ( SecurityException e) { clipboard=new Clipboard("Interfascia Clipboard"); } } else { try { clipboard=Toolkit.getDefaultToolkit().getSystemClipboard(); } catch ( Exception e) { } } parent.registerKeyEvent(this); parent.registerDraw(this); }
Example 41
From project jchempaint, under directory /src/main/org/openscience/jchempaint/.
Source file: AbstractJChemPaintPanel.java

public Image takeTransparentSnapshot(){ Image snapshot=takeSnapshot(); ImageFilter filter=new RGBImageFilter(){ public int markerRGB=renderPanel.getRenderer().getRenderer2DModel().getBackColor().getRGB() | 0xFF000000; public final int filterRGB( int x, int y, int rgb){ if ((rgb | 0xFF000000) == markerRGB) { return 0x00FFFFFF & rgb; } else { return rgb; } } } ; ImageProducer ip=new FilteredImageSource(snapshot.getSource(),filter); return Toolkit.getDefaultToolkit().createImage(ip); }
Example 42
From project jftp, under directory /src/main/java/com/myjavaworld/gui/.
Source file: IntegerField.java

@Override public void insertString(int offset,String str,AttributeSet a) throws BadLocationException { StringBuffer sb=new StringBuffer(getText(0,getLength())); sb.insert(offset,str); try { Integer.parseInt(sb.toString()); super.insertString(offset,str,a); } catch ( NumberFormatException exp) { if (sb.toString().equals("-")) { super.insertString(offset,str,a); } else { Toolkit.getDefaultToolkit().beep(); } } }
Example 43
From project jmd, under directory /src/org/apache/bcel/verifier/.
Source file: GraphicalVerifier.java

/** * Constructor. */ public GraphicalVerifier(){ VerifierAppFrame frame=new VerifierAppFrame(); if (packFrame) { frame.pack(); } else { frame.validate(); } Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize=frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height=screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width=screenSize.width; } frame.setLocation((screenSize.width - frameSize.width) / 2,(screenSize.height - frameSize.height) / 2); frame.setVisible(true); frame.classNamesJList.setModel(new VerifierFactoryListModel()); VerifierFactory.getVerifier(Type.OBJECT.getClassName()); frame.classNamesJList.setSelectedIndex(0); }
Example 44
From project JoshEdit, under directory /org/lateralgm/joshedit/.
Source file: CompletionMenu.java

protected void install(){ long mask=AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK; Toolkit.getDefaultToolkit().addAWTEventListener(this,mask); invoker.addWindowListener(this); invoker.addComponentListener(this); }
Example 45
private void enableMenuItems(MouseEvent e){ JTextComponent textComp=(JTextComponent)e.getComponent(); String selectedText=textComp.getSelectedText(); boolean textSelected=selectedText != null && selectedText.length() > 0; boolean isEditable=textComp.isEditable(); JMenuItem item=(JMenuItem)itemMap.get(ITEM_COPY); if (item != null) { item.setEnabled(textSelected); } item=(JMenuItem)itemMap.get(ITEM_CUT); if (item != null) { item.setEnabled(textSelected && isEditable); } Clipboard clipboard=Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable contents=clipboard.getContents(null); boolean hasTransferableText=(contents != null) && contents.isDataFlavorSupported(DataFlavor.stringFlavor); item=(JMenuItem)itemMap.get(ITEM_PASTE); if (item != null) { item.setEnabled(hasTransferableText && isEditable); } }
Example 46
From project jSite, under directory /src/main/java/de/todesbaum/jsite/gui/.
Source file: ProjectPage.java

/** * Copies the request URI of the currently selected project to the clipboard. */ private void actionCopyURI(){ int selectedIndex=projectList.getSelectedIndex(); if (selectedIndex > -1) { Project selectedProject=(Project)projectList.getSelectedValue(); Clipboard clipboard=Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(new StringSelection(selectedProject.getFinalRequestURI(0)),this); uriCopied=true; } }
Example 47
/** * Creates a new instance. * @param owner The parent frame. * @param pictureFileData The picture to manage. * @param uploadPolicy The upload policy which applies. */ public PictureDialog(Frame owner,PictureFileData pictureFileData,UploadPolicy uploadPolicy){ super(owner,pictureFileData.getFileName(),true); this.uploadPolicy=uploadPolicy; this.pictureFileData=pictureFileData; setCursor(new Cursor(Cursor.WAIT_CURSOR)); this.picturePanel=new DialogPicturePanel(this,uploadPolicy,pictureFileData); this.buttonClose=new JButton(uploadPolicy.getString("buttonClose")); this.buttonClose.setMaximumSize(new Dimension(100,100)); this.buttonClose.addActionListener(this); getContentPane().add(this.buttonClose,BorderLayout.SOUTH); getContentPane().add(this.picturePanel); pack(); Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize(); setBounds(0,0,screenSize.width,screenSize.height); addComponentListener(this); setVisible(true); this.picturePanel.setPictureFile(null,null,null); }
Example 48
void setDimensions(GUI gui,int w,int h){ setVisible(false); dispose(); if (w == 0) { Dimension scrsize=Toolkit.getDefaultToolkit().getScreenSize(); winwidth=scrsize.width; winheight=scrsize.height; win_decoration=false; menuBar.setPreferredSize(new java.awt.Dimension()); this.setUndecorated(true); this.setResizable(false); this.setSize(winwidth,winheight); GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(gui); } else { winwidth=w; winheight=h; win_decoration=true; menuBar.setPreferredSize(null); GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(null); this.setUndecorated(false); this.setResizable(true); this.setVisible(true); System.out.println("Winwidth: " + winwidth + ", Winheight: "+ winheight+ " I: "+ super.getInsets()); this.setSize(winwidth + super.getInsets().left + super.getInsets().right,winheight + super.getInsets().top + super.getInsets().bottom+ menuBar.getHeight()+ menuBar.getHeight()); System.out.println(super.getBounds()); } this.setVisible(true); canvas.requestFocus(); canvas.createBufferStrategy(2); strategy=getGUI().canvas.getBufferStrategy(); }
Example 49
From project leaves, under directory /libraries/controlP5/src/controlP5/.
Source file: ControlP5IOHandler.java

/** * load an image with MediaTracker to prevent nullpointers e.g. in BitFontRenderer * @param theURL * @return */ @Deprecated public Image loadImage(Component theComponent,URL theURL){ if (theComponent == null) { theComponent=cp5.papplet; } Image img=null; img=Toolkit.getDefaultToolkit().createImage(theURL); MediaTracker mt=new MediaTracker(theComponent); mt.addImage(img,0); try { mt.waitForAll(); } catch ( InterruptedException e) { ControlP5.logger().severe("loading image failed." + e.toString()); } catch ( Exception e) { ControlP5.logger().severe("loading image failed." + e.toString()); } return img; }
Example 50
public Image loadIcon(String path){ Image img=null; try { URL url=ClassLoader.getSystemResource(path); img=(Image)(Toolkit.getDefaultToolkit()).getImage(url); } catch ( Exception e) { System.out.println("Exception occured: " + e.getMessage() + " - "+ e); } return (img); }
Example 51
From project log4jna, under directory /thirdparty/log4j/contribs/SvenReimers/gui/.
Source file: JListView.java

public Image loadIcon(String path){ Image img=null; try { URL url=ClassLoader.getSystemResource(path); img=(Image)(Toolkit.getDefaultToolkit()).getImage(url); } catch ( Exception e) { System.out.println("Exception occured: " + e.getMessage() + " - "+ e); } return (img); }
Example 52
From project maple-ide, under directory /build/windows/launcher/launch4j/demo/SimpleApp/src/net/sf/launch4j/example/.
Source file: SimpleApp.java

public SimpleApp(String[] args){ super("Java Application"); final int inset=100; Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize(); setBounds(inset,inset,screenSize.width - inset * 2,screenSize.height - inset * 2); JMenu menu=new JMenu("File"); menu.add(new JMenuItem("Open")); menu.add(new JMenuItem("Save")); JMenuBar mb=new JMenuBar(); mb.setOpaque(true); mb.add(menu); setJMenuBar(mb); this.addWindowListener(new WindowAdapter(){ public void windowClosing( WindowEvent e){ System.exit(123); } } ); setVisible(true); StringBuffer sb=new StringBuffer("Java version: "); sb.append(System.getProperty("java.version")); sb.append("\nJava home: "); sb.append(System.getProperty("java.home")); sb.append("\nCurrent dir: "); sb.append(System.getProperty("user.dir")); if (args.length > 0) { sb.append("\nArgs: "); for (int i=0; i < args.length; i++) { sb.append(args[i]); sb.append(' '); } } JOptionPane.showMessageDialog(this,sb.toString(),"Info",JOptionPane.INFORMATION_MESSAGE); }
Example 53
From project medsavant, under directory /medsavant/MedSavantClient/src/org/ut/biolab/medsavant/view/genetics/variantinfo/.
Source file: BasicVariantSubInspector.java

private Component getCopyButton(final String key){ JButton button=ViewUtil.getTexturedButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.COPY)); button.setToolTipText("Copy " + key); button.addActionListener(new ActionListener(){ @Override public void actionPerformed( ActionEvent ae){ String selection=p.getValue(key); StringSelection data=new StringSelection(selection); Clipboard clipboard=Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(data,data); DialogUtils.displayMessage("Copied \"" + selection + "\" to clipboard."); } } ); return button; }
Example 54
From project mididuino, under directory /editor/core/src/processing/core/.
Source file: PGraphics2D.java

protected void allocate(){ pixelCount=width * height; pixels=new int[pixelCount]; if (primarySurface) { cm=new DirectColorModel(32,0x00ff0000,0x0000ff00,0x000000ff); ; mis=new MemoryImageSource(width,height,pixels,0,width); mis.setFullBufferUpdates(true); mis.setAnimated(true); image=Toolkit.getDefaultToolkit().createImage(mis); } }
Example 55
From project milton, under directory /milton/milton-caldav/src/main/java/info/ineighborhood/cardme/util/.
Source file: Util.java

/** * <p>Centers an given Window to the user's screen.</p> * @param w */ public static void center(Window w){ int screenWidth=Toolkit.getDefaultToolkit().getScreenSize().width; int screenHeight=Toolkit.getDefaultToolkit().getScreenSize().height; int windowWidth=w.getWidth(); int windowHeight=w.getHeight(); if (windowHeight > screenHeight) { return; } if (windowWidth > screenWidth) { return; } int x=(screenWidth - windowWidth) / 2; int y=(screenHeight - windowHeight) / 2; w.setLocation(x,y); }
Example 56
From project milton2, under directory /external/cardme/src/main/java/info/ineighborhood/cardme/util/.
Source file: Util.java

/** * <p>Centers an given Window to the user's screen.</p> * @param w */ public static void center(Window w){ int screenWidth=Toolkit.getDefaultToolkit().getScreenSize().width; int screenHeight=Toolkit.getDefaultToolkit().getScreenSize().height; int windowWidth=w.getWidth(); int windowHeight=w.getHeight(); if (windowHeight > screenHeight) { return; } if (windowWidth > screenWidth) { return; } int x=(screenWidth - windowWidth) / 2; int y=(screenHeight - windowHeight) / 2; w.setLocation(x,y); }
Example 57
From project Moneychanger, under directory /src/main/java/com/moneychanger/core/util/.
Source file: Utility.java

public static Point getLocation(Dimension componentDimension){ Point center=new Point(0,0); Dimension toolkitDimension=Toolkit.getDefaultToolkit().getScreenSize(); center.x=center.x + (toolkitDimension.width - componentDimension.width) / 2; center.y=center.y + (toolkitDimension.height - componentDimension.height) / 2; return center; }
Example 58
From project multibit, under directory /src/main/java/org/multibit/viewsystem/swing/action/.
Source file: PasteSwatchAction.java

private Image getImageFromClipboard(){ Transferable transferable=Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.imageFlavor)) { try { return (Image)transferable.getTransferData(DataFlavor.imageFlavor); } catch ( UnsupportedFlavorException e) { e.printStackTrace(); } catch ( IOException e) { e.printStackTrace(); } } return null; }
Example 59
From project nenya, under directory /core/src/main/java/com/threerings/util/.
Source file: IdleTracker.java

public void start(KeyboardManager keymgr,Window root,RunQueue rqueue){ EventListener listener=new EventListener(); try { Toolkit.getDefaultToolkit().addAWTEventListener(listener,EVENT_MASK); } catch ( SecurityException se) { if (root != null) { root.addKeyListener(listener); root.addMouseListener(listener); root.addMouseMotionListener(listener); } } if (keymgr != null) { keymgr.registerKeyObserver(new KeyboardManager.KeyObserver(){ public void handleKeyEvent( int id, int keyCode, long timestamp){ handleUserActivity(); } } ); } new Interval(rqueue){ @Override public void expired(){ checkIdle(); } } .schedule(_toIdleTime / 3,true); }
Example 60
From project niravCS2103, under directory /CS2103/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/lf5/.
Source file: LF5Appender.java

/** * @return the screen width from Toolkit.getScreenSize()if possible, otherwise returns 800 * @see java.awt.Toolkit */ protected static int getScreenWidth(){ try { return Toolkit.getDefaultToolkit().getScreenSize().width; } catch ( Throwable t) { return 800; } }
Example 61
From project nuxeo-distribution, under directory /nuxeo-launcher/src/main/java/org/nuxeo/launcher/gui/.
Source file: NuxeoLauncherGUI.java

protected void initFrame(){ final NuxeoLauncherGUI controller=this; SwingUtilities.invokeLater(new Runnable(){ @Override public void run(){ try { if (nuxeoFrame != null) { executor.shutdownNow(); nuxeoFrame.close(); executor=newExecutor(); } nuxeoFrame=createNuxeoFrame(controller); nuxeoFrame.pack(); Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize(); nuxeoFrame.setLocation(screenSize.width / 2 - (nuxeoFrame.getWidth() / 2),screenSize.height / 2 - (nuxeoFrame.getHeight() / 2)); nuxeoFrame.setVisible(true); } catch ( HeadlessException e) { log.error(e); } } } ); if (nuxeoFrameUpdater == null) { nuxeoFrameUpdater=new Thread(){ @Override public void run(){ while (true) { updateServerStatus(); try { Thread.sleep(UPDATE_FREQUENCY); } catch ( InterruptedException e) { break; } } } } ; nuxeoFrameUpdater.start(); } }
Example 62
public void pasteClipboard(){ Transferable t=Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); try { if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) { addContents((String)t.getTransferData(DataFlavor.stringFlavor)); table.repaint(); } } catch ( Exception e) { e.printStackTrace(); } }
Example 63
From project oops, under directory /application/src/main/java/nl/rug/ai/mas/oops/.
Source file: GUI.java

/** * Build a menu item with key accelerator. * @param title * @param mnemonic * @param accelerator * @param shift * @return */ private JMenuItem buildMenuItem(String title,char mnemonic,int accelerator,boolean shift){ JMenuItem item=buildMenuItem(title,mnemonic); int keyMask=Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); if (shift) { keyMask=keyMask | KeyEvent.SHIFT_MASK; } item.setAccelerator(KeyStroke.getKeyStroke(accelerator,keyMask,false)); return item; }
Example 64
From project Openbravo-POS-iPhone-App, under directory /UnicentaPOS/src-beans/com/openbravo/editor/.
Source file: JEditorNumber.java

protected void transCharInternal(char cTrans){ String sOldText=getText(); if (cTrans == '\u007f') { reset(); } else if (cTrans == '-') { m_bNegative=!m_bNegative; } else if ((cTrans == '0') && (m_iNumberStatus == NUMBER_ZERONULL)) { m_sNumber="0"; } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9') && (m_iNumberStatus == NUMBER_ZERONULL)) { m_iNumberStatus=NUMBER_INT; m_sNumber=Character.toString(cTrans); } else if (cTrans == '.' && m_iNumberStatus == NUMBER_ZERONULL) { m_iNumberStatus=NUMBER_DEC; m_sNumber="0."; } else if ((cTrans == '0' || cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9') && (m_iNumberStatus == NUMBER_INT)) { m_sNumber+=cTrans; } else if (cTrans == '.' && m_iNumberStatus == NUMBER_INT) { m_iNumberStatus=NUMBER_DEC; m_sNumber+='.'; } else if ((cTrans == '0' || cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9') && (m_iNumberStatus == NUMBER_DEC)) { m_sNumber+=cTrans; } else { Toolkit.getDefaultToolkit().beep(); } firePropertyChange("Text",sOldText,getText()); }