Repaint(Rectangle ) problem

Hi, anyone knows any problems calling repaint with a Rectangle parameter when the component doesn't fit in the window ( both width and height ).
I'm trying to repaint an area delimited by a Rectangle, but when its bounds are outside of the window, width and height it doesnt repaint the area. Any idea ? thanks

If you want to eliminate 'Flicker' in Java you have to override the update(Graphics g) method found in the java.awt.Container class.
A call to repaint() calls update(Graphics g) first which by default clears the painting surface by painting with the background color (this causes flicker on a large area) after this there is a call to paint(Graphics g).
There are two ways to proceed. Use 'clipping' if the area that is changing is quite small e.g. numbers on a digital clock or use 'double buffering' if the area is larger e.g. large animation.

Similar Messages

  • [VB][CS5] Hyperlink on Rectangle problem - urgent

    Hi there,
    I got the a problem with VB and CS5. I try to do something like that:
    Dim mInDesign As InDesign.Application
    Dim mPub As InDesign.Document
    Dim mHyperlink As InDesign.Hyperlink
    Set mInDesign = GetObject("", "InDesign.Application.CS5")
    Set mPub = mInDesign.Documents.Item(1)
    Dim mRectangle as InDesign.Rectangle
    'REM - rectangleID is a Long parameter for this function and is a valid rectangle ID
    Set mRectangle=mPub.Rectangles.ItemById(rectangleID)
    Dim mHysperSource As InDesign.HyperlinkPageItemSource
    Set mHysperSource = mPub.HyperlinkPageItemSources.Add(mRectangle)
    Well, the bold underlined line of code creates error 13 - type mismatch!
    No mather what I am trying to use mRectangle.AllPageItems.Item(1), mRectangle.PageItems.Item(1), mRectangle.AllGraphics.Item(1) - still no success
    Watching the variable shows mRectangle as Variant/Object/Rectange and mRectangle.AllGraphics.Item(1) as Variant/Object/Image
    The Image is a JPEG Image....
    Any suggestions how to get Hyperlinks working with Rectnagle? (I cannot use TextFrame with InsertionPoint... it is Rectangle and I cannot change it)
    Regards
    Jarema

    I'm no VB expert, but what happens when you change:
    Set mRectangle=mPub.Rectangles.ItemById(rectangleID)
    to:
    Set mRectangle=mPub.PageItems.ItemById(rectangleID)
    Harbs

  • Point in Polygon/Rectangle problem.

    Hi,
    I'm want to find out, what points in my DB are inside an user-defined area.
    If I have a rectangle and treat it like a rectangle in the query:
    SELECT * FROM TABLE WHERE
    sdo_relate(point, mdsys.sdo_geometry(2003,8307,null,
    mdsys.sdo_elem_info_array(1,1003,3),
    mdsys.sdo_ordinate_array(-30,-30, 30,30)),
    'mask=INSIDE querytype=window layer_gtype=point') = 'TRUE'
    ...everything is ok.
    If I take the same geometry and use it as an polygon in the query:
    SELECT * FROM TABLE WHERE
    sdo_relate(point, mdsys.sdo_geometry(2003,8307,null,
    mdsys.sdo_elem_info_array(1,1003,1),
    mdsys.sdo_ordinate_array(-30,-30, 30,-30, 30,30, -30,30, -30,-30 )),
    'mask=INSIDE querytype=window layer_gtype=point') = 'TRUE'
    ...the result is wrong, there are lots of points that are definitely outside the area. The number of errors is rising the bigger the choosen area becomes.
    Any idea?
    Best regards
    Florian

    wateenmooiedag,
    this seems to work. Thanks.
    But: if I make the query window very large, than again I have wrong results.
    Here: http://gdsg.ngdc.noaa.gov/spatial_cookbook.html I found the sentence:
    Also, this query will not return the correct number of records if the selection area > one-half the surface of the earth
    This is exactly what I'm experienced.
    Now I ask myself: how should I use Oracle Spatial if it's not possible to aks for points that are inside a certain polygon (even if the polygon is more than half the world) ??
    siva,
    I understand what you mean.
    But in my case, the problem is not that I get little differences between the rectangle and the polygon. If I use the polygon, I get completely wrong results.
    For example: my query window is mdsys.sdo_ordinate_array(-100,-80, 100,-80, 100,80, -100,80, -100,-80 ), than I only get results that are outside the longitude area (-180 to -100 and 100 to 180).
    For me this seems to be a bug.
    Best regards,
    Florian

  • Stroke of Rectangle Problem

    Hello
    My Problem is :
    When i draw a rectangle and gave it a stroke of 2 points.
    When i reduce the size of rectangle then the stroke (or outline) increase its width.
    Waiting for the answer. i need to solve this issue.
    Thanx In advance

    The stroke is not scaling with the object, i.e. it remains at 2 points. You can change this behaviour by going to Edit>Preferences>General>Scale strokes & Effects. That way the stroke will scale with everything else.

  • A basic repaint efficiency problem

    When the repaint() method of a swing component is called by some thread, but the whole swing application window is full covered by other windows, then, will the paintComponent(Graphics g) method of the component actually be called?
    And why? Who takes care of this?

    The paint() method is called.
    Inside JComponent.paint(), the clip rectangle (the rectangle that covers all that needs to be repainted) is compared to the bounds of the component. If the bounds are such that some of the component is within the repaint area, then the component's paintComponent() method is called.
    The paintChildren() is called, and each child which is within the clip rectangle is painted (with some extra work so that painting all of something deep in the Z-stack doesn't overpaint something higher-up outside the clip area).
    JComponent has the responsibility of deciding which of its children to paint.
    The OS's window manager has the responsibility of providing the bounds of the area that needs to be repainted.
    Whether or not the repaint method is called when a window is obscured is OS dependent- on OS X, the image of any inactive window is cached, so the paint method of window 'A' won't get called if you drag window 'B' over the top of 'A', minimise and restore 'A', or move 'A' around without resizing (unless you add in extra window event handlers for those cases). On Windows NT, repaints will occur for most of these events, as it has a much less advanced windowing system.
    Pete

  • IMAQ Overlay Rectangle problem

    Hello,
    I am trying to Overlay Roteted rectangle and fill it inside.
    I can't do it by IMAQ Overlay Rectangle - it doesn't accept rotations
    So I onvert Restangle to ROI and I use IMAQ Overlay ROI but now I dont have fill option
    Do You know  way around this??
    Solved!
    Go to Solution.

    Dear Pawhan!
    As far as i'm aware, you can have Rotated Rectangle overlays in Vision Assistant, so you can set one up in VA and create a LabVIEW VI from there. If you want to stick with LV Vision, try this code:
    Please tell me if this works for you.
    Best regards:
    Andrew Valko
    NI Hungary
    Andrew Valko
    National Instruments Hungary
    Attachments:
    Rotated Rectangle.vi ‏20 KB

  • Rectangle problems can't see cel height

    Can anyone help me?
    I use the celheight to measure a height of a text?
    For some reason it dissapeared. I'll include a photo for what i mean i lost.

    Found it, it's was set in dutch so had to translate everything.

  • Paint()/repaint() problem w/applet

    Hi all. Here's my dilemma: I'm trying to create an applet that asks for simple multiplication answers, and draws a string giving feedback after the question is answered ("Very good!" or "No, try again."). The problem is that the book says to draw everything from paint(), and gives the impression that repaint() should magically refresh everything on the applet, which it does not. How can I make the strings I drew in paint() go away and give way to new strings based on user answer (whether correct or not), instead of piling up on top of each other, because they don't refresh? Also, my JButton and JTextField aren't showing up until the mouse is scrolled over them. Thanks for your time!
    code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class Week5Class extends JApplet implements ActionListener
        static int int1 = (int)(Math.random()*10);
        static int int2 = (int)(Math.random()*10);
        JTextField answer = new JTextField(3);
        JButton verifyAnswer = new JButton("Click to see if correct");
        public void init()
            Container myContainer = getContentPane();
            myContainer.add(answer);
            myContainer.add(verifyAnswer);
            verifyAnswer.addActionListener(this);
            myContainer.setLayout(new FlowLayout());
        static int j = 0;
        static int i;
        public void paint(Graphics gr)
              gr.drawString("How much is " + int1 + " * " + int2 + "?", 10, 70);
              if(i == 1)
                  gr.drawString("VeryGood!", 300, 200);
              else if(i == 0 && j != 0)
                  gr.drawString("No. Please try again.", 300, 200);
              j++;
        public void actionPerformed(ActionEvent e)
            int x = 300;
            int y = 200;
            if(Integer.parseInt(answer.getText()) == (int1*int2))
                int1 = (int)(Math.random()*10);
                int2 = (int)(Math.random()*10);
                i = 1;
                repaint();
            else
                i = 0;
                repaint();
    }

    The problem is that you're mixing doing your own drawing and using child objects. The paint method you've overriden would be the one that draws the text field and button.
    A far easier approach would be to use a JLabel to display your response message, and insert that as another component into the container, as you've inserted the button and input field.
    Then use setText() on the label to change the message.
    If you really want to have an area that you draw arbitary shapes on it's best to create your own child component, add it to the container, and override it's paintComponent method. Alternatively create a class which implments the Icon interface and put it in a JLabel.
    FlowLayout isn't very clever, by the way, try a BorderLayout or maybe a BoxLayout.

  • Java rotate, drag RoundRectangle2D problem please help me!!!

    Hi,
    i have 2 program, the first program can rotate a RoundRectangle2D, and the secend program can create new RoundRectangle2D and drag them around.
    The problem is that i want the rotate and the drag functions in one file, could any wone plese help me with this??
    The code has been orginally written by phillips75. i have modified it.
    The first program that rotates a Rectangle2D
    package appli;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.event.MouseInputAdapter;
    public class minappli extends JApplet
    Vector shape = new Vector();
    class axel extends JPanel
    axel selectedRect;
    //RoundRectangle2D r;
    RectangularShape r;
    RectangularShape rsss;
    AffineTransform xform;
    int theta;
    public axel()
    shape.addElement(new axel(40, 50, 50, 60));
    shape.addElement(new axel(150, 100, 50, 60));
    shape.addElement(new axel(40, 150, 50, 60));
    setBackground(Color.white);
    addMouseListener(new RectSelector(this));
    public axel (int x, int y, int w, int h)
    r = new RoundRectangle2D.Double(x, y, w, h, 20, 20);
    xform = new AffineTransform();
    theta = 0;
    public void drawdd (Graphics2D g2)
    AffineTransform orig = g2.getTransform();
    if (!xform.isIdentity())
    g2.setTransform(xform);
    g2.draw(r);
    g2.setTransform(orig);
    public void rotateRect()
    double cx = r.getCenterX();
    double cy = r.getCenterY();
    theta = theta + 5;
    xform.setToRotation(Math.toRadians(theta), cx, cy);
    public void paintComponent(Graphics g)
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
    RenderingHints.VALUE_ANTIALIAS_ON);
    //int w = getWidth();
    //int h = getHeight();
    axel rs;
    for(int i = 0; i < shape.size(); i++)
    rs = (axel) shape.get(i);
    // System.out.println(" rs " + rs + " rsss " + konam);
    if (rs == selectedRect)
    g2.setPaint(Color.yellow);
    else
    g2.setPaint(Color.black);
    rs.drawdd(g2);
    class RectSelector extends MouseInputAdapter
    axel rotationPanel;
    RectangularShape selectedShape;
    axel rs;
    Point start, offset;
    boolean addCircle, addSquare, dragging;
    final int size = 50;
    public RectSelector(axel fp)
    rotationPanel = fp;
    offset = new Point();
    addCircle = false;
    addSquare = false;
    dragging = false;
    public void mousePressed(MouseEvent e)
    RectangularShape rssss = null;
    Point p = e.getPoint();
    rssss = new RoundRectangle2D.Double(p.x - size / 2, p.y - size / 2, size, size, 20, 20);
    for (int i = 0; i < shape.size(); i++)
    rs = (axel) shape.get(i);
    //System.out.println("rs" + rs);
    if (rs.r.contains(p))
    selectedRect = rs;
    repaint();
    break;
    public void mouseReleased(MouseEvent e)
    selectedShape = null;
    dragging = false;
    public void mouseDragged(MouseEvent e)
    if (dragging)
    Point p = e.getPoint();
    if (selectedShape != null)
    // dragging a shape
    Rectangle r = selectedShape.getBounds();
    r.x = p.x - offset.x;
    r.y = p.y - offset.y;
    selectedShape.setFrame(r);
    rotationPanel.repaint();
    public JPanel getUIpanelg()
    final JButton rotateButton = new JButton("Rotate");
    final JButton box = new JButton("Box");
    rotateButton.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    if (e.getSource() == rotateButton)
    selectedRect.rotateRect();
    repaint();
    JPanel panel = new JPanel();
    panel.add(rotateButton);
    panel.add(box);
    return panel;
    public void init()
    axel rp = new axel();
    Container cp = getContentPane();
    cp.setLayout(new BorderLayout());
    cp.add(rp.getUIpanelg(), "South");
    cp.add(rp);
    public static void main(String[] args)
    JApplet applet = new minappli();
    JFrame f = new JFrame("Test");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(applet);
    f.setSize(400,300);
    f.setLocation(200,200);
    applet.init();
    f.setVisible(true);
    The second program that creates new Rectangle2D and drags it around
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.event.*;
    public class axel extends JApplet
    Vector shape = new Vector();
    int theta;
    RoundRectangle2D r;
    AffineTransform xform;
    class axel1 extends JPanel
    axel1 selectedRect;
    RectSelector action;
    public axel1()
    //shape.addElement(new axel1(40, 50, 50, 60));
    //shapeList.addElement(new FlowPanel(150, 100, 50, 60));
    //shapeList.addElement(new FlowPanel(40, 150, 50, 60));
    setBackground(Color.white);
    action = new RectSelector(this);
    addMouseListener(action);
    addMouseMotionListener(action);
    public void drawdd (Graphics2D g2)
    AffineTransform orig = g2.getTransform();
    if (!xform.isIdentity())
    g2.setTransform(xform);
    g2.draw(r);
    g2.setTransform(orig);
    public axel1 (int x, int y, int w, int h)
    r = new RoundRectangle2D.Double(x, y, w, h, 20, 20);
    xform = new AffineTransform();
    theta = 0;
    public void rotateRect()
    double cx = r.getCenterX();
    double cy = r.getCenterY();
    System.out.println("fffffffffffff");
    theta = theta + 5;
    xform.setToRotation(Math.toRadians(theta), cx, cy);
    public void paintComponent(Graphics g)
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
    RenderingHints.VALUE_ANTIALIAS_ON);
    RoundRectangle2D rs;
    for (int i = 0; i < shape.size(); i++)
    //rs = (RectangularShape) shape.get(i);
    g2.draw((RectangularShape) shape.get(i));
    //rs = (axel1) shape.get(i);
    //System.out.println("skapar " + i + "hahaaha " + rs);
    //if (rs == selectedRect)
    // g2.setPaint(Color.red);
    //else
    // g2.setPaint(Color.black);
    public void clear()
    shape.clear();
    repaint();
    class RectSelector extends MouseInputAdapter
    axel1 rotationPanel;
    RectangularShape selectedShape;
    final int size = 50;
    Point start, offset;
    boolean addCircle, addSquare, dragging;
    axel1 rs;
    public RectSelector(axel1 fp)
    // lista = (Vector) flowPanel.getShapeList();
    shape.addElement(new RoundRectangle2D.Double(40, 50, 50, 60, 20, 20));
    rotationPanel = fp;
    offset = new Point();
    addCircle = false;
    addSquare = false;
    dragging = false;
    public void mousePressed(MouseEvent e)
    RectangularShape rssss = null;
    Point p = e.getPoint();
    if (addCircle)
    rssss = new Ellipse2D.Double(p.x - size / 2, p.y - size / 2, size, size);
    if (addSquare)
    rssss = new RoundRectangle2D.Double(p.x - size / 2, p.y - size / 2, size, size, 20, 20);
    if (rssss != null)
    shape.addElement(rssss);
    rotationPanel.repaint();
    addCircle = addSquare = false;
    return;
    // or are we selecting an existing shape to drag
    for (int i = 0; i < shape.size(); i++)
    rssss = (RectangularShape) shape.get(i);
    if (rssss.contains(p))
    System.out.println("nu " + i + " " + rssss);
    selectedShape = rssss;
    Rectangle r = rssss.getBounds();
    offset.x = p.x - r.x;
    offset.y = p.y - r.y;
    dragging = true;
    break;
    public void mouseReleased(MouseEvent e)
    selectedShape = null;
    dragging = false;
    public void mouseDragged(MouseEvent e)
    if (dragging)
    Point p = e.getPoint();
    if (selectedShape != null)
    // dragging a shape
    Rectangle r = selectedShape.getBounds();
    r.x = p.x - offset.x;
    r.y = p.y - offset.y;
    selectedShape.setFrame(r);
    rotationPanel.repaint();
    public JToolBar getToolBar()
    JToolBar toolBar = new JToolBar();
    ActionListener l = new ActionListener()
    public void actionPerformed(ActionEvent e)
    JButton button = (JButton) e.getSource();
    String ac = button.getActionCommand();
    if (ac.equals("Single arrow"))
    addCircle = true;
    if (ac.equals("Box"))
    addSquare = true;
    if (ac.equals("Clear"))
    rotationPanel.clear();
    if (ac.equals("Rotate"))
    //double cx = r.getCenterX();
    //double cy = r.getCenterY();
    System.out.println("fffffffffffff");
    //theta = theta + 5;
    //xform.setToRotation(Math.toRadians(theta), cx, cy);
    // repaint();
    JButton button = makeButton("Single arrow", "Add a arrow", l);
    toolBar.add(button);
    button = makeButton("Box", "Add a box", l);
    toolBar.add(button);
    button = makeButton("Clear", "Clears everything", l);
    toolBar.add(button);
    button = makeButton("Rotate", "Rotate a shape", l);
    toolBar.add(button);
    return toolBar;
    private JButton makeButton(String actionCommand, String toolTipText, ActionListener l)
    JButton button = new JButton(actionCommand);
    button.setActionCommand(actionCommand);
    button.setToolTipText(toolTipText);
    button.addActionListener(l);
    return button;
    public void init()
    axel1 flowPanel = new axel1();
    RectSelector action = flowPanel.action;
    Container cp = getContentPane();
    cp.setLayout(new BorderLayout());
    cp.add(action.getToolBar(), "South");
    cp.add(flowPanel);
    public static void main(String[] args)
    JApplet applet = new axel();
    JFrame f = new JFrame("test");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(applet);
    f.setSize(500, 400);
    f.setLocation(200, 200);
    applet.init();
    f.setVisible(true);
    The

    New code:
    Class Arrow
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class GraphicArrow  extends JComponent
        GeneralPath arrow   =  new GeneralPath();
        Stroke dashStroke   =  new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 10f, new float[] {4f, 4f}, 0f);
        Paint gradientPaint =  new GradientPaint(-30, 0, Color.red, 10, 0, Color.yellow);
        GraphicArrow selectedArrow;
        public void paintComponent(Graphics _g)
            super.paintComponent(_g);
            Graphics2D g2 = (Graphics2D) _g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                               RenderingHints.VALUE_ANTIALIAS_ON);
            AffineTransform graphicsDefaultTransform = g2.getTransform();
            AffineTransform xform = new AffineTransform();
            Rectangle bounds = arrow.getBounds();
            Point startPoint = new Point();
            xform.translate(startPoint.x - bounds.x, startPoint.y - bounds.y);
            //g2.transform(xform);
            //g2.setStroke(dashStroke);
            //g2.draw(arrow);
             //g2.setTransform(graphicsDefaultTransform);
            //g2.transform(xform);
            //g2.setPaint(gradientPaint);
            //g2.fill(arrow);
            xform.translate(bounds.width + 20, 0);
            xform.translate(bounds.width + 20, 0);
            //g2.setTransform(graphicsDefaultTransform);
            g2.setPaint(gradientPaint);
            g2.transform(xform);
            g2.rotate(Math.PI / 1);
            g2.fill(arrow);
        public GraphicArrow (int x, int y)
            //Value before -20, -10
            arrow.moveTo(x, y);
            arrow.lineTo(0, -10);
            arrow.lineTo(0, -20);
            arrow.lineTo(20, 0);
            arrow.lineTo(0, 20);
            arrow.lineTo(0, 10);
            arrow.lineTo(-20, 10);
            arrow.lineTo(-20, -10);
            addMouseListener(new MouseAdapter()
                Rectangle hitRect = new Rectangle(0, 0, 5, 5);
                public void mouseClicked(MouseEvent e)
                    Graphics2D g = (Graphics2D) getGraphics();
                    AffineTransform xform = new AffineTransform();
                    hitRect.x = e.getX();
                    hitRect.y = e.getY();
                    Rectangle bounds = arrow.getBounds();
                    Point startPoint = new Point();
                    //System.out.println("hh " + (bounds.x  ) );
                    xform.setToTranslation(startPoint.x - bounds.x + 2 * bounds.width + 2 * 20, startPoint.y - bounds.y);
                    xform.rotate(Math.PI / 1);
                    g.setTransform(xform);
                    if (g.hit(hitRect, arrow, false))
                        System.out.println("Traff " + xform);
        public static void main(String args[])
            Frame frame = new Frame("Arrow");
            frame.add(new GraphicArrow(0, 0));
            frame.setBackground(Color.white);
            frame.setSize(new Dimension(400, 350));
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
    }The shape class:
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.event.MouseInputAdapter;
    import java.awt.*;
    public class Box extends JApplet
        Vector shape      = new Vector();
        Vector arrowArray = new Vector();
        int theta;
        class axel extends JPanel implements KeyListener
            GeneralPath arrow   = new GeneralPath();
            Stroke dashStroke   = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 10f, new float[] {10f, 10f}, 5f);
            Paint gradientPaint = new GradientPaint( -30, 0, Color.red, 10, 0, Color.yellow);
            boolean delete_box, addSquare, addArrow, dragging;
            axel selectedRect;
            RectangularShape boxen;
            AffineTransform xform;
            RectSelector action;
            String texten;
            public axel()
                shape.addElement(new axel("Text1", 40, 50, 50, 60));
                shape.addElement(new axel("Text2", 150, 100, 50, 60));
                shape.addElement(new axel("Text3", 40, 150, 50, 60));
                setBackground(Color.white);
                action = new RectSelector(this);
                addMouseListener(action);
                addMouseMotionListener(action);
                addKeyListener(this);
            public axel(String text, int x, int y, int w, int h)
                texten = text;
                boxen  = new RoundRectangle2D.Double(x, y, w, h, 20, 20);
                xform  = new AffineTransform();
                theta  = 5;
            public void rita(Graphics2D g2)
                double cx = boxen.getCenterX();
                double cy = boxen.getCenterY();
                int mus_x =(int) cx;
                int mus_y =(int) cy;
                AffineTransform orig = g2.getTransform();
                if (!xform.isIdentity())
                    g2.setTransform(xform);
                g2.fill(boxen);
                g2.setColor(Color.black);
                g2.setFont(new Font("Helvetica", Font.BOLD, 12));
                g2.drawString(texten, mus_x + -11, mus_y + 5);
                g2.draw(boxen);
                g2.setTransform(orig);
            public void paintComponent(Graphics g)
               super.paintComponent(g);
               Graphics2D g2 = (Graphics2D) g;
               Image bild = getImage(getDocumentBase(), "images.jpg");
               g2.drawImage(bild, 0, 0, this);
               g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                   RenderingHints.VALUE_ANTIALIAS_ON);
               //Draw the Shapes
               for (int i = 0; i < shape.size(); i++)
                   axel rsh = (axel) shape.get(i);
                   if (rsh == selectedRect)
                       g2.setStroke(dashStroke);
                       g2.setPaint(Color.green);
                   else
                       g2.setStroke(new BasicStroke(0));
                       g2.setPaint(Color.yellow);
                   rsh.rita(g2);
               //Draw the Arrows
               for (int i = 0; i < arrowArray.size(); i++)
                   GraphicArrow selectedArrow;
                   GraphicArrow arrowen = (GraphicArrow) arrowArray.get(i);
                   arrowen.paintComponent(g);
            public void resizen()
                Rectangle r      = boxen.getBounds();
                double    width  = boxen.getWidth()+2;
                double    height = boxen.getHeight()+2;
                boxen.setFrame(r.x, r.y, width, height);
            public void rotateRect()
                double cx = boxen.getCenterX();
                double cy = boxen.getCenterY();
                theta = theta - 5;
                xform.setToRotation(Math.toRadians(theta), cx, cy);
            public void rotateRect_right()
                double cx = boxen.getCenterX();
                double cy = boxen.getCenterY();
                theta = theta + 5;
                xform.setToRotation(Math.toRadians(theta), cx, cy);
            public void keyPressed(KeyEvent e) {
                System.out.println("Test1");
                if (e.isShiftDown()) {
                    System.out.println("Test3");
                if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                    System.out.println("Test2");
            public void keyReleased(KeyEvent e) {
            public void keyTyped(KeyEvent e) {
            class RectSelector extends MouseInputAdapter {
                axel rotationPanel;
                RectangularShape selectedShape;
                axel rs;
                Point offset;
                final int size = 50;
                public RectSelector(axel fp)
                    rotationPanel  = fp;
                    offset         = new Point();
                    delete_box     = false;
                    addSquare      = false;
                    addArrow       = false;
                    dragging       = false;
                public void mousePressed(MouseEvent e) {
                    Point p = e.getPoint();
                    //New Box skapas
                    if (addSquare)
                      shape.addElement(new axel("text5", p.x, p.y, 50, 60));
                      rotationPanel.repaint();
                      addSquare = false;
                      return;
                    //New Arrow skapas
                    if (addArrow)
                      arrowArray.addElement(new GraphicArrow(p.x, p.y));
                      rotationPanel.repaint();
                      addArrow = false;
                      return;
                    for (int i = 0; i < shape.size(); i++)
                        rs = (axel) shape.get(i);
                        if (rs.boxen.contains(p))
                            if (delete_box) {
                                shape.removeElementAt(i);
                                delete_box = false;
                                repaint();
                            Rectangle r = rs.boxen.getBounds();
                            offset.x = p.x - r.x;
                            offset.y = p.y - r.y;
                            selectedRect = rs;
                            selectedShape = rs.boxen;
                            dragging = true;
                            repaint();
                        //else
                        //    System.out.println("press does not work " + delete_box + i + rs.boxen.contains(p));
                public void mouseReleased(MouseEvent e)
                    int x = e.getX();
                    int y = e.getY();
                    selectedShape = null;
                    dragging = false;
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR) );
                    //Graphics2D g3  = (Graphics2D) getGraphics();
                    //g3.setStroke(new BasicStroke(0));
                    //g3.setPaint(Color.yellow);
                public void mouseDragged(MouseEvent e)
                    if (dragging) {
                        Point p = e.getPoint();
                        if (selectedShape != null) {
                            setCursor(new Cursor(Cursor.MOVE_CURSOR) );
                            Rectangle r = selectedShape.getBounds();
                            System.out.println("dragging " + p + p.x + " " + p.y);
                            r.x = p.x - offset.x;
                            r.y = p.y - offset.y;
                            selectedShape.setFrame(r);
                            repaint();
                public void mouseMoved(MouseEvent e)
            public JPanel panelen()
                final JButton rotate_left  = new JButton("Rotate left");
                final JButton rotate_right = new JButton("Rotate right");
                final JButton arrow        = new JButton("New Arrow");
                final JButton box          = new JButton("New Box");
                final JButton delete       = new JButton("Delete");
                final JButton resize       = new JButton("Resize");
                rotate_left.setCursor(new Cursor(Cursor.HAND_CURSOR) );
                rotate_right.setCursor(new Cursor(Cursor.HAND_CURSOR) );
                arrow.setCursor(new Cursor(Cursor.HAND_CURSOR) );
                box.setCursor(new Cursor(Cursor.HAND_CURSOR) );
                delete.setCursor(new Cursor(Cursor.HAND_CURSOR) );
                resize.setCursor(new Cursor(Cursor.HAND_CURSOR) );
                rotate_left.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent e)
                      if (e.getSource() == rotate_left && selectedRect != null)
                         selectedRect.rotateRect();
                         repaint();
                rotate_right.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e)
                      if (e.getSource() == rotate_right && selectedRect != null)
                         selectedRect.rotateRect_right();
                         repaint();
                arrow.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent e)
                      addArrow = (e.getSource() == arrow);
                box.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent e)
                      addSquare = (e.getSource() == box && selectedRect != null);
                delete.addActionListener(new ActionListener()
                    public void actionPerformed(ActionEvent e)
                       delete_box = (e.getSource() == delete);
                resize.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent e)
                      if (e.getSource() == resize && selectedRect != null)
                         selectedRect.resizen();
                         repaint();
                JPanel panel = new JPanel();
                panel.setBackground( Color.orange );
                panel.add(rotate_left);
                panel.add(rotate_right);
                panel.add(arrow);
                panel.add(box);
                panel.add(delete);
                panel.add(resize);
                return panel;
        public void init() {
            axel rp = new axel();
            Container cp = getContentPane();
            cp.setLayout(new BorderLayout());
            cp.add(rp.panelen(), "South");
            cp.add(rp);
        public static void main(String[] args)
            JApplet applet = new Box();
            JFrame f = new JFrame("Test");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(applet);
            f.setSize(600, 400);
            f.setLocationRelativeTo(null);
            applet.init();
            f.setVisible(true);

  • ActionListener / JTextArea Update Problem

    I have a JFrame that implements ActionListener, and the actionPerformed method looks like so:
    public void actionPerformed(ActionEvent myEvent){
         if ("abc".equals(myEvent.getActionCommand()) {
              //new window is created, etc
         } else if ("def".equals(myEvent.getActionCommand()) {
              //new window is created, etc
         someJTextArea.setText(newText);
         repaint();
    }The problem is, the newText relies on the other windows for its content, but for some unknown reason setText() is called before the new windows are closed, and also before newText has been set. I have a feeling this has something to do with the new windows launching their own threads, but I'm lost on how to wait for those windows to close before setting the text.
    Thanks for any help.

    I don't think that it's an issue of new threads being produced, since Swing GUIs and all actionPerformed code gets called on one thread, the EDT.
    More importantly to me: what exactly are your "new window"s? JFrames? If so, they likely need to be modal JDialogs. This will stop execution of any further method calls in your actionPerformed method until the dialogs have been fully dealt with.

  • What caused this problem (see example photo)?

    I have discoved one shoting session whereby almost 50% of the shots have this solid rectangle as part of the raw file. Out of thousands of sessions and photo's, this folder is the only one with this problem.   These rectangles are all about the same size on each photo, but occur in different locations within the photo.  I don't think this is one just a corrupt file, but perhaps a error I unknowly made when looking at them when i used to use PhotoShop. (now using LR)  
    Does anybody have any idea's on how one would somehow make this kind of mistake?  j
    PS - I have never done anything in Photoshop real complicated.  Always just simple basic shapening or other small adjustments.

    Hal/Andrew:   Thanks for your replies.  Actually this was only one example of another 9 or 10 with this same problem in this folder.  The folder has about 10 good shots and 10 shots like this example.  This folder contains shots that were taken last year and the original compact flash that they were from was reused many times with 100's of shots since then with none corrupt in any way.   It was only this one folder that had this problem and only about half of these with this similar rectangle problem.  Of the twenty of so shots in this folder, the problem was completely random with one or two shots good and then next shot or next 5 or six shots were like this example, then then next shot was good and so on.

  • CreateImage(int, int) problem -- or..?

    I'm trying to get a program double buffered, and have followed the structure for doing so provided by Sun. However, the program does not work correctly.
    Problem #1: I have to "manually" refresh the JFrame (put it behind a window, then bring it back to the foreground), and everything seems to work correctly.
    Problem #2: When the program first starts, I get 2 NPE's.
    Note: Both of these problems usually occur. Rarely, the entire thing runs perfectly with no problems at all.
    Here is how the code is structured:
    Graphics offScreen;
    Image offScreenImage;
    public void paint(Graphics screen)
    update(screen);
    public void update(Graphics toPaint)
    if( offScreenImage == null )
    offScreenImage = createImage(640, 480);     
    offScreen = offScreenImage.getGraphics();
    setBackground(Color.gray);          
    board.draw(offScreen);
    toPaint.drawImage(offScreenImage, 0, 0, null);     
    } //end draw()
    Also, the draw(Graphics) method from the board instance is:
    public void draw(Graphics offScreen)
    offScreen.drawImage(testImage, 25, 25, null);
    What could be causing these problems? Is there anything special that needs to be done if I'm using separate object files to draw? The NPE's are always flagged at this line:
         board.draw(offScreen);
    Any suggestions would be GREATLY appreciated.

    problem #1: Try moving the initializing code from update to paint or make paint to call update. Paint is the method that is called first to paint the component, update is called to repaint it.
    problem #2: "board.draw(offScreen);" can cause a NPE if a) board is null or b) offScreen is null. Which one is it?
    Also, in swing you should override the paintComponent-method instead of paint. (And aren't swing components double buffered by default? I'm not sure about that...)

  • Update Jcombobox 's label in render

    hi ,everybody, i have a problem about combobox, any body can help me!
    thank you!
    I want to have a combobox with checkbox as item, I rewrite a render writen by ice, because the combobox has three state, when I click diferent checkbox in this combobox , the label of combobox will update rightly, but if I click one checkbox to change the checkbox state ,the label will no update , it seem that when I click one checkbox many times .the menthod
    getListCellRendererComponent(JList list, Object value, int index,
                        boolean isSelected, boolean cellHasFocus)
    will no update label
    my code :
    mainclass:
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Iterator;
    import java.util.Vector;
    import javax.swing.DefaultListCellRenderer;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JList;
    import javax.swing.JPanel;
    import javax.swing.plaf.basic.BasicComboBoxEditor;
    public class mainclass {
          public static void main(String[] args) {
                 final testbox myComboBox = new testbox();
                 myComboBox.addItem("SelectAll");
                 myComboBox.addItem("ClearAll");
                 myComboBox.addItem("GrayedAll");
                 for(int i = 0; i < 5; i++) {
                     myComboBox.addItem("Item " + i);
                 JFrame frame = new JFrame("My ComboBox");
                 frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                 frame.setSize(150, 60);
                 frame.setLocation(300, 300);
                 //frame.setJMenuBar( menubar );
                 JPanel panel=new JPanel();
                 panel.setLayout(new BorderLayout());
                 panel.add(myComboBox,BorderLayout.NORTH);        
                 frame.getContentPane().add(panel);
                 frame.setVisible(true);
                 final IconedCellRendererField renderer = IconedCellRendererField.getCheckBoxRendererInstance();
                 myComboBox.setRenderer(renderer);
                 myComboBox.addActionListener(new ActionListener()
                     public void actionPerformed(ActionEvent e)
                          if(myComboBox.getSelectedItem().toString().equals("SelectAll")){
                               renderer.selectAll(true);                         
                          if(myComboBox.getSelectedItem().toString().equals("ClearAll")){
                               renderer.clearAll(true);
                          if(myComboBox.getSelectedItem().toString().equals("GrayedAll")){
                               renderer.grayedAll(true);
    }renderer:
    import java.awt.*;
    import java.awt.event.*;
    //import java.io.*;
    //import java.net.*;
    import java.util.*;
    import javax.swing.*;
    //import javax.swing.event.*;
    import javax.swing.border.*;
    //import javax.swing.table.*;
    public class IconedCellRendererField extends DefaultListCellRenderer implements MouseListener {
         public Icon icon, selIcon;
         Icon[] icons = null;
         public boolean useIconBackground = true, useIndexSensitiveIcons = false,
                   useCheckBoxAsIcon = false, useLinkState = false;
         Dimension labelDim = null;
         public JLabel iconLabel;
         public JCheckBox box = null;
         public JPanel noback;
         public SelectionStateHandler selStateHandler = null;     
         private JList theList = null;
         public boolean[] selState = null, enableState = null;
         int offset = 5;
         Rectangle rect = null;
         int currentLinkRow = -1;
         boolean isOnRow = false, paintDivider = false;
         private Icon dividerImage = null;     
         private Color linkColor = Color.blue, hoverColor = Color.red, selectedLinkColor = Color.green;
         /* Initialises the renderer with one icon that is displayed without the
          * cell background.
         public IconedCellRendererField(Icon icon) {
              this(icon,false);
         /* Initialises the renderer with two icons that provide a switch capability
          * when a row is selected/deselected
         public IconedCellRendererField(Icon icon, Icon selIcon) {
              this.icon = icon;
              this.selIcon = selIcon;
              //addMouseListener(this);
         /* Initialises the renderer with two icons that provide a switch capability
          * when a row is selected/deselected. The boolean argument enables the icon
          * to either use the renderer background or appear transparent.
         public IconedCellRendererField(Icon icon, Icon selIcon, boolean useIconBackground) {
              this(icon, selIcon);
              setIconHasBackground(useIconBackground);
              createNoBackgroundPanel();
         /* Initialises the renderer with a single no siwthing icon. The boolean
          * argument enables the icon to either use the renderer background
          * or appear transparent.
         public IconedCellRendererField(Icon icon, boolean useIconBackground) {
              this(icon, icon, useIconBackground);
         /* Initialises the renderer to load two icons from the provided image locations.
          * This enables icon switching on selection.
         public IconedCellRendererField(String iconLoc, String selIconLoc) {
              icon = new ImageIcon(iconLoc);
              selIcon = new ImageIcon(selIconLoc);
              //addMouseListener(this);
         /* Initialises the renderer to load a single icon from the provided image location.
          * The icon can either have the renderer background or not based on the
          * boolean property.
         public IconedCellRendererField(String iconLoc, boolean iconBackground) {
              this(iconLoc, iconLoc, iconBackground);
         /* Initialises the renderer to load two icons from the provided image locations.
          * This enables icon switching on selection. The icon can either have the renderer
          * background or not based on the boolean property.
         public IconedCellRendererField(String iconLoc, String selIconLoc, boolean iconBackground) {
              this(iconLoc, selIconLoc);
              setIconHasBackground(iconBackground);
              createNoBackgroundPanel();
         /* Initialises the renderer to load a single icon from the provided image location.
         public IconedCellRendererField(String iconLoc) {
              this(iconLoc, true);
         /* Initialises the renderer with an array of image icons that are repeated for
          * each row in the list.
         public IconedCellRendererField(Icon[] icons, boolean useIconBackground) {
              this(icons[0], icons[0], useIconBackground);
         public void createNoBackgroundPanel() {
              iconLabel = new JLabel((Icon)null, JLabel.CENTER);
              if(labelDim != null) {      iconLabel.setPreferredSize(labelDim); }
              iconLabel.setBorder( new EmptyBorder(1,5,1,5) );
              noback = new JPanel( new BorderLayout() ) {
                  * Overridden for performance reasons.
                  * See the <a href="#override">Implementation Note</a>
                  * for more information.
                  //public void validate() {}
                 // public void invalidate() {}          
                  public void repaint() {}
                  //public void revalidate() {}
                  public void repaint(long tm, int x, int y, int width, int height) {}
                  public void repaint(Rectangle r) {}
                  protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
                        // Strings get interned...
                        if (propertyName == "text"
                                   || ((propertyName == "font" || propertyName == "foreground")
                                       && oldValue != newValue)) {
                            super.firePropertyChange(propertyName, oldValue, newValue);
                  public void firePropertyChange(String propertyName, byte oldValue, byte newValue) {}
                  public void firePropertyChange(String propertyName, char oldValue, char newValue) {}
                  public void firePropertyChange(String propertyName, short oldValue, short newValue) {}
                  public void firePropertyChange(String propertyName, int oldValue, int newValue) {}
                  public void firePropertyChange(String propertyName, long oldValue, long newValue) {}
                  public void firePropertyChange(String propertyName, float oldValue, float newValue) {}
                  public void firePropertyChange(String propertyName, double oldValue, double newValue) {}
                  public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {}
              if(useCheckBoxAsIcon()) {
                   box = new JCheckBox();
                   //box.addMouseListener(this);
                   box.setOpaque(false);
                   noback.add( box, BorderLayout.WEST );
                   //noback.addMouseListener(this);
                   rect = box.getBounds();
                   //list.addMouseListener(this);
              } else {
                   noback.add( iconLabel, BorderLayout.WEST );
              noback.add( this, BorderLayout.CENTER );
              noback.setBorder( new EmptyBorder(1,1,1,1) );
              noback.setOpaque(false);
         public Component getListCellRendererComponent(JList list, Object value, int index,
                        boolean isSelected, boolean cellHasFocus) {
              System.out.println(value+"+"+index+"+"+isSelected+"+"+cellHasFocus);
              if(theList == null || theList != list) {
                   theList = list;
                   if(useLinkState) {
                        attachLinkSimulationListener();
              setOpaque(true);
              setText( value == null ? "" : value.toString());
              if(useIndexSensitiveIcons) {
                   icon = getIcon(index);
              if(useIconBackground)
                   setIcon(icon);          
              setFont( list.getFont() );
              setToolTipText(value.toString() );
              if(list.isEnabled())
                   setEnabled( isEnabled(index) );
              else
                   setEnabled( list.isEnabled() );
              if(isSelected && isEnabled(index) ) {
                   setForeground( Color.black );
                   setBackground( new Color(223, 235, 245) );
                   if(useIndexSensitiveIcons) {
                        selIcon = getIcon(index);
                   if(useIconBackground)
                        setIcon(selIcon);
              } else {
                   setForeground(Color.black);
                   setBackground(Color.white);
                   setBorder(null);
              if(cellHasFocus) {
                   setBorder( new CompoundBorder( new LineBorder( new Color(150, 150, 220) ),
                                                      new EmptyBorder(2,2,2,2)  ) );
              } else {
                   setBorder( new EmptyBorder(2,2,2,2));
              if(useLinkState) {
                   if(currentLinkRow == index) {
                        setText("<html><u>" + value.toString()+"</u></html>" );     
                        setForeground( getHoverLinkColor() );               
                   } else {
                        setForeground( getLinkColor() );
                   if(isSelected) {
                        setForeground( getSelectedLinkColor() );
                   setBackground(Color.white);
                   setBorder( new EmptyBorder(1,1,1,1) );
              if( shdPaintDivider() ) {
                   Border border = null;
                   if(dividerImage != null) {
                        border = new MatteBorder(0,0,1,0, dividerImage);
                   } else {
                        border = new MatteBorder(0,0,1,0, getLinkColor() );
                   if(index < theList.getModel().getSize() - 1 ) {
                        setBorder( new CompoundBorder(getBorder(),border) );
                   } else {
                        setBorder( new EmptyBorder(1,1,1,1) );
              if(useIconBackground == false) {
                  if(isSelected)
                      iconLabel.setIcon(selIcon);
                  else
                      iconLabel.setIcon(icon);
                  if(useCheckBoxAsIcon()) {
                      if(selState == null) {
                          updateSelectionStateTrackers(list);
                      if(selStateHandler == null) {
                          list.addMouseListener( selStateHandler = new SelectionStateHandler(list) );
                      try {
                          box.setSelected( selState[index] );
                      } catch(Exception e) {}
                  if( shdPaintDivider() ) {              
                      //if(index < theList.getModel().getSize() - 1 ) {
                          noback.setBorder( getBorder() );
                          setBorder( new EmptyBorder(1,1,1,1) );
                      //} else {
                      //  noback.get
                  // this should cause a JComboBox to paint the Label instead of the
                  // check box + label combination
                  if(index == -1) {
                       Vector<Object> v=new Vector<Object>();
                       v=getSelectedObjects();
                        String val=generateString();
                       JLabel label=new JLabel(val);                    
                      if(iconLabel.getIcon() != null) {
                           label.setIcon( iconLabel.getIcon() );
                      System.out.println("label");
                      return label;
                  return noback;
              return this;
         public String generateString()
              String val = "";
              if(selState[0]==true&&selState[1]==false&&selState[2]==false){
                    for(int i = 3; i < theList.getModel().getSize(); i++) {
                           String curString=theList.getModel().getElementAt(i).toString();
                           if(val.length()==0){
                                  val=val+curString+"-1";
                           } else {                              
                                  val=val+"&"+curString+"-1";
               //clear all     
               if(selState[1]==true&&selState[0]==false&&selState[2]==false ){                                   
                      for(int i = 3; i < theList.getModel().getSize(); i++) {
                           String curString=theList.getModel().getElementAt(i).toString();
                           if(val.length()==0){
                                  val=val+curString+"-0";
                           } else {                              
                                  val=val+"&"+curString+"-0";
              //grayedall
               if(selState[2]==true&&selState[0]==false&&selState[1]==false ){                                   
                      val="";                      
               if(selState[0]==false&&selState[1]==false&&selState[2]==false ){
                    for(int i = 3; i < theList.getModel().getSize(); i++) {
                           String curString=theList.getModel().getElementAt(i).toString();
                           if(selState==true&&enableState[i]==false){
                             continue;
                        if(selState[i]==true&&enableState[i]==true){
                             if(val.length()==0){
                                       val=val+curString+"-1";
                             } else {                              
                                       val=val+"&"+curString+"-1";
                        if(selState[i]==false&&enableState[i]==true){
                             if(val.length()==0){
                                       val=val+curString+"-0";
                             } else {                              
                                       val=val+"&"+curString+"-0";
              return val;
         public void updateSelectionStateTrackers(JList list) {
              selState = new boolean[ list.getModel().getSize() ];
              enableState = new boolean[ list.getModel().getSize() ];
              for(int i = 0; i < selState.length; i++) {
                   selState[i] = false;
                   enableState[i] = true;
         public int[] getSelectedIndices() {
              if(!useCheckBoxAsIcon()) {
                   return new int[0];
              int length = 0;
              if(selState==null){
                   return null;
              for(int i = 0; i < selState.length; i++) {
                   if(selState[i]) {
                        length++;
              int[] indices = new int[length];
              for(int i = 0, n = 0; i < selState.length; i++) {
                   if(selState[i]) {
                        indices[n++] = i;
              //System.out.println("Selected Indices.length = " + indices.length);
              return indices;
         public Vector<Object> getSelectedObjects() {
              int[] indices = getSelectedIndices();
              Vector<Object> objects = new Vector<Object>();
              if(indices==null){
                   return null;
              for(int i = 0; i < indices.length; i++) {
                   objects.addElement( theList.getModel().getElementAt(indices[i]) );
              return objects;
         public void setIconHasBackground(boolean b) {
              useIconBackground = b;
         public Icon[] getIcons() {
              return icons;
         public Icon getIcon(int index) {
              if(icons != null && icons.length == 0) {
                   return icon;
              if(icons != null && index > icons.length) {
                   index = index - (icons.length - 1);
              return icons[index];
         public void setIcons(Icon[] icons) {
              if(icons != null) {
                   useIndexSensitiveIcons = true;
              this.icons = icons;
         public void setIcon(Icon icon, int index) {
              if(icons != null && icons.length > 0) {
                   icons[index] = icon;
         public void setIconLabelDimension(Dimension dim) {
              labelDim = dim;
         public static IconedCellRendererField getCheckBoxRendererInstance() {
              IconedCellRendererField cr = new IconedCellRendererField(new EmptyIcon());
                   cr.setUseCheckBoxAsIcon(true);
              return cr;
         public void setUseCheckBoxAsIcon(boolean use) {
              useCheckBoxAsIcon = use;
              createNoBackgroundPanel();
         public boolean useCheckBoxAsIcon() {
              return useCheckBoxAsIcon;
         public void paintComponent(Graphics g) {
              super.paintComponent(g);
         public void setDisplayItemsAsLinks(boolean use) {
              useLinkState = use;
         public void setLinkColor(Color color) {
              linkColor = color;
              if(theList != null) {
                   theList.repaint();
         public Color getLinkColor() {
              return linkColor;
         public void setHoverLinkColor(Color color) {
              hoverColor = color;
              if(theList != null) {
                   theList.repaint();
         public Color getHoverLinkColor() {
              return hoverColor;
         public void setSelectedLinkColor(Color color) {
              selectedLinkColor = color;
              if(theList != null) {
                   theList.repaint();
         public Color getSelectedLinkColor() {
              return selectedLinkColor;
         public void attachLinkSimulationListener() {
              theList.setCursor( Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) );
              theList.addMouseListener( new MouseAdapter() {
                   public void mouseEntered(MouseEvent e) {
                        isOnRow = true;                    
                   public void mouseExited(MouseEvent e) {
                        isOnRow = false;
    currentLinkRow = -1;
    theList.repaint();
              theList.addMouseMotionListener( new MouseMotionAdapter() {
                   public void mouseMoved(MouseEvent e) {
    isOnRow = true;
    currentLinkRow = theList.locationToIndex( e.getPoint() );
    theList.repaint();
              /*table.addMouseListener(new MouseAdapter() {
    public void mouseEntered(MouseEvent e) {
    public void mouseExited(MouseEvent e) {
    isOnRow = false;
    currentHighlightRow = -1;
    table.repaint();
    table.addMouseMotionListener( new MouseMotionAdapter() {
    public void mouseMoved(MouseEvent e) {
    isOnRow = true;
    currentHighlightRow = table.rowAtPoint( e.getPoint() );
    table.repaint();
         public boolean shdPaintDivider() {
              return paintDivider;
         public void setPaintDivider(boolean paintDivider) {
              this.paintDivider = paintDivider;
         public void setDividerImage(Icon icon) {
              this.dividerImage = icon;
              setPaintDivider(true);
         private void dispatchEvent(MouseEvent me) {
    if(rect != null && box != null && rect.contains(me.getX(), me.getY())){
    Point pt = me.getPoint();
    pt.translate(0,0);
    box.setBounds(rect);
    box.dispatchEvent(new MouseEvent(box, me.getID()
    , me.getWhen(), me.getModifiers()
    , pt.x, pt.y, me.getClickCount()
    , me.isPopupTrigger(), me.getButton()));
    if(!box.isValid()) {
         repaint();
         System.out.println("Dispatch Event: Box.invalid called");
    System.out.println("Dispatch Event called");
    } else {
         System.out.println("Dispatch Event Called, rect null");
    public void mouseClicked(MouseEvent me){
    dispatchEvent(me);
    public void mouseEntered(MouseEvent me){
    dispatchEvent(me);
    public void mouseExited(MouseEvent me){
    dispatchEvent(me);
    public void mousePressed(MouseEvent me){
    dispatchEvent(me);
    public void mouseReleased(MouseEvent me){
    dispatchEvent(me);
    public class SelectionStateHandler extends MouseAdapter {
         JList list = null;
         public SelectionStateHandler(JList list) {
              this.list = list;
         public void mouseClicked(MouseEvent e)
              * Handles the checkbox selection process. Uses the bounds property of the
              * check box within the selected cell to determine whether the checkbox should
              * be selected or not
              public void mouseReleased(MouseEvent e) {
                   /*if(list == null || list.getSelectedIndex() == -1
         || !isEnabled( list.locationToIndex(e.getPoint()) ) ) {
         return;
              if(list == null || list.getSelectedIndex() == -1){
                   return;
         int[] indices = list.getSelectedIndices();
         // get the current relative position of the check box
         //rect = box.getBounds(rect);
         for(int i = 0; i < indices.length; i++) {
         // get the current relative position of the check box
         int loc = list.locationToIndex( e.getPoint() );
         rect = list.getCellBounds(loc,loc);
         // ensure the point clicked in within the checkBox
         if(e.getX() < (rect.getX() + 20) ) {
              Object obj=list.getModel().getElementAt(i);
              //if(!obj.equals("SelectAll")&&!obj.equals("ClearAll")&&!obj.equals("GrayedAll")){
                   if(indices[i]>2){
                        selState[0]=false;
                        selState[1]=false;
                        selState[2]=false;
                        //����
                        if(!this.isEnabled(indices[i])&&selState[indices[i]]==true){
                             this.setEnabled(indices[i],true);
                             selState[indices[i]]=false;
                        } else if(this.isEnabled(indices[i])&&selState[indices[i]]==true){
                             //����
                             selState[indices[i]]=true;
                             this.setEnabled(indices[i],false);                              
                        }else if(this.isEnabled(indices[i])&&selState[indices[i]]==false){
                             //����
                             selState[indices[i]]=true;
                             this.setEnabled(indices[i],true);
                   } else {
                        selState[indices[i]] = !selState[indices[i]];
         list.revalidate();
         list.repaint();
         public void selectAll(boolean b) {
              for(int i = 0; i < list.getModel().getSize(); i++) {
                   try {
                        this.enableAll(true);
                        Object obj=list.getModel().getElementAt(i);
                        if(!obj.equals("ClearAll")&&!obj.equals("GrayedAll")){
                             selState[i] = b;
                        } else{
                             selState[i]=!b;
                        selState[0]=false;
                   } catch(ArrayIndexOutOfBoundsException aie) {
                        updateSelectionStateTrackers(list);
                        selectAll(b);
                        return;
              if(list != null) {
                   list.revalidate();
                   list.repaint();
         public void clearAll(boolean b){
              for(int i = 0; i < list.getModel().getSize(); i++) {
                   try {
                        Object obj=list.getModel().getElementAt(i);
                        this.enableAll(true);
                        if(!obj.equals("ClearAll")){
                             selState[i] = !b;
                        } else{
                             selState[i]=b;
                        selState[1]=false;
                   } catch(ArrayIndexOutOfBoundsException aie) {
                        updateSelectionStateTrackers(list);
                        selectAll(b);
                        return;
              if(list != null) {
                   list.revalidate();
                   list.repaint();
         public void grayedAll(boolean b){
              for(int i = 0; i < list.getModel().getSize(); i++) {
                   try {
                        Object obj=list.getModel().getElementAt(i);
                        if(!obj.equals("SelectAll")&&!obj.equals("ClearAll")){
                             if(i==2){
                                  selState[i] = !b;
                             }else{                             
                                  selState[i] = b;
                             this.setEnabled(i,false);
                        } else{
                             selState[i]=!b;                          
                   } catch(ArrayIndexOutOfBoundsException aie) {
                        updateSelectionStateTrackers(list);
                        selectAll(b);
                        return;
              if(list != null) {
                   list.revalidate();
                   list.repaint();
         public void setSelectedIndex(int index) {
              for(int i = 0; i < list.getModel().getSize(); i++) {
                   selState[i] = false;
              selectIndex(index);
         public void selectIndex(int index) {
              try {
                   selState[index] = true;
              } catch(ArrayIndexOutOfBoundsException aie) {
                   updateSelectionStateTrackers(list);
                   selectIndex(index);
                   return;
              if(list != null) {
                   list.revalidate();
                   list.repaint();
         public void setEnabled(int index, boolean b) {
              try {
                   enableState[index] = b;
              } catch(ArrayIndexOutOfBoundsException aie) {
                   updateSelectionStateTrackers(list);
                   setEnabled(index, b);
         public boolean isEnabled(int index) {
              if(index == -1) {
                   return true;
              boolean isEnabled = true;
              try {
                   isEnabled = enableState[index];
              } catch(ArrayIndexOutOfBoundsException aie) {
                   updateSelectionStateTrackers(list);
                   return isEnabled(index);
              return isEnabled;
         public void enableAll(boolean b) {
              for(int i = 0; i < enableState.length; i++) {
                   enableState[i] = b;
    public void selectAll(boolean b) {
         if(selStateHandler == null) {
              return;
         selStateHandler.selectAll(b);
    public void clearAll(boolean b){
         if(selStateHandler == null) {
              return;
         selStateHandler.clearAll(b);
    public void grayedAll(boolean b){
         if(selStateHandler == null) {
              return;
         selStateHandler.grayedAll(b);
    public void setSelectedIndex(int index) {
         if(selStateHandler == null) {
              return;
         selStateHandler.setSelectedIndex(index);
    public void selectIndex(int index) {
         if(selStateHandler == null) {
              return;
         selStateHandler.selectIndex(index);
    public void enableAll(boolean b) {
         if(selStateHandler == null) {
              return;
         selStateHandler.enableAll(b);
    public void setEnabled(int index, boolean enable) {
         if(selStateHandler == null) {
              return;
         selStateHandler.setEnabled(index, enable);
    public boolean isEnabled(int index) {
         if(selStateHandler == null) {
              return true;
         return selStateHandler.isEnabled(index);
    public boolean isEnabledAll() {
         if(enableState == null) return true;
         for(int i = 0; i < enableState.length; i++) {
              if(!isEnabled(i)) {
                   return false;
         return true;
    // EmptyIcon implementation
    public static class EmptyIcon implements Icon {
         int width = 16, height = 16;
         public EmptyIcon() {
         setSize(16,16);
         public EmptyIcon(int width, int height) {
         setSize(width, height);
         public void setSize(int width, int height) {
         this.width = width;
         this.height = height;
         public int getIconWidth() {  return width; }
         public int getIconHeight() { return height; }
         public void paintIcon(Component c, Graphics g, int x, int y) {}
    public int getItemCount(){
         if(theList!=null){
              return theList.getModel().getSize();
         } else {
              return 0;
         public boolean[] getEnableState() {
              return enableState;
         public boolean[] getSelState() {
              return selState;
         public JList getTheList() {
              return theList;
    testbox :import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.JComboBox;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    public class testbox extends JComboBox
    * @param args
    JComboBox myComboBox;
    public testbox()
    myComboBox = new JComboBox();
    public void setPopupVisible(boolean b)
         if(b)
              myComboBox.showPopup();
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             

    You are updating the label value when (index == -1), let change into (index<=0).
    like below
    // this should cause a JComboBox to paint the Label instead of the
                // check box + label combination
                if (index <= 0) {
                    Vector v = new Vector();
                    v = getSelectedObjects();
                    String val = generateString();
                    JLabel label = new JLabel(val);
                    if (iconLabel.getIcon() != null) {
                        label.setIcon(iconLabel.getIcon());
                    System.out.println("label");
                    return label;
                }

  • A Grow Box for a JFrame

    I am this >||< (font size 8) close to getting this JGrowBox class thing to work exactly the way I want it to, and then, everybody can have a nice little grow box thingie to "attatch" to their JFrames. Ooooh.
    I have three problems. First, if the user tries to resize the frame normally (grabs the very corner of the JFrame) then the JFrame resizes in its normal ugly way, without repainting its components (which means that the JGrowBox thing just stays where it is, which looks stupid.) Second, if the user grabs the actual JGrowBox the way you can with all other stupid Windoze programs, the JFrame flickers horribly, and the CPU goes nuts. Third, I use static byte array representations of the GIF images. This is kinda lame. I'm guessing all the cool Java widgets use Java2D somehow.
    The dimensions used for the customized JComponent are specific to the arrangment of the rest of the layout. The JGrowBox is actually in the BorderLayout.EAST of a 18-pixel tall JPanel "status bar" thingie, which is in the BorderLayout.SOUTH of the contentPane. I didn't feel like going through the hassle of getting the thing to be universally positioned at the bottom-right of the parent JFrame, regardless of layout.
    The images are just a 16x16 screen captures of the Windows 2000 and Windows XP grow boxes, respectively, with the window grey replaced with black and black set as the transparent color, and then sort of converted into a static byte array. I suppose it might be a bit more space-saving to just use Java2D to draw out all the pixels and stuff, but I hate doing that kinda crap.
    Code:
    * JGrowBox.java
    * Created on July 28, 2005, 1:54 PM
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    * @author [email protected]
    public class JGrowBox
        extends JComponent {
        // the associated JFrame window parent of the grow box
        private JFrame parent = null;
        // where the user clicked the mouse to resize using the grow box
        private Point p0 = null;
        // the image of the grow box thinga-ma-jigger
        private Image image = null;
        /** Creates a new instance of JGrowBox */
        public JGrowBox(final JFrame parent) {
            this.parent = parent;
            // get the name of the operating system
            String OS_NAME = System.getProperty("os.name");
            // anybody got GIFs for KDE or GNOME?
            if (OS_NAME.equals("Windows 2000")) {
                image = new ImageIcon(WINDOWS_2000_GROW_BOX.BYTES).getImage();
            else if (OS_NAME.equals("Windows XP")) {
                image = new ImageIcon(WINDOWS_XP_GROW_BOX.BYTES).getImage();
            // this stuff is specific to a given arrangement
            setSize(new Dimension(18, 15));
            setPreferredSize(new Dimension(18, 15));
            setMaximumSize(new Dimension(18, 15));
            setMinimumSize(new Dimension(18, 15));
            setFocusable(false);
            // getting the first mouseClick and changing the cursor and stuff
            addMouseListener(new MouseAdapter() {
                public void mouseEntered(MouseEvent e) {
                    parent.getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
                public void mouseExited(MouseEvent e) {
                    parent.getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                public void mousePressed(MouseEvent e) {
                    if (e.getButton() == MouseEvent.BUTTON1) {
                        p0 = e.getPoint();
                public void mouseReleased(MouseEvent e) {
                    if (!contains(e.getPoint())) {
                        parent.getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            // when the user drags the mouse, resize the parent JFrame (ugly!)
            addMouseMotionListener(new MouseMotionAdapter() {
                public void mouseDragged(MouseEvent e) {
                    Point p1 = e.getPoint();
                    parent.getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
                    Rectangle bounds = parent.getBounds();
                    int x = bounds.width + (p1.x - p0.x);
                    int y = bounds.height + (p1.y - p0.y);
                    Point p2 = new Point(x, y);
                    int xMax = Toolkit.getDefaultToolkit().getScreenSize().width;
                    parent.setSize(Math.min(p2.x, xMax), p2.y);
            // hide the grow icon when the parent window is maximized
            parent.addComponentListener(new ComponentAdapter() {
                public void componentResized(ComponentEvent e) {
                    if (parent.getExtendedState() == JFrame.MAXIMIZED_BOTH) {
                        setVisible(false);
                    else {
                        setVisible(true);
        public void paintComponent(Graphics g) {
            if (image != null) {
                g.drawImage(image, 3, 3, this);
        public boolean contains(Point p) {
            Rectangle r = getBounds();
            return (p.x >= 0 && p.x <= r.width &&
                    p.y >= 0 && p.y <= r.height);
    class WINDOWS_2000_GROW_BOX {
        public final static byte[] BYTES = {
      71,   73,   70,   56,   57,   97,   16,    0,   16,    0,   -9,    0,    0,    0,    0,    0,
      -1,   -1,   -1,  -44,  -48,  -56, -110, -116, -106, -100, -102,  -69,    0,    0,   -1,    0,
       0, -128, -118, -103,  -35,  115,  126,  -96,   10,   36,  106,   10,   35,  103,    9,   32,
      95,   11,   37,  107,   13,   39,  109,   35,   54,  106,   10,   36,  105,    8,   27,   77,
      12,   39,  108,   14,   40,  109,   15,   42,  110,   15,   41,  110,   16,   42,  111,   17,
      44,  112,   17,   43,  112,   18,   45,  113,   19,   46,  114,   20,   47,  115,   15,   35,
      84,   21,   48,  116,   21,   48,  115,   22,   49,  116,   23,   50,  117,   24,   51,  118,
      25,   52,  119,   27,   54,  120,   28,   55,  121,   29,   56,  122,   30,   57,  123,   31,
      58,  124,   32,   59,  125,   34,   61,  126,   36,   63, -128,   37,   64, -127,   38,   65,
    -126,   30,   58,  123,   32,   60,  125,   33,   61,  126,   34,   62,  127,   39,   67, -125,
      41,   70, -123,   40,   68, -125,   41,   69, -124,   42,   70, -123,   43,   71, -122,   44,
      72, -121,   45,   74, -120,   45,   73, -120,   46,   75, -119,   47,   75, -118,   48,   77,
    -117,   49,   78, -116,   48,   76, -118,   50,   79, -115,   51,   80, -115,   52,   81, -114,
      53,   82, -113,   54,   83, -112,   54,   83, -113,   55,   84, -111,   56,   85, -110,   56,
      85, -111,   57,   86, -110,   58,   87, -109,   59,   88, -108,   60,   89, -107,   61,   91,
    -106,   61,   90, -107,   62,   91, -106,   63,   93, -104,   63,   92, -105,   64,   93, -104,
      65,   94, -103,   66,   95, -102,   67,   96, -101,   68,   98, -100,   69,   99,  -99,   68,
      97, -101,   70,  100,  -99,   72,  102,  -97,   71,  101,  -98,   73,  104,  -96,   73,  103,
    -96,   74,  104,  -95,   75,  105,  -94,   76,  107,  -93,   77,  108,  -92,   77,  107,  -92,
      76,  106,  -94,   78,  109,  -91,   79,  110,  -91,   80,  111,  -90,   82,  113,  -88,   81,
    112,  -89,   83,  114,  -87,   84,  115,  -86,   85,  116,  -85,   87,  118,  -84,   89,  120,
    -82,   88,  119,  -83,   90,  121,  -81,   89,  120,  -83,  105, -115,  -53,   91,  123,  -80,
      93,  125,  -78,   92,  123,  -80,   91,  122,  -81,   93,  124,  -79,   95,  126,  -77,   94,
    125,  -78,   96,  127,  -76,   97, -128,  -76,   98, -126,  -75,   98, -127,  -75,  100, -125,
    -73,  100, -124,  -73,   99, -126,  -74,  101, -123,  -72,  103, -121,  -70,  102, -123,  -71,
    102, -122,  -71,  105, -119,  -68,  104, -120,  -69,  107, -117,  -67,  106, -118,  -68,   31,
      59,  102,   36,   64,  104,  107, -116,  -66,  108, -115,  -66,  110, -113,  -64,  109, -114,
    -65,  112, -111,  -62,  111, -112,  -63,  113, -110,  -61,  112, -112,  -63,  114, -109,  -61,
    116, -107,  -59,  115, -109,  -60,  115, -108,  -60,  118, -105,  -57,  117, -106,  -58,  120,
    -103,  -55,  119, -104,  -56,  121, -102,  -54,  119, -104,  -57,  122, -101,  -54,  121, -102,
    -55,  124,  -99,  -52,  123, -100,  -53,  125,  -98,  -51, -117,  -83,  -32,   72,  124,  -61,
    126,  -96,  -50,  124,  -99,  -53,  126,  -97,  -51, -127,  -93,  -48, -128,  -95,  -49, -125,
    -91,  -46, -126,  -92,  -47, -123,  -89,  -44, -124,  -90,  -45, -121,  -87,  -42, -122,  -88,
    -43, -118,  -84,  -40,  106,  -98,  -36,   97, -119,  -72, -123,  -85,  -38, -120,  -85,  -41,
    -117,  -82,  -39, -119,  -84,  -41, -114,  -80,  -37, -115,  -81,  -38, -116,  -82,  -39, -112,
    -77,  -35, -113,  -79,  -36, -110,  -75,  -33, -111,  -77,  -34, -111,  -76,  -34, -107,  -72,
    -30, -108,  -73,  -31, -109,  -74,  -32, -106,  -71,  -30, -107,  -72,  -31, -104,  -69,  -28,
    -105,  -70,  -29, -102,  -67,  -26, -103,  -68,  -27,  109,  -93,  -34, -100,  -65,  -25, -101,
    -66,  -26, -102,  -67,  -27,  -97,  -61,  -22,  -98,  -63,  -23,  -98,  -62,  -23,  -99,  -64,
    -24,  -95,  -59,  -20,  -96,  -61,  -21,  -93,  -57,  -18,  -95,  -60,  -21,  -93,  -58,  -19,
    -97,  -73,  -46,  -95,  -72,  -46,   45,   88, -126,   74,  122,  -87,  -94,  -58,  -20,  -91,
    -55,  -17,  -90,  -54,  -16,  -70,  -52,  -34,   78,  -99,  -29,   74, -114,  -51,  109,  -71,
      -9,  -85,  -52,  -25, -124,  -81,  -47,   65, -115,  -62,  124,  -78,  -40,  -86,  -43,  -12,
    -77,  -63,  -53,  105, -127, -113,   67,  -98,  -51,   73,  -86,  -38,  103,  -74,  -33,   77,
    -70,  -21,  104,  -57,  -23,  -72,  -27,  -13, -127,  -45,  -23, -104,  -33,  -13,  -61,  -18,
      -6, -111,  -36,  -16, -101,  -49,  -37, -101,  -34,  -25,  127,  -47,  -37,  -85,  -27,  -40,
    -111,  -28,  -65,  -99,  -21,  -57,    0, -128,    0,  -48,   -8,  -51,   -1,   -1,    0, -128,
    -128,    0,  -69,  -73,  -97,  -83,  -99,  105,  123,  110,   81,  -87,  -91, -100,   -1,    0,
       0, -128,    0,    0, -110, -118, -118, -128, -128, -128,   64,   64,   64,   33,   -7,    4,
       1,    0,    0,    0,    0,   44,    0,    0,    0,    0,   16,    0,   16,    0,    0,    8,
      59,    0,    1,    8,   28,   72,  -80,  -96,  -63, -125,    8,   19,    6,   72,   88,   48,
    -128,   63, -122,    3,   29,   62, -124,   40,   17,   34, -128, -118,   11,   21,   -6,  123,
    -24,   80,   35,  -57, -115,    8,   49, -126,   60,   40, -110,  -93,  -63, -110,   23,   39,
      70,    4, -119,  114,  -27,  -57, -105,   22,   99,   50,   12,    8,    0,   59
    class WINDOWS_XP_GROW_BOX {
        public final static byte[] BYTES = {
      71,   73,   70,   56,   57,   97,   16,    0,   16,    0,   -9,    0,    0,   -8,  -70,   43,
    -45,  -94,  -97,    0,   90,  -20,  -39,  -39,  -40,    2,  106,   -2,  -26,  111,   82,  113,
    111,  100,  -11,  -11,  -15,  -14,  -14,  -18,  121,  -98,  -66,  -52,  -51,  -53, -111, -103,
    -48,  111,  114,  -78,  -83,  -80,  -45,  -13,  -21,  -76,  -30,  -36,  -53,  -74,  -57,   -8,
       0,    0,    0,    1,  -79,    3,  -39,  -30,   -7,  -98,  -74,  -41,  -36,   10,   25,   73,
    124,  -10,   -2,   -5,  -11,  -32,   77,   47,    0,   75,  -30,  -91,  -90,  -91,  -28,  -24,
      -8,  101,  -79,   -8,   53,  112,  -12,   83, -118,   -9, -110,  -44,   -8,  -84,  -88, -103,
       1,   19, -117,   62, -106,   -1,  -17,  -19,  -34,    3,  101,  -15,   33, -105,  -76,  -82,
    -70,  -19,  -77,  -14,   -5,   -7,  -56,   76,    0,   90,  -12,  -15,  -17,  -30,  -44,  -37,
      -8,  120,  -56,  -21,   20,   72,  -69,    0,  -98,  -57,    0,   60,  116,  -65,  -63,  -65,
       1,   68,  -48,    1,  -37,    0,   81,  -90,   -8,  -74,  123,    0,  -28,  -28, -109,  -51,
    -42,   -7,  -59,  -59,  -59,   -8, -103,  116, -105,  -78,  -17,  -97,  -95,  -98, -122, -119,
    -65,  -10,  -84,   76,   75,   75,   74,    1,   67,  -49, -122, -126, -122,    3,  113,   -1,
       8,   85,  -35,  104, -107,  -11, -100, -103, -100,  -33,  -33,  -35,    0,   30,  -95,  -86,
      47,   10,  -20,  -23,  -40,  -38,  -43,  -61,   -7,   -7,   -7,  -35,  -75,  -59,   44,   44,
      43,  -17,  -18,  -13,   43, -112,   -1,    0,   61,  -36,   98,   98,   98,  -63,  -59,  -27,
      -3,  -49,  108,    6,   44,  -86,  -45,  -59,  -80,   -2,   -3,   -6,  -28,  -27,  -28,   50,
    106,  -63,  -79,  -77,  -80,  -61,  -49,   -7,   85,  -68,  -44,  -16,  -45,  -18,   35,   89,
    111, -104,  -49,  -52,   53,  -84,  -56,  -86,  -85,  -69,    0,   88,  -26, -113, -115, -114,
      65, -110,  -89,   74,  -83,   96,  -70,  -70,    0,  -77,  118, -111,   -5,  -17,  -41,  -14,
    -13,   -8,  -19,  -21,  -26,   21, -124,  -24,  -45,  -41,  -19,    0,   72,  -15,  124,  121,
    119,  -94,  -98, -105,   22,  106,  -18,  -28,  -12,   -5,  -21,  -52,  -67,    6, -124,   92,
      -4,  -36, -111,    0,   85,  -22,  -99, -106,  -74,  -54, -114,   82,    0,   83,  -31,   97,
    -85,  -70,  -37,  -35,  117,  -19,  -28,  -58,   -5,   -9,  -12,  120,  -72,  -53,   18,  -92,
    -55,   -1,   -1,   -1,   81,  -22,   70, -112,   -7, -123,    7,   49,  -39,  105,   40,   19,
    -11,   -4,   -5,   -5,  -10,  -20,  -72,   94,  108,    3,   54,  -66,  -71,  -71,  -70,  120,
    -84, -121,    1,   97,  -21,    8,   49,  -39,  -24,  -25,  -25,  -55,  -49,  -22,  -11,  -13,
    -27,   -5,  -62,   59,   32, -122,   -2,    0,   54,  -21,    7,  120,  -92,  105, -107,  -52,
      36,  106,  -11,  -20,  -20,  -18,   -5,  -10,  -25,   34,  120,   -7,    0,   25,  -49,  -69,
    -67,  -36,   27,   94,  -27,   80, -102, -100,  -23,  -70,   83,  -21, -124,   89,    2,  107,
    -12,   80,  -80,  -90,  106, -114,  -96,   44,   89,  -60,    1,  100,   -7,    0,   81,  -27,
      -8,   -7,   -3,  -46,  -61,  -37,    0,   38,  -59,  -72,  -76,  -94,  -25,  -31,  -37,   39,
      96,  -27,   -6,  -63,   14,   -4,  -13,   -3, -109,  -92,  -73,    0,   38,  -45,   41, -103,
    -56,   27,   90,  -15,  -59,  -39,  127,  -74,  -67,  -68,   23,   85,  -33,   15,   92,  -25,
      10,  102,  -12,   -2,  -20,  -22,  -23,  -26,  -33,    3,   62,  -56,    6,   77,  -42,  -16,
    -16,  -21,    4,   84,  -25,  -24,  -27,  -45,   -4,   -4,   -5,    0,   55,  -45,  -96,  -64,
      43,    0,   85,  -27,   -1,  -17,  -53,  -33,  -28,  -50,    6,   88,  -28,  -31,  -26,  -24,
       0,   96,   -8,    0,   84,  -29,    0,  101,   -3,   -9,  -17,  -25,    0,   96,   -4,  -57,
    -53,   45,   -2,   -5,  -18,   -2,   -2,   -2,  -64,  -70,  -84,   63,   64,   61,  -11,  -12,
    -36,  -48,  -44,   80,  -69,  -85,  -66,  -60,  -58,   30,    0,  123,    2,    1,  114,  -34,
      -5,   -5,  -27, -110, -111, -107,   -9,  -21,  -32,  -97, -105, -127,   -6,  -23,   78,   -7,
    -26,   96,   58, -104,  -26,  -46,  -45,  -46,   42, -107,  -22,   -4,   -4,   -1,   -1,   -1,
    -83, -112,   -1,   -1,   50, -119,   -3,   32,   45,   52,   17,   20,   18,  108,  108,  108,
    -40,  -68, -113,   73, -123,  -43,   33, -115,  -34,  -15,  -14,  -23,   70,  -87, -109,  -13,
    -29,  -30,   21,  126,  -32,    3,  104,   -6,   -3,   -2,   -2,  -65,  -36,  -57,   21,  111,
      -9,   -1,   -2,   -3,   37,  -20,   32,   17,   78,  -33,  -21,  -24,  -32,   11,  104,   -9,
      14,   80,  -19,   -8,   -4,   -3,   -2,   -5,   -5,  -42,  -48,  -59,  -11,  -11,  -22,  -48,
    -33, -107, -122, -112,  105,  112,   89, -118,  -21,  -24,  -40,  126,  -92,  -14,  -97,  -96,
    -53,  -33,  -62,  -24,  -49,  -79,   59,  127,  109,   76,    7,   79,  -22,   33,   -7,    4,
       1,    0,    0,   17,    0,   44,    0,    0,    0,    0,   16,    0,   16,    0,    0,    8,
      61,    0,   35,    8,   28,   72,  -80,  -96,  -63, -125,    8,   19,   42,   36,   72, -118,
    -44,  -62, -127,   13,   -7,   60,   20,  -56,   71,  -30,  -60, -123,   13,    5,  102,   76,
      24,   49,   66,  -57, -124,   21,   41,   90,  -68,   88,  112,  -93,   73, -121,   37,   73,
      73,  -20,   -8, -111,   96,  -56,    8,   47,   95, -110, -100,   25,   33,   32,    0,   59
    }

    Yes, <expletive deleted>, I know what Google is.You need to calm down.I was perfectly calm. You're the one saying "Oh, but maybe you don't know what a "google" is.", which intended or not, sounds like you're calling me a jackass for not looking it up myself. Nevermind the fact that you said in the post before that that you didn't even know what it was called. So why should I assume that searching the web for "grow box" is going go give me any results at all that have to do with what you're trying to do?
    Hmm, perhaps you are just being argumentative, and
    wasting my time, but I'll assume that there are
    enough people out there like you who don't understand
    what the purpose of that doohickey in the southeast
    corner of a window is to make responding to your
    questions worth my time. I'm not doing it to waste your time. I'm quite sure I've never seen what you linked to on an application before. At least not like what that link showed. If you had said, for example, like Internet Explorer has that little larger box in the lower right corner which acts as a larger handle for window resizing, then I might have understood you from the start.
    By the way, are you
    suggesting by your question that it is perhaps
    unnecessary to fulfill the expectations of the end
    user with respect to the graphical user interface of
    a Java program, just because the given defacto Java
    component already has very nearly the bare minimum
    functionality expected of a comparable gui component
    that can be found in any other relatively advanced
    development kit?I would expect that a frame-like container component that supports manual resizing by the user would supply some location to click to initiate that resize. How is up to the component.
    Okay, so why would you need a handle to resize the
    frame?
    Reason #1: Because it aids the user in resizing the
    window. It's a bigger, albeit not by much, area on
    the screen for which the user can aim for in the
    mouse movement action to "grab" onto a portion of the
    current window in order to resize it, reducing the
    amount of time wasted on window arrangement.As mentioned above, if something like what IE has, or Netscape or FireFox has in the lower right, then fine.
    Reason #2: Because I'll bet you dollars to donuts
    that the web browser you are using right now to view
    this rapidly decaying topic has one. Shouldn't your
    program be at least as good as, say,
    IExploder? Why not at least try to make your
    Java program seem like it didn't just fall off the
    Swing turnip truck?I wouldn't use the terms "at least as good as" and IE in the same sentence. But that's just me. But as I mentioned above, I don't think you were clear on what you were talking about.
    You started by saying "grow box" like this was some common name for something assuming everyone would know what you were talking about. Then when asked, you admitted you didn't know what it was really called, which as mentioned, I think precludes one from "googling" that term, as the results, IMO, can be assume to not necessarily be what you are talking about. Then you post a specific link to a site that you say is more or less what you have in mind, but that's refering to very old Mac applications as an example, instead of (as in your most recent post) just refering to a very common modern application as an example.
    Reason #3: Because, maybe it looks cooler that way.
    I mean, geez, man. You don't have to
    o use it. It was just an idea. Gawd.I think you need to calm down. If you can't be more clear initially what you're talking or give modern references to site examples, then you shouldn't expect everyone on a text-only forum can read your mind and figure out what you really are looking for.
    Addressing the second problem I was having with this
    class, adding this line:
    System.setProperty("sun.awt.noerasebackground",
    ound", "true");
    gets rid of the flicker, but not the performance hit.
    Got this from the misnamed not_a_genius in "Re:
    : Transparent windows."
    (http://forum.java.sun.com/thread.jspa?threadID=391403
    &messageID=3067048#3067048).http://www.javadesktop.org/forums/thread.jspa?threadID=6437&tstart=15
    You basically are either going to have to live with the performance hit or the flicker, from what I can see. At least til Java 6 next year. Or you can check
    https://swinglabs.dev.java.net/
    and see if they have a fix that is backwards compatible with Java 1.5. I thought I heard said that they made something available to fix the "gray rectangle" problem... I could be wrong about that, though.
    Anyway, for real info, you can read thru:
    http://weblogs.java.net/blog/chet/archive/2005/04/swing_update_no_1.html

  • Listening for multiple keypresses simultaneously

    I'm trying to move a rectangle around with arrow keys.
    The current code of keyPressed method is
         public void keyPressed(KeyEvent e){
    /*           switch(e.getKeyCode()){
                   case 37: x=(Math.max(0,x-3));break;
                   case 38: y=Math.max(0,y-3); break;
                   case 39: x=Math.min(200,x+3);break;
                   case 40: y=Math.min(200,y+3);break;
              int a = e.getKeyCode();
              if(a == 37){x=Math.max(0,x-3);}
              if(a == 38){y=Math.max(0,y-3);}
              if(a == 39){x=Math.min(200,x+3);}
              if(a == 40){y=Math.min(200,y+3);}
              repaint();
         }The problem is that when pressing multiple keys at the same time only one registers.
    So how do I register multiple key presses ad change x and y accordingly?
    thank you

    It seems to me that the problems mentioned in that link with the "hold" could be solved with using a state flag set on keyPressed and then reset on keyReleased. When you release even one you should get the keyReleased event and until then, you should be in a hold state.

Maybe you are looking for

  • Updates to a complex view

    SQL Developer version 3.0.04 on XP Pro We are able to use the data grid to update the values of views that are inherently updatable, no problem. We have a complex view with an associated instead-of-update trigger. We are able to update this complex v

  • Itouch stuck on startup screen-please help!

    My itouch has been stuck on the startup screen since last night; first I tried letting it charge, and after 30 minutes with no results I unplugged it, let the battery drain completely and started again. After another hour of charging with no results

  • Can't scan to computer w/new HP Photosmart 6520

    -New HP Photosmart 6520 was installed 2 days ago. eprint sucessfully done as well. I can scan to an email thru eprint, but can't scan the document to my computer. The printer message tells me there it's a USB connection error. -I have shut down and c

  • Need help on: Automation of Daily Data Load

    Hi all, We need to start our Daily Data load from DAC by Manually. So right now my client has asked us to do Automation of Daily Data Load. Starting the Daily Data Load Manually(DAC) Process: First we have to check whether the ASCP Plans updated or n

  • How to delete custom AET fields in CRM 7.0 Web UI

    Hello gurus, When I want to delete a custom AET field created by a mistake or for exercising purposes only, the UI Config tool markes it for deletion by changing a status to "Marked for Deletion" (a garbage bucket icon). My question is how to proceed