Package java.awt

Examples of java.awt.Canvas


                && Math.abs((fromLoc.z) - (toLoc.z)) <= 150) {
            //Cover Screen not needed
        } else {
            //attach cover screen
            final MainFrame mainFrame = JmeClientMain.getFrame();
            final Canvas canvas = mainFrame.getCanvas();
            final CoverScreen coverScreenPanel = new CoverScreen(csd, canvas.getSize());

            try {

                //show cover screen in JDialog over the canvas panel
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        dialog = new JDialog(mainFrame.getFrame(), "Child", false);

                        coverScreenPanel.setPreferredSize(canvas.getSize());
                        dialog.setSize(canvas.getSize().width, canvas.getSize().height);
                        dialog.setLocation(canvas.getLocationOnScreen().x, canvas.getLocationOnScreen().y);

                        mainFrame.getFrame().addComponentListener(new ComponentAdapter() {
                            private void doChange() {
                                SwingUtilities.invokeLater(new Runnable() {
                                    public void run() {
                                        if (dialog != null && dialog.isVisible()) {
                                            Component cs = dialog.getComponent(0);
                                            Canvas canvas = mainFrame.getCanvas();
                                            cs.setPreferredSize(canvas.getSize());
                                            dialog.setSize(canvas.getSize().width, canvas.getSize().height);
                                            dialog.setLocation(canvas.getLocationOnScreen().x, canvas.getLocationOnScreen().y);
                                            dialog.pack();
                                            dialog.setVisible(true);
                                        }
                                    }
                                });
View Full Code Here


    public BasicSplitPaneDivider getDivider() {
        return divider;
    }

    protected Component createDefaultNonContinuousLayoutDivider() {
        return new Canvas() {
            // Note: this is not a guaratee for correct serialization/deserialization
            // but rather a performace optimization
            private static final long serialVersionUID = 1L;

            @Override
View Full Code Here

    public TemplateImageLoaderInstaller templateImageLoaderInstaller(final String requested) {
        try {
            if(requested == null) {
                // fail early if the default (which uses AWT) cannot be used.
                // this is a workaround to force the fallback of Noop; ie for Google App Engine.
                @SuppressWarnings("unused")
                Canvas canvas = new java.awt.Canvas();
            }
            return templateImageLoaderInstaller(requested, SystemConstants.IMAGE_LOADER_DEFAULT);
        } catch (NoClassDefFoundError e) {
            // to support running on Google App Engine
View Full Code Here

            URL imageurl;
            imageurl = this.getClass().getResource(
                "/gnu/classpath/examples/icons/big-warning.png");
            img = Toolkit.getDefaultToolkit().createImage(imageurl);

            final Canvas ch = new Canvas() {
                public void paint(Graphics g) {
                    g.drawImage(img, xs + 25, ys + 25, this);

                    Font font = new Font("Serif", Font.PLAIN, 18);
                    g.setFont(font);
                    g.setXORMode(Color.red);

                    g.drawString("Hi Red!", xs + 15, ys + 10);
                    g.setColor(Color.blue);
                    g.drawLine(xs, ys, xs + 100, ys + 100);

                }
            };
            ch.setSize(150, 150);
            add(ch, "Center");

            final ScrollPane sp = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
            final Panel p = new Panel();
            p.add(new Button("Stop"));
            p.add(new Button("evil"));
            p.add(new Button("hoarders"));
            p.add(new Button("use"));
            p.add(new Button("GNU!"));

            sp.add(p);
            add(sp, "South");

            Panel east_panel = new Panel();
            east_panel.setLayout(new GridLayout(0, 1));

            CheckboxGroup group = new CheckboxGroup();
            Checkbox cb = new Checkbox("one", group, true);
            east_panel.add(cb);
            cb = new Checkbox("two", group, false);
            east_panel.add(cb);

            add(east_panel, "East");

            final Button wb = new Button();
            wb.setLabel("Hello World!");
            wb.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    l.setText("Hello World!");

                    final Dialog d = new Dialog(parent);
                    d.setLayout(new FlowLayout());
                    d.setModal(true);
                    Button b = new Button("foobar");
                    b.addMouseListener(new MouseAdapter() {
                        public void mousePressed(MouseEvent me) {
                            d.setVisible(false);
                        }
                    });
                    d.add(b);

                    List ch = new List();
                    ch.add("Ding");
                    ch.add("September");
                    ch.add("Red");
                    ch.add("Quassia");
                    ch.add("Pterodactyl");
                    d.add(ch);

                    d.pack();
                    d.setVisible(true);
                }
            });

            wb.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent e) {
                    xs++;
                    ys++;
                    ch.repaint();
                }
            });

            add(wb, "West");
View Full Code Here

            cursorChoice.addItemListener(this);

            add(cursorChoice, "North");

            cursorCanvas = new Canvas() {
                public void paint(Graphics g) {
                    Dimension d = this.getSize();
                    g.setColor(Color.white);
                    g.fillRect(0, 0, d.width, d.height / 2);
                    g.setColor(Color.black);
View Full Code Here

   */
  public void test(TestHarness harness)
  {
    setBackground(Color.red);
    Frame f = new Frame();
    Canvas c = new Canvas();
    c.setBackground(Color.blue);
    c.setSize(100,100);
    add(c);
    f.add(this);
    f.pack();
    f.show();
    Point loc = f.getLocationOnScreen();
    Rectangle bounds = c.getBounds();
    Insets i = f.getInsets();
    bounds.x += i.left + loc.x;
    bounds.y += i.top + loc.y;
   
    Robot r = harness.createRobot();
View Full Code Here

            WorldWindow ww = this.getWorldWindow();
            if (ww != null)
            {
                WorldWindowGLCanvas wwgl = (WorldWindowGLCanvas) ww;
                GLCanvas glc = wwgl;
                Canvas cv = glc;
                Component c = cv;
                hwnd = zebraGetWin32Handle(c);
            }
        }
View Full Code Here

     * @return the image
     */   
    public java.awt.Image createAwtImage(Color foreground, Color background) {
        int f = foreground.getRGB();
        int g = background.getRGB();
        Canvas canvas = new Canvas();

        String fullCode = code;
        if (generateChecksum && checksumText)
            fullCode = calculateChecksum(code);
        if (!startStopText)
            fullCode = fullCode.substring(1, fullCode.length() - 1);
        byte bars[] = getBarsCodabar(generateChecksum ? calculateChecksum(code) : code);
        int wide = 0;
        for (int k = 0; k < bars.length; ++k) {
            wide += bars[k];
        }
        int narrow = bars.length - wide;
        int fullWidth = narrow + wide * (int)n;
        boolean print = true;
        int ptr = 0;
        int height = (int)barHeight;
        int pix[] = new int[fullWidth * height];
        for (int k = 0; k < bars.length; ++k) {
            int w = (bars[k] == 0 ? 1 : (int)n);
            int c = g;
            if (print)
                c = f;
            print = !print;
            for (int j = 0; j < w; ++j)
                pix[ptr++] = c;
        }
        for (int k = fullWidth; k < pix.length; k += fullWidth) {
            System.arraycopy(pix, 0, pix, k, fullWidth);
        }
        Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth));
       
        return img;
    }
View Full Code Here

     * @return the image
     */   
    public java.awt.Image createAwtImage(Color foreground, Color background) {
        int f = foreground.getRGB();
        int g = background.getRGB();
        Canvas canvas = new Canvas();

        String bCode = code;
        if (extended)
            bCode = getCode39Ex(code);
        if (generateChecksum)
            bCode += getChecksum(bCode);
        int len = bCode.length() + 2;
        int nn = (int)n;
        int fullWidth = len * (6 + 3 * nn) + (len - 1);
        byte bars[] = getBarsCode39(bCode);
        boolean print = true;
        int ptr = 0;
        int height = (int)barHeight;
        int pix[] = new int[fullWidth * height];
        for (int k = 0; k < bars.length; ++k) {
            int w = (bars[k] == 0 ? 1 : nn);
            int c = g;
            if (print)
                c = f;
            print = !print;
            for (int j = 0; j < w; ++j)
                pix[ptr++] = c;
        }
        for (int k = fullWidth; k < pix.length; k += fullWidth) {
            System.arraycopy(pix, 0, pix, k, fullWidth);
        }
        Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth));
       
        return img;
    }   
View Full Code Here

     * @return the image
     */   
    public java.awt.Image createAwtImage(Color foreground, Color background) {
        int f = foreground.getRGB();
        int g = background.getRGB();
        Canvas canvas = new Canvas();
        String bCode;
        if (codeType == CODE128_RAW) {
            int idx = code.indexOf('\uffff');
            if (idx >= 0)
                bCode = code.substring(0, idx);
            else
                bCode = code;
        }
        else {
            bCode = getRawText(code, codeType == CODE128_UCC);
        }
        int len = bCode.length();
        int fullWidth = (len + 2) * 11 + 2;
        byte bars[] = getBarsCode128Raw(bCode);
       
        boolean print = true;
        int ptr = 0;
        int height = (int)barHeight;
        int pix[] = new int[fullWidth * height];
        for (int k = 0; k < bars.length; ++k) {
            int w = bars[k];
            int c = g;
            if (print)
                c = f;
            print = !print;
            for (int j = 0; j < w; ++j)
                pix[ptr++] = c;
        }
        for (int k = fullWidth; k < pix.length; k += fullWidth) {
            System.arraycopy(pix, 0, pix, k, fullWidth);
        }
        Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth));
       
        return img;
    }
View Full Code Here

TOP

Related Classes of java.awt.Canvas

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.