Java Code Examples for java.awt.Toolkit#getImage()

The following examples show how to use java.awt.Toolkit#getImage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IDEF0TabView.java    From ramus with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (Action.SELECTED_KEY.equals(evt.getPropertyName())) {
        if ((Boolean) evt.getNewValue()) {
            Toolkit toolkit = Toolkit.getDefaultToolkit();
            Image image = toolkit.getImage(getClass()
                    .getResource("/images/pen-cursor.png"));
            java.awt.Point point = new java.awt.Point(0, 15);
            panel.getMovingArea().setVisualCopyCursor(
                    toolkit.createCustomCursor(image, point,
                            "CopyVisualCursor"));
        } else {
            panel.getMovingArea().setVisualCopyCursor(null);
        }
    }
}
 
Example 2
Source File: Util.java    From beanshell with Apache License 2.0 6 votes vote down vote up
public static void startSplashScreen()
{
    int width=275,height=148;
    Window win=new Window( new Frame() );
    win.pack();
    BshCanvas can=new BshCanvas();
    can.setSize( width, height ); // why is this necessary?
    Toolkit tk=Toolkit.getDefaultToolkit();
    Dimension dim=tk.getScreenSize();
    win.setBounds(
        dim.width/2-width/2, dim.height/2-height/2, width, height );
    win.add("Center", can);
    Image img=tk.getImage(
        Interpreter.class.getResource("/bsh/util/lib/splash.gif") );
    MediaTracker mt=new MediaTracker(can);
    mt.addImage(img,0);
    try { mt.waitForAll(); } catch ( Exception e ) { }
    Graphics gr=can.getBufferedGraphics();
    gr.drawImage(img, 0, 0, can);
    win.setVisible(true);
    win.toFront();
    splashScreen = win;
}
 
Example 3
Source File: UnitOverview.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
public UnitOverview(ClientGUI clientgui) {
    this.clientgui = clientgui;
    fm = clientgui.getFontMetrics(FONT);

    Toolkit toolkit = clientgui.getToolkit();
    scrollUp = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), "scrollUp2.png").toString()); //$NON-NLS-1$
    PMUtil.setImage(scrollUp, clientgui);
    scrollDown = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), "scrollDown2.png").toString()); //$NON-NLS-1$
    PMUtil.setImage(scrollDown, clientgui);
    pageUp = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), "pageUp2.png").toString()); //$NON-NLS-1$
    PMUtil.setImage(pageUp, clientgui);
    pageDown = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), "pageDown2.png").toString()); //$NON-NLS-1$
    PMUtil.setImage(pageDown, clientgui);
    scrollUpG = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), "scrollUp2_G.png").toString()); //$NON-NLS-1$
    PMUtil.setImage(scrollUp, clientgui);
    scrollDownG = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), "scrollDown2_G.png").toString()); //$NON-NLS-1$
    PMUtil.setImage(scrollDown, clientgui);
    pageUpG = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), "pageUp2_G.png").toString()); //$NON-NLS-1$
    PMUtil.setImage(pageUp, clientgui);
    pageDownG = toolkit.getImage(new MegaMekFile(Configuration.widgetsDir(), "pageDown2_G.png").toString()); //$NON-NLS-1$
    PMUtil.setImage(pageDown, clientgui);
    
    visible = GUIPreferences.getInstance().getShowUnitOverview();
}
 
Example 4
Source File: GLChartPanel.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Set mouse mode
 *
 * @param value Mouse mode
 */
@Override
public final void setMouseMode(MouseMode value) {
    this.mouseMode = value;
    Image image;
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Cursor customCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
    switch (this.mouseMode) {
        case SELECT:
            customCursor = Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
            break;
        case ZOOM_IN:
            image = toolkit.getImage(this.getClass().getResource("/images/zoom_in_32x32x32.png"));
            customCursor = toolkit.createCustomCursor(image, new Point(8, 8), "Zoom In");
            break;
        case ZOOM_OUT:
            image = toolkit.getImage(this.getClass().getResource("/images/zoom_out_32x32x32.png"));
            customCursor = toolkit.createCustomCursor(image, new Point(8, 8), "Zoom In");
            break;
        case PAN:
            image = toolkit.getImage(this.getClass().getResource("/images/Pan_Open_32x32x32.png"));
            customCursor = toolkit.createCustomCursor(image, new Point(8, 8), "Pan");
            break;
        case IDENTIFER:
            image = toolkit.getImage(this.getClass().getResource("/images/identifer_32x32x32.png"));
            customCursor = toolkit.createCustomCursor(image, new Point(8, 8), "Identifer");
            break;
        case ROTATE:
            image = toolkit.getImage(this.getClass().getResource("/images/rotate.png"));
            customCursor = toolkit.createCustomCursor(image, new Point(8, 8), "Identifer");
            break;
    }
    this.setCursor(customCursor);
}
 
Example 5
Source File: SplashFrame.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
public SplashFrame() {
    super(new Frame());

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Image image = toolkit.getImage(MainFrame.class.getResource("SplashBug1.png"));
    Image image2 = toolkit.getImage(MainFrame.class.getResource("SplashBug2B.png"));
    Image imageReverse = toolkit.getImage(MainFrame.class.getResource("SplashBug1reverse.png"));
    Image image2Reverse = toolkit.getImage(MainFrame.class.getResource("SplashBug2reverseB.png"));

    JLabel l = new JLabel(new ImageIcon(MainFrame.class.getResource("spotbugs.png")));
    JPanel p = new JPanel();
    Viewer viewer = new Viewer(image, image2, imageReverse, image2Reverse);
    final JPanel bottom = viewer;
    p.setBackground(Color.white);
    bottom.setBackground(Color.white);

    p.add(l);
    getContentPane().add(p, BorderLayout.CENTER);
    getContentPane().add(bottom, BorderLayout.SOUTH);
    pack();
    Dimension labelSize = l.getPreferredSize();
    p.setPreferredSize(new Dimension(labelSize.width + 50, labelSize.height + 20));
    p.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
    bottom.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
    Dimension panelSize = p.getPreferredSize();
    bottom.setPreferredSize(new Dimension(panelSize.width, image.getHeight(null) + 2));

    setLocationRelativeTo(null);

    // g.drawImage(new ImageIcon("bugSplash3.png"),0 ,0 ,null);

    pack();
    viewer.animate();

}
 
Example 6
Source File: UiUtil.java    From Java with Artistic License 2.0 5 votes vote down vote up
/**
 * 修改窗体图标
 * @param jf 
 */
public static void setFrameIcon(JFrame jf,String imagePath){
    //获取工具类
    Toolkit took = Toolkit.getDefaultToolkit();
    //根据路径获取图片
    Image image = took.getImage(imagePath);
    //设置图标
    jf.setIconImage(image);
}
 
Example 7
Source File: UiUtil.java    From Java with Artistic License 2.0 5 votes vote down vote up
/**
 * 修改窗体图标
 * @param jf 
 */
public static void setFrameIcon(JFrame jf,String imagePath){
    //获取工具类
    Toolkit took = Toolkit.getDefaultToolkit();
    //根据路径获取图片
    Image image = took.getImage(imagePath);
    //设置图标
    jf.setIconImage(image);
}
 
Example 8
Source File: UiUtil.java    From Java with Artistic License 2.0 5 votes vote down vote up
/**
 * 修改窗体图标
 * @param jf 
 */
public static void setFrameIcon(JFrame jf,String imagePath){
    //获取工具类
    Toolkit took = Toolkit.getDefaultToolkit();
    //根据路径获取图片
    Image image = took.getImage(imagePath);
    //设置图标
    jf.setIconImage(image);
}
 
Example 9
Source File: MechPanelTabStrip.java    From megamek with GNU General Public License v2.0 4 votes vote down vote up
private void setImages() {
    UnitDisplaySkinSpecification udSpec = SkinXMLHandler
            .getUnitDisplaySkin();
    MediaTracker mt = new MediaTracker(this);
    Toolkit tk = getToolkit();
    idleImage[0] = tk.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getGeneralTabIdle()).toString());
    idleImage[1] = tk.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getPilotTabIdle()).toString());
    idleImage[2] = tk.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getArmorTabIdle()).toString());
    idleImage[3] = tk.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getSystemsTabIdle()).toString());
    idleImage[4] = tk.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getWeaponsTabIdle()).toString());
    idleImage[5] = tk.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getExtrasTabIdle()).toString());
    activeImage[0] = tk.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getGeneralTabActive()).toString());
    activeImage[1] = tk.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getPilotTabActive()).toString());
    activeImage[2] = tk.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getArmorTabActive()).toString());
    activeImage[3] = tk.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getSystemsTabActive()).toString());
    activeImage[4] = tk.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getWeaponsTabActive()).toString());
    activeImage[5] = tk.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getExtraTabActive()).toString());
    idleCorner = tk.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getCornerIdle()).toString());
    selectedCorner = tk.getImage(new MegaMekFile(Configuration.widgetsDir(), udSpec.getCornerActive()).toString());

    // If we don't flush, we might have stale data
    idleCorner.flush();
    selectedCorner.flush();

    for (int i = 0; i < 6; i++) {
        // If we don't flush, we might have stale data
        idleImage[i].flush();
        activeImage[i].flush();
        mt.addImage(idleImage[i], 0);
        mt.addImage(activeImage[i], 0);
    }
    mt.addImage(idleCorner, 0);
    mt.addImage(selectedCorner, 0);
    try {
        mt.waitForAll();
    } catch (InterruptedException e) {
        System.out.println("TabStrip: Error while image loading."); //$NON-NLS-1$
    }
    if (mt.isErrorID(0)) {
        System.out.println("TabStrip: Could Not load Image."); //$NON-NLS-1$
    }

    for (int i = 0; i < 6; i++) {
        if (idleImage[i].getWidth(null) != activeImage[i].getWidth(null)) {
            System.out.println("TabStrip Warning: idleImage and "
                    + "activeImage do not match widths for image " + i);
        }
        if (idleImage[i].getHeight(null) != activeImage[i].getHeight(null)) {
            System.out.println("TabStrip Warning: idleImage and "
                    + "activeImage do not match heights for image " + i);
        }
    }
    if (idleCorner.getWidth(null) != selectedCorner.getWidth(null)) {
        System.out.println("TabStrip Warning: idleCorner and "
                + "selectedCorner do not match widths!");
    }
    if (idleCorner.getHeight(null) != selectedCorner.getHeight(null)) {
        System.out.println("TabStrip Warning: idleCorner and "
                + "selectedCorner do not match heights!");
    }
}
 
Example 10
Source File: Event.java    From javagame with MIT License 4 votes vote down vote up
/**
 * �C���[�W�����[�h
 * 
 */
private void loadImage() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    mapchipImage = toolkit.getImage(getClass().getClassLoader().getResource("image/mapchip.png"));
}
 
Example 11
Source File: Map.java    From javagame with MIT License 4 votes vote down vote up
/**
 * �C���[�W�����[�h
 * 
 */
private void loadImage() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    mapchipImage = toolkit.getImage(getClass().getClassLoader().getResource("image/mapchip.png"));
}
 
Example 12
Source File: ToolkitImages.java    From jmg with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a set of stave images.
 */
public ToolkitImages() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();

    trebleClef = toolkit.getImage(
            Stave.class.getResource("graphics/trebleClef.gif"));
    bassClef = toolkit.getImage(
            Stave.class.getResource("graphics/bassClef.gif"));
    crotchetDown = toolkit.getImage(
            Stave.class.getResource("graphics/crotchetDown.gif"));
    crotchetUp = toolkit.getImage(
            Stave.class.getResource("graphics/crotchetUp.gif"));
    quaverDown = toolkit.getImage(
            Stave.class.getResource("graphics/quaverDown.gif"));
    quaverUp = toolkit.getImage(
            Stave.class.getResource("graphics/quaverUp.gif"));
    semiquaverDown = toolkit.getImage(
            Stave.class.getResource("graphics/semiquaverDown.gif"));
    semiquaverUp = toolkit.getImage(
            Stave.class.getResource("graphics/semiquaverUp.gif"));
    minimDown = toolkit.getImage(
            Stave.class.getResource("graphics/minimDown.gif"));
    minimUp = toolkit.getImage(
            Stave.class.getResource("graphics/minimUp.gif"));
    semibreve = toolkit.getImage(
            Stave.class.getResource("graphics/semibreve.gif"));
    dot = toolkit.getImage(
            Stave.class.getResource("graphics/dot.gif"));
    semiquaverRest = toolkit.getImage(
            Stave.class.getResource("graphics/semiquaverRest.gif"));
    quaverRest = toolkit.getImage(
            Stave.class.getResource("graphics/quaverRest.gif"));
    crotchetRest = toolkit.getImage(
            Stave.class.getResource("graphics/crotchetRest.gif"));
    minimRest = toolkit.getImage(
            Stave.class.getResource("graphics/minimRest.gif"));
    semibreveRest = toolkit.getImage(
            Stave.class.getResource("graphics/semibreveRest.gif"));
    sharp = toolkit.getImage(
            Stave.class.getResource("graphics/sharp.gif"));
    flat = toolkit.getImage(
            Stave.class.getResource("graphics/flat.gif"));
    natural = toolkit.getImage(
            Stave.class.getResource("graphics/natural.gif"));
    one = toolkit.getImage(
            Stave.class.getResource("graphics/one.gif"));
    two = toolkit.getImage(
            Stave.class.getResource("graphics/two.gif"));
    three = toolkit.getImage(
            Stave.class.getResource("graphics/three.gif"));
    four = toolkit.getImage(
            Stave.class.getResource("graphics/four.gif"));
    five = toolkit.getImage(
            Stave.class.getResource("graphics/five.gif"));
    six = toolkit.getImage(
            Stave.class.getResource("graphics/six.gif"));
    seven = toolkit.getImage(
            Stave.class.getResource("graphics/seven.gif"));
    eight = toolkit.getImage(
            Stave.class.getResource("graphics/eight.gif"));
    nine = toolkit.getImage(
            Stave.class.getResource("graphics/nine.gif"));
    delete = toolkit.getImage(
            Stave.class.getResource("graphics/delete.gif"));
    tieOver = toolkit.getImage(
            Stave.class.getResource("graphics/tieOver.gif"));
    tieUnder = toolkit.getImage(
            Stave.class.getResource("graphics/tieUnder.gif"));
}