Java 类java.awt.Toolkit 实例源码

项目:openjdk-jdk10    文件:PointerInfoCrashTest.java   
private static void testMouseInfoPeer() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (toolkit instanceof ComponentFactory) {
        ComponentFactory componentFactory = (ComponentFactory) toolkit;

        MouseInfoPeer mouseInfoPeer = componentFactory.getMouseInfoPeer();
        mouseInfoPeer.fillPointWithCoords(new Point());

        Window win = new Window(null);
        win.setSize(300, 300);
        win.setVisible(true);

        mouseInfoPeer.isWindowUnderMouse(win);
        win.dispose();
    }
}
项目:AgentWorkbench    文件:ChartEditorJDialog.java   
/**
 * Instantiates a new JDialog as chart editor .
 *
 * @param dynForm the {@link DynForm}
 * @param startArgIndex the start argument index
 */
public ChartEditorJDialog(DynForm dynForm, int startArgIndex) {

    this.dynForm = dynForm;
    this.startArgIndex = startArgIndex;

    this.setModal(true);
    this.setSize(600, 450);
    this.setIconImage(imageAgentGUI);
    this.setTitle(Language.translate("Edit Chart", Language.EN));

    // --- center dialog --------------------
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 
    int top = (screenSize.height - this.getHeight()) / 2; 
    int left = (screenSize.width - this.getWidth()) / 2; 
    this.setLocation(left, top);    


    this.setContentPane(this.getContentPane());
    this.getContentPane().add(getButtonPane(), BorderLayout.SOUTH);

}
项目:jdk8u-jdk    文件:DitherTest.java   
@Override
protected void processEvent(AWTEvent evt) {
    int id = evt.getID();
    if (id != KeyEvent.KEY_TYPED) {
        super.processEvent(evt);
        return;
    }

    KeyEvent kevt = (KeyEvent) evt;
    char c = kevt.getKeyChar();

    // Digits, backspace, and delete are okay
    // Note that the minus sign is not allowed (neither is decimal)
    if (Character.isDigit(c) || (c == '\b') || (c == '\u007f')) {
        super.processEvent(evt);
        return;
    }

    Toolkit.getDefaultToolkit().beep();
    kevt.consume();
}
项目:WordnetLoom    文件:ShortCut.java   
/**
 * Ukonanie akcji zwiazanej ze skrotem
 */
public void doAction() {
    // czy jest to skrót do przycisku
    // jeśli tak to wywoływany jest click
    if (button != null && button.isEnabled()) {
        button.doClick();

        // jest to skrót do komponentu
        // a więc ustawienie focuu
    } else if (component != null) {
        if (pane != null) {          // zmienie aktywnej zakladki
            pane.setSelectedIndex(tabIndex);
            Toolkit.getDefaultToolkit().sync();
        }
        component.grabFocus(); // ustawienie focusu
    } else if (action != null) {
        action.doAction(null, -1);
    }
}
项目:litiengine    文件:ImageProcessing.java   
/**
 * All pixels that have the specified color are rendered transparent.
 *
 * @param img
 *          the img
 * @param color
 *          the color
 * @return the image
 */
public static Image applyAlphaChannel(final Image img, final Color color) {
  if (color == null || img == null) {
    return img;
  }

  final ImageFilter filter = new RGBImageFilter() {

    // the color we are looking for... Alpha bits are set to opaque
    public final int markerRGB = color.getRGB() | 0xFF000000;

    @Override
    public final int filterRGB(final int x, final int y, final int rgb) {
      if ((rgb | 0xFF000000) == this.markerRGB) {
        // Mark the alpha bits as zero - transparent
        return 0x00FFFFFF & rgb;
      } else {
        // nothing to do
        return rgb;
      }
    }
  };

  final ImageProducer ip = new FilteredImageSource(img.getSource(), filter);
  return Toolkit.getDefaultToolkit().createImage(ip);
}
项目:incubator-netbeans    文件:TooltipWindow.java   
public void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel(master.getTextComponent());

    Window w = SwingUtilities.windowForComponent(master.getTextComponent());
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y - 1);  // slight visual adjustment
    contentWindow.setVisible(true);

    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
}
项目:incubator-netbeans    文件:HintsUI.java   
private void removePopup() {
    Toolkit.getDefaultToolkit().removeAWTEventListener(this);
    if (listPopup != null) {
        closeSubList();
        if( tooltipPopup != null )
            tooltipPopup.hide();
        tooltipPopup = null;
        listPopup.hide();
        if (hintListComponent != null) {
            hintListComponent.getView().removeMouseListener(this);
            hintListComponent.getView().removeMouseMotionListener(this);
        }
        if (errorTooltip != null) {
            errorTooltip.removeMouseListener(this);
        }
        hintListComponent = null;
        errorTooltip = null;
        listPopup = null;
        if (hintIcon != null)
            hintIcon.setToolTipText(NbBundle.getMessage(HintsUI.class, "HINT_Bulb")); // NOI18N
    }
}
项目:blitzcrank_screenshoot    文件:Blitzcrank.java   
/**
 * @param args the command line arguments
 * @throws java.awt.AWTException
 * @throws java.lang.InterruptedException
 * @throws java.io.IOException
 */
public static void main(String[] args) throws AWTException, InterruptedException, IOException {
    String stringfyCurrent = String.valueOf(System.currentTimeMillis());
    String path = "{path}";
    String name = "capture" + stringfyCurrent;
    String type = ".jpg";
    //--
    File file = new File(path + name + type);
    BufferedImage imagexd = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageIO.write(imagexd, type.replace(".", ""), baos);
    byte[] bytes = baos.toByteArray();

    OutputStream out = new FileOutputStream(file);

    out.write(bytes);

}
项目:jNotifyOSD    文件:ServerOSD.java   
private Dimension getDeviceDimension() {
    Dimension deviceDimension = null;
    try {
        Toolkit tool = Toolkit.getDefaultToolkit();
        deviceDimension = tool.getScreenSize();
    } catch (AWTError e) {
        System.out.println(CLASS_NAME+": ERROR! "+ e.getMessage());
        e.printStackTrace();
    }
    return deviceDimension;
}
项目:incubator-netbeans    文件:FastTypeProvider.java   
@Override
public void open() {
    boolean success = false;
    try {
        final FileObject fo = getFileObject();
        if (fo != null) {
            final DataObject d = DataObject.find(fo);
            final EditCookie cake = d.getCookie(EditCookie.class);
            if (cake != null) {
                cake.edit();
                success = true;
            }
        }
    } catch (DataObjectNotFoundException ex) {
        Exceptions.printStackTrace(ex);
    }
    if (!success) {
        Toolkit.getDefaultToolkit().beep();
    }
}
项目:incubator-netbeans    文件:KeyboardDnd.java   
private void stop( boolean commitChanges ) {
    Toolkit.getDefaultToolkit().removeAWTEventListener( this );
    TopComponent.getRegistry().removePropertyChangeListener( this );
    try {
        if( commitChanges ) {
            TopComponentDroppable droppable = targets.get( currentIndex );
            Point dropLocation = currentSide.getDropLocation( droppable );
            if( droppable.canDrop( draggable, dropLocation ) ) {
                dndManager.performDrop( dndManager.getController(), droppable, draggable, dropLocation );
            }
        }
    } finally {
        dndManager.dragFinished();
        dndManager.dragFinishedEx();
        if( currentDnd == this )
            currentDnd = null;
    }
}
项目:jdk8u-jdk    文件:MaximizedToMaximized.java   
public static void main(String[] args) throws Exception {

       Frame frame = new Frame();
        final Toolkit toolkit = Toolkit.getDefaultToolkit();
        final GraphicsEnvironment graphicsEnvironment =
                GraphicsEnvironment.getLocalGraphicsEnvironment();
        final GraphicsDevice graphicsDevice =
                graphicsEnvironment.getDefaultScreenDevice();

        final Dimension screenSize = toolkit.getScreenSize();
        final Insets screenInsets = toolkit.getScreenInsets(
                graphicsDevice.getDefaultConfiguration());

        final Rectangle availableScreenBounds = new Rectangle(screenSize);

        availableScreenBounds.x += screenInsets.left;
        availableScreenBounds.y += screenInsets.top;
        availableScreenBounds.width -= (screenInsets.left + screenInsets.right);
        availableScreenBounds.height -= (screenInsets.top + screenInsets.bottom);

        frame.setBounds(availableScreenBounds.x, availableScreenBounds.y,
                availableScreenBounds.width, availableScreenBounds.height);
        frame.setVisible(true);

        Rectangle frameBounds = frame.getBounds();
        frame.setExtendedState(Frame.MAXIMIZED_BOTH);
        ((SunToolkit) toolkit).realSync();

        Rectangle maximizedFrameBounds = frame.getBounds();
        if (maximizedFrameBounds.width < frameBounds.width
                || maximizedFrameBounds.height < frameBounds.height) {
            throw new RuntimeException("Maximized frame is smaller than non maximized");
        }
    }
项目:incubator-netbeans    文件:ModeResizer.java   
private void stop( boolean commitChanges ) {
    Toolkit.getDefaultToolkit().removeAWTEventListener( this );
    TopComponent.getRegistry().removePropertyChangeListener( this );
    if( null != frame ) {
        boolean glassVisible = oldGlass.isVisible();
        frame.setGlassPane( oldGlass);
        oldGlass.setVisible( glassVisible );
    }
    if( !commitChanges ) {
        if( null != parentSplitter ) {
            parentSplitter.finishDraggingTo( originalParentLocation );
        }
        splitter.finishDraggingTo( originalLocation );
    }
    if( currentResizer == this )
        currentResizer = null;
}
项目:jdk8u-jdk    文件:Metalworks.java   
public static void main(String[] args) {
    UIManager.put("swing.boldMetal", Boolean.FALSE);
    JDialog.setDefaultLookAndFeelDecorated(true);
    JFrame.setDefaultLookAndFeelDecorated(true);
    Toolkit.getDefaultToolkit().setDynamicLayout(true);
    System.setProperty("sun.awt.noerasebackground", "true");
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (UnsupportedLookAndFeelException e) {
        System.out.println(
                "Metal Look & Feel not supported on this platform. \n"
                + "Program Terminated");
        System.exit(0);
    }
    JFrame frame = new MetalworksFrame();
    frame.setVisible(true);
}
项目:Equella    文件:JNumberTextField.java   
@Override
public void insertString(int offset, String s, AttributeSet attributeSet) throws BadLocationException
{
    try
    {
        int value = Integer.parseInt(s);
        if( value < 0 )
        {
            Toolkit.getDefaultToolkit().beep();
            return;
        }
    }
    catch( NumberFormatException ex )
    {
        Toolkit.getDefaultToolkit().beep();
        return;
    }

    super.insertString(offset, s, attributeSet);

    if( Integer.parseInt(getText(0, getLength())) > maxNumber )
    {
        Toolkit.getDefaultToolkit().beep();
        super.remove(offset, s.length());
    }
}
项目:incubator-netbeans    文件:SystemActionTest.java   
/** Test that iconResource really works.
 * @see "#26887"
 */
public void testIcons() throws Exception {
    Image i = Toolkit.getDefaultToolkit().getImage(SystemActionTest.class.getResource("data/someicon.gif"));
    int h = imageHash("Control icon", i, 16, 16);
    SystemAction a = SystemAction.get(SystemAction1.class);
    CharSequence log = Log.enable("org.openide.util", Level.WARNING);
    assertEquals("Absolute slash-initial iconResource works (though deprecated)", h, imageHash("icon1", icon2Image(a.getIcon()), 16, 16));
    assertTrue(log.toString(), log.toString().contains("Initial slashes in Utilities.loadImage deprecated"));
    a = SystemAction.get(SystemAction2.class);
    assertEquals("Absolute no-slash-initial iconResource works", h, imageHash("icon2", icon2Image(a.getIcon()), 16, 16));
    a = SystemAction.get(SystemAction3.class);
    assertEquals("Relative iconResource works (though deprecated)", h, imageHash("icon3", icon2Image(a.getIcon()), 16, 16));
    assertTrue(log.toString(), log.toString().contains("Deprecated relative path"));
    a = SystemAction.get(SystemAction4.class);
    a.getIcon();
    assertTrue(log.toString(), log.toString().contains("No such icon"));
}
项目:openjdk-jdk10    文件:CSS.java   
ImageIcon getImage(URL base) {
    if (!loadedImage) {
        synchronized(this) {
            if (!loadedImage) {
                URL url = CSS.getURL(base, svalue);
                loadedImage = true;
                if (url != null) {
                    image = new ImageIcon();
                    Image tmpImg = Toolkit.getDefaultToolkit().createImage(url);
                    if (tmpImg != null) {
                        image.setImage(tmpImg);
                    }
                }
            }
        }
    }
    return image;
}
项目:jdk8u-jdk    文件:WPageDialog.java   
@Override
@SuppressWarnings("deprecation")
public void addNotify() {
    synchronized(getTreeLock()) {
        Container parent = getParent();
        if (parent != null && parent.getPeer() == null) {
            parent.addNotify();
        }

        if (getPeer() == null) {
            ComponentPeer peer = ((WToolkit)Toolkit.getDefaultToolkit()).
                createWPageDialog(this);
            setPeer(peer);
        }
        super.addNotify();
    }
}
项目:jdk8u-jdk    文件:bug7189299.java   
public static void main(String[] args) throws Exception {
    final SunToolkit toolkit = ((SunToolkit) Toolkit.getDefaultToolkit());

    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            setup();
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            try {
                verifySingleDefaultButtonModelListener();
                doTest();
                verifySingleDefaultButtonModelListener();
            } finally {
                frame.dispose();
            }
        }
    });
}
项目:LP_Proyecto    文件:Principal.java   
private void jl_Imagen_ContactsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jl_Imagen_ContactsMouseClicked
    // TODO add your handling code here:
    jl_Imagen_Contacts.setText("");

    JFileChooser fc = new JFileChooser();
    FileFilter filtro = new FileNameExtensionFilter("Imagenes", "png", "jpg", "jpeg", "gif");
    fc.setFileFilter(filtro);

    File Archivo;
    int op = fc.showOpenDialog(this);

    if (op == JFileChooser.APPROVE_OPTION) {
        Archivo = fc.getSelectedFile();
        RutaImagen = Archivo.getPath();
        System.out.println(Archivo.getPath());
        Image Img = Toolkit.getDefaultToolkit().createImage(Archivo.getPath()).getScaledInstance(180, 229, 0);
        this.jl_Imagen_Contacts.setIcon(new ImageIcon(Img));
    }
}
项目:SpotSpotter    文件:BMPReader.java   
protected static Image readImage24(FileInputStream fs, BitmapHeader bh) throws IOException {
    Image image;
    if (bh.iSizeimage == 0) {
        bh.iSizeimage = ((((bh.iWidth * bh.iBitcount) + 31) & ~31) >> 3);
        bh.iSizeimage *= bh.iHeight;
    }
    final int npad = (bh.iSizeimage / bh.iHeight) - bh.iWidth * 3;
    final int ndata[] = new int[bh.iHeight * bh.iWidth];
    final byte brgb[] = new byte[(bh.iWidth + npad) * 3 * bh.iHeight];
    fs.read(brgb, 0, (bh.iWidth + npad) * 3 * bh.iHeight);
    int nindex = 0;
    for (int j = 0; j < bh.iHeight; j++) {
        for (int i = 0; i < bh.iWidth; i++) {
            ndata[bh.iWidth * (bh.iHeight - j - 1) + i] = constructInt3(brgb, nindex);
            nindex += 3;
        }
        nindex += npad;
    }
    image = Toolkit.getDefaultToolkit()
            .createImage(new MemoryImageSource(bh.iWidth, bh.iHeight, ndata, 0, bh.iWidth));
    fs.close();
    return (image);
}
项目:geomapapp    文件:Cursors.java   
public static Cursor getCursor( int which ) {
    Cursor c = (Cursor) cursorCache.get(new Integer(which));
    if (c != null) return c;

    try {
        ClassLoader loader = org.geomapapp.util.Icons.class.getClassLoader();
        String path = "org/geomapapp/resources/icons/" +names[which];
        java.net.URL url = loader.getResource(path);
        BufferedImage im = ImageIO.read(url);
        String name = names[which].substring(0, names[which].lastIndexOf("."));
        System.out.println(im.getWidth() + "\t" + im.getHeight());

        c = Toolkit.getDefaultToolkit().createCustomCursor(im, new Point(hotSpot[which][0],hotSpot[which][1]), name);
        cursorCache.put(new Integer(which), c);
        return c;
    } catch(Exception ex) {
        return Cursor.getDefaultCursor();
    }
}
项目:OpenJSharp    文件:ExecutableInputMethodManager.java   
ExecutableInputMethodManager() {

        // set up host adapter locator
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        try {
            if (toolkit instanceof InputMethodSupport) {
                InputMethodDescriptor hostAdapterDescriptor =
                    ((InputMethodSupport)toolkit)
                    .getInputMethodAdapterDescriptor();
                if (hostAdapterDescriptor != null) {
                    hostAdapterLocator = new InputMethodLocator(hostAdapterDescriptor, null, null);
                }
            }
        } catch (AWTException e) {
            // if we can't get a descriptor, we'll just have to do without native input methods
        }

        javaInputMethodLocatorList = new Vector<InputMethodLocator>();
        initializeInputMethodLocatorList();
    }
项目:powertext    文件:RtfGenerator.java   
/**
 * Resets this generator.  All document information and content is
 * cleared.
 */
public void reset() {
    fontList.clear();
    colorList.clear();
    document.setLength(0);
    lastWasControlWord = false;
    lastFontIndex = 0;
    lastFGIndex = 0;
    lastBold = false;
    lastItalic = false;
    lastFontSize = DEFAULT_FONT_SIZE;
    screenRes = Toolkit.getDefaultToolkit().getScreenResolution();
}
项目:NotifyTools    文件:SimpleBeanInfo.java   
public Image loadImage(String resourceName) {
    if (null == resourceName) {
        return null;
    }

    URL file = getClass().getResource(resourceName);

    if (file != null) {
        return Toolkit.getDefaultToolkit().createImage(file);
    }
    return null;
}
项目:jaer    文件:EyeTarget.java   
/** Creates a new instance of EyeTarget */
public EyeTarget() {
    super(caps);
    addGLEventListener(this);
    setAutoSwapBufferMode(true);
    glu=new GLU();
    glut=new GLUT();
    Dimension ss=Toolkit.getDefaultToolkit().getScreenSize();
    ss.setSize(ss.width/2,ss.height/2);
    setSize(ss);
    target=new Target();
}
项目:marathonv5    文件:TransparentFrame.java   
public void dispose() {
    disposed = true;
    Toolkit.getDefaultToolkit().removeAWTEventListener(this);
    SwingUtilities.invokeLater(new Runnable() {
        @Override public void run() {
            paintTransparentFrame();
        }
    });
}
项目:freecol    文件:DropListener.java   
/**
 * Gets called when the mouse was released on a Swing component
 * that has this object as a MouseListener.
 *
 * @param e The event that holds the information about the mouse click.
 */
@Override
public void mouseReleased(MouseEvent e) {
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    Transferable clipData = clipboard.getContents(clipboard);
    if (clipData != null) {
        if (clipData.isDataFlavorSupported(DefaultTransferHandler.flavor)) {
            JComponent comp = (JComponent)e.getSource();
            TransferHandler handler = comp.getTransferHandler();
            handler.importData(comp, clipData);
        }
    }
}
项目:Hydrograph    文件:TransformDialog.java   
/**
 * Return the initial size of the dialog.
 */
@Override
protected Point getInitialSize() {
    container.getShell().layout(true, true);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    final Point newSize = container.getShell().computeSize(screenSize.width, screenSize.height, true);
    container.getShell().setSize(newSize);
    return newSize;
}
项目:litiengine    文件:KeyBoard.java   
@Override
public String getText(final KeyEvent e) {
  if (this.isPressed(KeyEvent.VK_SHIFT) || Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK)) {
    return this.getShiftText(e);
  } else if (this.isPressed(KeyEvent.VK_ALT_GRAPH)) {
    return this.getAltText(e);
  } else {
    return this.getNormalText(e);
  }
}
项目:jdk8u-jdk    文件:DragSource.java   
private static Cursor load(String name) {
    if (GraphicsEnvironment.isHeadless()) {
        return null;
    }

    try {
        return (Cursor)Toolkit.getDefaultToolkit().getDesktopProperty(name);
    } catch (Exception e) {
        e.printStackTrace();

        throw new RuntimeException("failed to load system cursor: " + name + " : " + e.getMessage());
    }
}
项目:marathonv5    文件:DocumentSizeFilter.java   
public void insertString(FilterBypass fb, int offs, String str, AttributeSet a) throws BadLocationException {
    if (DEBUG) {
        System.out.println("in DocumentSizeFilter's insertString method");
    }

    // This rejects the entire insertion if it would make
    // the contents too long. Another option would be
    // to truncate the inserted string so the contents
    // would be exactly maxCharacters in length.
    if ((fb.getDocument().getLength() + str.length()) <= maxCharacters)
        super.insertString(fb, offs, str, a);
    else
        Toolkit.getDefaultToolkit().beep();
}
项目:rekit-game    文件:GameView.java   
/**
 * Center {@link Frame} relative to monitor.
 *
 * @param frame
 *            the frame
 */
private void center(Frame frame) {
    Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (int) ((dimension.getWidth() - frame.getWidth()) / 2);
    int y = (int) ((dimension.getHeight() - frame.getHeight()) / 2);
    frame.setLocation(x, y);
}
项目:incubator-netbeans    文件:SimpleEngine.java   
public Action getAction (final String action, String containerCtx, final Map context) {
    return new AbstractAction () {
        public void actionPerformed (ActionEvent ae) {
            SimpleInvoker invoker = interp.getInvoker(action);
            System.err.println("Invoker is " + invoker);
            System.err.println("Invoking " + action + " on " + context);
            if (invoker != null) {
                invoker.invoke(context);
            } else {
                Toolkit.getDefaultToolkit().beep();
            }
        }
    };
}
项目:incubator-netbeans    文件:TooltipWindow.java   
/**
 * Closes the window
 */
void shutdown() {
    Toolkit.getDefaultToolkit().removeAWTEventListener(this);
    if (contentWindow != null) {
        contentWindow.getOwner().removeWindowFocusListener(this);
        contentWindow.removeWindowFocusListener(this);
        contentWindow.dispose();
    }
    contentWindow = null;
}
项目:myfaces-trinidad    文件:ImageUtils.java   
/**
 * Return true if the Image has been successfully loaded.
 * <p>
 * @param image Image to check for sucessful loading
 * <p>
 * @return True if the image has been sucessfully loaded.
 */
static public boolean isImageLoaded(
  Image image
  )
{
  Toolkit tk = Toolkit.getDefaultToolkit();
  int status = tk.checkImage(image, -1, -1, null);

  return ((status & (ImageObserver.ALLBITS |ImageObserver.FRAMEBITS)) != 0);
}
项目:sentimental-analyzer    文件:Analyzer.java   
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
    frame.setIconImage(Toolkit.getDefaultToolkit().getImage("E:\\图片\\u=1829416607,2140971604&fm=21&gp=0.jpg"));
    frame.setType(Type.UTILITY);
    frame.setTitle("网络电影评论情感倾向性分类");
    frame.setBounds(100, 100, 639, 412);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JMenuBar menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);

    JMenu mnNewMenu = new JMenu("数据集自动标注");
    menuBar.add(mnNewMenu);

    JMenuItem mntmNewMenuItem_2 = new JMenuItem("自动标注");
    mnNewMenu.add(mntmNewMenuItem_2);

    JMenu mnNewMenu_1 = new JMenu("情感分析");
    menuBar.add(mnNewMenu_1);

    JMenuItem mntmNewMenuItem_3 = new JMenuItem("朴素贝叶斯算法");
    mnNewMenu_1.add(mntmNewMenuItem_3);

    JMenuItem mntmNewMenuItem_4 = new JMenuItem("N-Gram算法");
    mnNewMenu_1.add(mntmNewMenuItem_4);

    JMenuItem mntmNewMenuItem_5 = new JMenuItem("支持向量机");
    mnNewMenu_1.add(mntmNewMenuItem_5);

    JMenu mnNewMenu_2 = new JMenu("关于");
    menuBar.add(mnNewMenu_2);

    JMenuItem mntmNewMenuItem = new JMenuItem("作者");
    mnNewMenu_2.add(mntmNewMenuItem);

    JMenuItem mntmNewMenuItem_1 = new JMenuItem("New menu item");
    mnNewMenu_2.add(mntmNewMenuItem_1);
}
项目:incubator-netbeans    文件:Utils.java   
public static Graphics2D prepareGraphics(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    Map rhints = (Map)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N
    if( rhints == null && Boolean.getBoolean("swing.aatext") ) { //NOI18N
         g2.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON );
    } else if( rhints != null ) {
        g2.addRenderingHints( rhints );
    }
    return g2;
}
项目:org.alloytools.alloy    文件:OurUtil.java   
/**
 * Construct a new JMenuItem then add it to an existing JMenu.
 * 
 * @param parent - the JMenu to add this JMenuItem into (or null if you
 *            don't want to add it to any JMenu yet)
 * @param label - the text to show on the menu
 * @param attrs - a list of attributes to apply onto the new JMenuItem
 *            <p>
 *            If one positive number a is supplied, we call setMnemonic(a)
 *            <p>
 *            If two positive numbers a and b are supplied, and a!=VK_ALT,
 *            and a!=VK_SHIFT, we call setMnemoic(a) and setAccelerator(b)
 *            <p>
 *            If two positive numbers a and b are supplied, and a==VK_ALT or
 *            a==VK_SHIFT, we call setAccelerator(a | b)
 *            <p>
 *            If an ActionListener is supplied, we call addActionListener(x)
 *            <p>
 *            If an Boolean x is supplied, we call setEnabled(x)
 *            <p>
 *            If an Icon x is supplied, we call setIcon(x)
 */
public static JMenuItem menuItem(JMenu parent, String label, Object... attrs) {
    JMenuItem m = new JMenuItem(label, null);
    int accelMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    boolean hasMnemonic = false;
    for (Object x : attrs) {
        if (x instanceof Character || x instanceof Integer) {
            int k = (x instanceof Character) ? ((int) ((Character) x)) : ((Integer) x).intValue();
            if (k < 0)
                continue;
            if (k == KeyEvent.VK_ALT) {
                hasMnemonic = true;
                accelMask = accelMask | InputEvent.ALT_MASK;
                continue;
            }
            if (k == KeyEvent.VK_SHIFT) {
                hasMnemonic = true;
                accelMask = accelMask | InputEvent.SHIFT_MASK;
                continue;
            }
            if (!hasMnemonic) {
                m.setMnemonic(k);
                hasMnemonic = true;
            } else
                m.setAccelerator(KeyStroke.getKeyStroke(k, accelMask));
        }
        if (x instanceof ActionListener)
            m.addActionListener((ActionListener) x);
        if (x instanceof Icon)
            m.setIcon((Icon) x);
        if (x instanceof Boolean)
            m.setEnabled((Boolean) x);
    }
    if (parent != null)
        parent.add(m);
    return m;
}
项目:jaer    文件:SimpleIPotSliderTextControl.java   
private void valueTextFieldActionPerformed(final java.awt.event.ActionEvent evt) {// GEN-FIRST:event_valueTextFieldActionPerformed
    // new pots current value entered
    // System.out.println("value field action performed");
    try {
        startEdit();
        pot.setBitValue(Integer.parseInt(valueTextField.getText()));
        endEdit();
    }
    catch (final NumberFormatException e) {
        Toolkit.getDefaultToolkit().beep();
        valueTextField.selectAll();
    }
}