How painting behind a JComponent ?

Hi all,
I'm trying to paint stuff like shadows, frames (not borders), etc. behind JComponents.
So every shape only intersects with the relative JComponent's one.
Cannot paint these stuff in the container's paintComponent() method since more widgets can have one or more of them, so I guess It should be better do the job in every child's paintComponent() method.
What follows was the code I tested but doesn't work.
Any hints ? Thanks in advance.
Lucio
import java.awt.*;
import javax.swing.*;
public class UpButton extends JButton {
    Dimension dimension = new Dimension(100, 100);
    Point point = new Point(100, 100);
    public UpButton(String text) {
     setSize(dimension);
     setLocation(point);
     setBackground(new Color(255,186,26));
     setText(text);
    public void paintComponent(Graphics g) {
     Component c = (Component) getParent();
     Graphics2D g2 = (Graphics2D)
                                  c.getGraphics().create(0,0,dimension.width,dimension.height);
     g2.translate(-(point.x + 10), -(point.y + 5));
     g2.setPaint(Color.gray);
     g2.fill(new Rectangle(dimension));
     g2.dispose();
     super.paintComponent(g);
    public static void main(String[] args) {
     JFrame jFrame = new JFrame();
     jFrame.getContentPane().setLayout(null);
     jFrame.add(new UpButton("Test"));
     jFrame.setSize(300,300);
     jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     jFrame.setVisible(true);
}

I'm very grateful to you, weebib
I was missing the setClip method, now perfectly works.
It doesn't seems to me too difficult (now ;-)
Here my modified version :
import java.awt.*;
import javax.swing.*;
public class UpButton extends JButton {
    Dimension dimension = new Dimension(100, 100);
    Point point = new Point(100, 100);
    public UpButton(String text) {
     setSize(dimension);
     setLocation(point);
     setBackground(new Color(255,186,26));
     setText(text);
    public void paintComponent(Graphics g) {
     Graphics2D g2 = (Graphics2D) g.create();
     g2.translate(10, 5);
     g2.setClip(0, 0, 100, 100);
     g2.setPaint(Color.gray);
     g2.fill(new Rectangle(dimension));
     g2.dispose();
     super.paintComponent(g);
    public static void main(String[] args) {
     JFrame jFrame = new JFrame();
     jFrame.getContentPane().setLayout(null);
     jFrame.add(new UpButton("Test"));
     jFrame.setSize(300,300);
     jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     jFrame.setVisible(true);
}

Similar Messages

  • Confused by how Paint Brushes Work

    I draw a rectangle in object mode, and using the Brush Mode
    options:
    a) paints fill paints behind the shape. What is considered
    the fill in this example?
    b) paints inside, seems to paint inside the shape, however,
    if I start painting outside the shape and into the shape, the
    stroke appears only outside of the shape and not inside.
    When drawing the shape in non-object mode:
    a) Paints fill paints both on top and outside of the shape
    b) paints inside, seems to paint inside the shape, however,
    if I start painting outside the shape and into the shape, the
    stroke appears only outside of the shape and not inside.
    Can anyone clarify how this is supposed to work?
    Thanks!!!

    I draw a rectangle in object mode, and using the Brush Mode
    options:
    a) paints fill paints behind the shape. What is considered
    the fill in this example?
    b) paints inside, seems to paint inside the shape, however,
    if I start painting outside the shape and into the shape, the
    stroke appears only outside of the shape and not inside.
    When drawing the shape in non-object mode:
    a) Paints fill paints both on top and outside of the shape
    b) paints inside, seems to paint inside the shape, however,
    if I start painting outside the shape and into the shape, the
    stroke appears only outside of the shape and not inside.
    Can anyone clarify how this is supposed to work?
    Thanks!!!

  • How to judge some jcomponent whether has gotten focus?

    1.How to judge some JComponent whether has gotten focus?
    2.How to judge what JComponent has gotten focus?

    1.How to judge some JComponent whether has gotten focus?You can use a [url http://java.sun.com/docs/books/tutorial/uiswing/events/focuslistener.html]Focus Listener.
    2.How to judge what JComponent has gotten focus?FocusManager.getCurrentManager().getFocusOwner()

  • How to check if JComponent is JLabel or not??

    I would need just a little check if a certain JComponent variable is a JLabel or not.
    I know JLabel is a subclass of JComponent but don't have any ideas.
    How to do that?
    Is there some method like:
    JComponent component;
    component.isLabel();Thanks for you help!!!!

    Provide a sampleok!
         Paint scaleGradient(Paint paint,View view){
              if (view.scale!=100){
                   if (GradientPaint.class.isInstance(paint) ){
                        GradientPaint gp = (GradientPaint)paint;
                        Point2D p1 = gp.getPoint1();
                        Point2D p2 = gp.getPoint2();
                        double scale = ((double)view.scale)/100;
                        p1 = new Point2D.Double(p1.getX()*scale,p1.getY()*scale);
                        p2 = new Point2D.Double(p2.getX()*scale,p2.getY()*scale);
                        paint = new GradientPaint(p1, gp.getColor1(), p2, gp.getColor2(), gp.isCyclic());     
                   else if (Radial.isRadial(paint))
                        paint = Radial.scale(paint, view.scale);
              return paint;
         }This snippet is from some paint code. Painting a shape, possibly with a gradient fill. If the view scale is not 100%, then the gradient needs scaling. But the Paint might be just a Color, or a GradientPaint, or a RadialGradientPaint. So isInstance( ) is used to find which.

  • How paint method in TiledLayer work ?

    It's my 1st time in forum. Does anyone has source code of Sprite, TiledLayer class or know how exactly the paint method work? I had used it in some game but not satisfied with it. I want to code my own class but i wonder it has some native or low-level code.
    Sorry for my poor E !!!

    perhaps you want to use a more hardware oriented approach. I can highly recommend you the Slick API. It is built on top of the LWJGL API set, which is a Java binding for OpenGL, OpenAL and provides device support such as joysticks/joypads. Slick turns the 3D part into an easy to use 2D rendering framework.
    [http://slick.cokeandcode.com/|http://slick.cokeandcode.com/]
    Basic example program:
    [http://slick.cokeandcode.com/wiki/doku.php?id=01_-_a_basic_slick_game|http://slick.cokeandcode.com/wiki/doku.php?id=01_-_a_basic_slick_game]

  • Painting behind transparent components

    Hi All,
    My problem is quite simple. I want to paint on a panel to which I then add a JEditorPane inside a JScrollPane both of which are transparent (using setOpaque(false)). I'm expecting whatever I paint to appear behind any text rendered by the JEditorPane as the component on which it is begin painted is behind the JEditorPane.
    What actually happens is that everything drawn on the panel appears above everything else. The following is a self contained example that should display the Google logo BEHIND the GNU GPL but instead paints it on top. Any ideas what the problem is?
    import javax.swing.*;
    import java.net.URL;
    import java.awt.*;
    public class Test extends JFrame
         public static void main(String args[]) throws Exception
              Test t = new Test();
         public Test() throws Exception
              setSize(500,500);
              setTitle("Test");
              JPanel backPanel = new JPanel(new BorderLayout())
                   ImageIcon background = new ImageIcon(new URL("http://www.google.com/images/logo.gif"));
                   public void paint(Graphics g)
                        super.paint(g);
                        g.drawImage(background.getImage(),50,150,this);
              backPanel.setOpaque(true);
              backPanel.setBackground(Color.white);
              JEditorPane textPane = new JEditorPane(new URL("http://www.gnu.org/licenses/gpl.txt"));
              textPane.setEditable(false);
              textPane.setOpaque(false);
              JScrollPane scroller = new JScrollPane(textPane);
              scroller.setOpaque(false);
              scroller.getViewport().setOpaque(false);
              backPanel.add(scroller,BorderLayout.CENTER);
              getContentPane().add(backPanel,BorderLayout.CENTER);
              setVisible(true);
    }

    You can paint directly on the text component:
    import java.awt.*;
    import javax.swing.*;
    public class TextPaneBackground extends JFrame
         ImageIcon icon;
         public TextPaneBackground()
              icon = new ImageIcon("mong.jpg");
              JTextPane textPane = new JTextPane()
                   public void paintComponent(Graphics g)
                        g.drawImage(icon.getImage(), 0, 0, null);
                        super.paintComponent(g);
              textPane.setOpaque( false );
              textPane.setText( "This is some text" );
              JScrollPane scrollPane = new JScrollPane( textPane );
              getContentPane().add( scrollPane );
         public static void main(String[] args)
              TextPaneBackground frame = new TextPaneBackground();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.setSize(200, 200);
              frame.setVisible(true);
    }Not positive, but I believe this approach would be more efficient. When Swing trys to paint a non-opaque component it needs to search the components ancestors until it finds an opaque component to paint the background. So I think in your case you have multiple ancestor, JViewport, JScrollPane, JPanel.

  • Drawing Inside Keeps Painting Behind Other Brush Strokes

    I am currently using the draw inside feature on an object of mine.  I find that when i come back to it, like if i save and close the program and then come back, whatever new stuff i paint vanishes behind rather than appearing on top.  The main solid colored object I always have to send behind before i could paint over it every single time.  But now that I have some details over top of that, they are cooperating the same way and need sent behind as well im assuming, with the main object being at the very back.  I'd hate to try and select everything because everything around it would need locked and this and that to select what i need and its just allot of hassle, especially if i have to do it every time i re open the program.  Shouldn't new brush strokes paint above everything rather than below?  Any help would be highly appreciated.  

    I submitted something similar to this about two version back. I know
    when I'm trying to draw a long line, it would be nice to be able to use
    some sort of guide. I think I was imagining a tool that you could hold
    with a second hand while drawing with the wacom pen. I think they really
    could corner the market if they came up with something like this.
    Unfortunately, I think they hold back...after all, if they give it all
    away, they have nothing to upgrade to...right?
    On a similar note, I vaguely remember back when ver 2or 3 of Illustrator
    came out and one could fit graphics(text?) in an envelope. At the time,
    it was a plugin that was subsequently removed.
    For the next 50;) versions I whined about this. Finally, I think it was
    version 9 or 10 that brought this feature back to Illustrator.
    So given that track record, I think we might get it in version 17. Let's
    cross our fingers. ;)

  • How to create a Line JComponent

    Can anybody kindly show me how to create a JComponent which is a line or rectangle?

    As everywhere:
    shift return
    Peter

  • How to get a brush preset to lay behind my picture

    I  have water wing brushes and I want to get the wings behind a person in the picture so that they are not going over the top of the image. I thought it was the "behind " option but I could not get that option to work. Could someone please give me an answer on this.
    Thanx,
    JP

    I tried this method but could could never really get the wings as dark as I wanted The only way I could see to adjust is using opacity on both levels and I could never find the right mix. when the wings wouls start to get as dark as I wanted they would start bleading through. Also I'm sure CS4 or 5 has to be more advanced than this, I just dont know the tricks as I'm a mew learner. I know there is an option on brushes called behind and I think by accident I even got it to work once and it did paint behind and not on the person in the picture. But never again. Also my picture is always locked unless I open it as a smart object, Maybe this is where the problem lies. It is very frustrating, I have come so close to what I want just experimenting. Any further suggestions would be most appreciated. Even help on adjusting the layers.
    JP

  • Cannot paint over a jpeg suddenly, paint shows up behind on same layer

    When i place an image (jpeg) into photoshop and try to paint over it it will not let me. instead it paints behind the jpeg on that layer. Also, if I create a layer mask on the jpeg it will not paint over it to paint out areas.
    It always worked fine, this issue has come up within the last couple weeks.
    Help would be greatly appreciated, thank you.

    Hi artvector99,
    The first thing that comes to mind is that the mode of the Brush Tool is set to something other than Normal in the tool options bar.

  • Know how to change the outline shape of a tooltip?

    Hi All,
    I was wondering if anybody knows how to change the shape of a tooltip popup box?
    I've implemented my own UI delegate for ToolTipUI and overridden the paint( Graphics g, JComponent c ) method which I thought would have allowed me to completely control the rendering of the tooltip, box and all. But what I discovered was that even when I did nothing inside this method, the rectangular popup window was still appearing (I stepped through the code, and the correct instance of UI was being used, not the one that may have been defined by UIManager.set( "ToolTipUI", "foo.Bar" )) After a little more investigation, I ended up in ToolTipManager.showTipWindow() which eventually calls
    PopupFactory popupFactory = PopupFactory.getSharedInstance();
    tipWindow = popupFactory.getPopup(insideComponent, tip, location.x, location.y);
    tipWindow.show();To try to overcome this, as a test I extended JButton with the following constructor:
    public TestButton() {
        super();
        setUI( new MyCustomUI() );
        ToolTipManager.sharedInstance().unregisterComponent( this );
    }but this didn't solve the problem either. Has anybody got any ideas on this?
    Cheers,
    Paul.

    Try this.
    regards,
    Stas
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.awt.geom.*;
    public class Test {
        JScrollPane scroll;
        JPanel p=new JPanel(new BorderLayout());
        Robot robot=new Robot();
        public Test()  throws Exception {
            final JFrame frame=new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add(p);
            JButton b=new JButton("Test balloon!");
            b.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    TransparentFrame frame1=new TransparentFrame();
                    int x=frame.getX()-100;
                    if (x<0) x=0;
                    int y=frame.getY()-100;
                    if (y<0) y=0;
                    frame1.setBounds(x,y,100,100);
                    frame1.createBalloon();
                    frame1.setVisible(true);
            frame.getContentPane().add(b);
            frame.setBounds(200,200,120,50);
            frame.show();
        public static void main(String[] args) throws Exception {
            new Test();
    class TransparentFrame extends JWindow {
        Robot robot;
        BufferedImage screenImg;
        Rectangle screenRect;
        MyPanel contentPanel=new MyPanel();
        boolean userActivate=false;
        Area Balloon;
        public TransparentFrame() {
            super();
            createScreenImage();
            contentPanel.Balloon=Balloon;
            this.setContentPane(contentPanel);
            this.addComponentListener(new ComponentAdapter() {
                public void componentHidden(ComponentEvent e) {}
                public void componentMoved(ComponentEvent e) {
                    resetUnderImg();
                    repaint();
                public void componentResized(ComponentEvent e) {
                    resetUnderImg();
                    repaint();
                public void componentShown(ComponentEvent e) {}
            this.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                public void windowClosed(WindowEvent e) {
                public void windowOpened(WindowEvent e) {
                public void windowIconified(WindowEvent e) {
                public void windowDeiconified(WindowEvent e) {
                public void windowActivated(WindowEvent e) {
                public void windowDeactivated(WindowEvent e) {
                    Balloon=null;
        protected void createScreenImage() {
            try {
                if (robot==null)
                    robot=new Robot();
            catch (AWTException ex) {
                ex.printStackTrace();
            Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
            screenRect=new Rectangle(0,0,screenSize.width,screenSize.height);
            screenImg=robot.createScreenCapture(screenRect);
        public void createBalloon() {
            Rectangle bounds=new Rectangle(0,0,getWidth(),getHeight());
            Balloon=new Area(new Rectangle(bounds));
            System.err.println(Balloon.getBounds());
            RoundRectangle2D content=new RoundRectangle2D.Double(0,0,getWidth(),getHeight()/3,20,20);
            Polygon polygon=new Polygon(new int[] {20,getWidth()/2,getWidth()},new int[] {getHeight()/3,getHeight()/3,getHeight()},3);
            Area a=new Area(new Rectangle(bounds));
            a.subtract(new Area(content));
            a.subtract(new Area(polygon));
            Balloon.subtract(a);
            contentPanel.Balloon=Balloon;
        public void resetUnderImg() {
            if (robot!=null && screenImg!=null) {
                Rectangle frameRect=getBounds();
                int x=frameRect.x;
                contentPanel.paintX=0;
                contentPanel.paintY=0;
                if (x<0) {
                    contentPanel.paintX=-x;
                    x=0;
                int y=frameRect.y;
                if (y<0) {
                    contentPanel.paintY=-y;
                    y=0;
                int w=frameRect.width;
                if (x+w>screenImg.getWidth())
                    w=screenImg.getWidth()-x;
                int h=frameRect.height;
                if (y+h>screenImg.getHeight())
                    h=screenImg.getHeight()-y;
                contentPanel.underFrameImg=screenImg.getSubimage(x,y,w,h);
    class MyPanel extends JPanel {
        BufferedImage underFrameImg;
        Area Balloon;
        int paintX=0;
        int paintY=0;
        public MyPanel() {
            super();
            setOpaque(true);
        public void paint(Graphics g) {
            super.paint(g);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(underFrameImg,paintX,paintY,null);
            if (Balloon!=null) {
                g.setColor(Color.yellow);
                ((Graphics2D)g).fill(Balloon);
            g.setColor(Color.red);
            g.drawString("Balloon test!",10,20);
    }

  • Brush tip icons in CS4 and painting w brush tip icons

    Why in CS4 Photoshop do none of the brush tip  icons paint to the edges of the icon dashed line. They all paint 4 to 5  (etc.) pixels behind the brush tip line. CS2 & 3 painted dead on the  brush dotted line if one desired. Am I missing how to do this??? in  CS4? I am not painting with the soft brush, but the HARD brush. I expect the brush tip icon to show me exactly what area I will paint. Am I wrong???

    Chris, I have looked everywhere in CS4 preferences to adjust the
    "bounds" setting for a brush, but cannot find it. I see the sliders for
    MASTER DIAMETERS of a brush and the HARDNESS of a brush.
    I can't remember ever having to set bounds in previous editions of
    PS, or I could be wrong.
    To be clear on what is happening, if I create a brush that is 110 pixels
    wide w hardness of 100, shouldn't CS4 paint a solid 110 pixel circle,
    exactly within the LIVE brush icon from dotted edge to dotted edge
    of the brush icon? My brushes paint behind the dotted lines.
    This makes me guess where the brush paint lands on the canvas
    within the dotted brush icon.
    Sorry if I am wordy. Just a wierd experience w the brushes in CS4.

  • Who paints the background of JInternalFrame

    Hello all,
    Im new to Swing / plaf, and I have a probably simple question.
    Im trying to make an internal frame that has rounded corners. Therefore I do not want the background color to fill the entire background. Actually I'd like to paint the background myself.
    I have extended and installed my own BasicInternalFrameUI. In installUI(JComponent c) I call c.setOpaque(false). And would now expect to be able to control the painting of the background by overriding BasicInternalFrameUI.paint :
    public void paint(Graphics g, JComponent c) {
    g.setColor(Color.black);
    g.fillRoundRect(0,0, c.getWidth(),c.getHeight(),10,10);
    (Disregard the fact that I paint on top of the title too - this example is only to keep it simple)
    But the JInternalFrame shows it's background color, and not my rect.
    It seems like the only way I can change the painting of the JInternalFrame is by overriding JInternalFrame.paint :
    public void paint(Graphics g) {
    super.paint(g);
    g.setColor(Color.blue);
    g.fillRoundRect(0,0, getWidth(), getHeight(),10,10);
    But that's not really look&feel...
    Could someone please enlighten me? How do I paint the background of an JInternalFrame the proper way?

    Hello all,
    Im new to Swing / plaf, and I have a probably simple question.
    Im trying to make an internal frame that has rounded corners. Therefore I do not want the background color to fill the entire background. Actually I'd like to paint the background myself.
    I have extended and installed my own BasicInternalFrameUI. In installUI(JComponent c) I call c.setOpaque(false). And would now expect to be able to control the painting of the background by overriding BasicInternalFrameUI.paint :
    public void paint(Graphics g, JComponent c) {
    g.setColor(Color.black);
    g.fillRoundRect(0,0, c.getWidth(),c.getHeight(),10,10);
    (Disregard the fact that I paint on top of the title too - this example is only to keep it simple)
    But the JInternalFrame shows it's background color, and not my rect.
    It seems like the only way I can change the painting of the JInternalFrame is by overriding JInternalFrame.paint :
    public void paint(Graphics g) {
    super.paint(g);
    g.setColor(Color.blue);
    g.fillRoundRect(0,0, getWidth(), getHeight(),10,10);
    But that's not really look&feel...
    Could someone please enlighten me? How do I paint the background of an JInternalFrame the proper way?

  • JList paint performance

    Hello all,
    I I have a problem with JList painting.
    I notiched that when I select cell in my list all the visible cells are repainted and not jas the selected cell.
    After debugging I discovered that the paintion is done in the paint methot at the BasicListUI class.
    I have a huge list which can display 100 cells on the screen at the same time and the so when I select one cell the painting causes my cpu usage to be at its maximum.
    Unfortunally I don't know how to rewrite the UI in order to speed up cell painting for only the selected cells.
    I'm using array list a the list model and the JList is configured as followed:
    public class ButtonList extends JList
        public ButtonList()
            super();
            setCellRenderer(createCellRenderer());
            setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            setFixedCellHeight(Drawboard.getShapeHeight());
            setFixedCellWidth(Drawboard.getShapeWidth());
            setLayoutOrientation(HORIZONTAL_WRAP);
            setVisibleRowCount(0);
        protected ListCellRenderer createCellRenderer()
            return new ButtonCellRenderer();
    }The list cell renderer is a JButton component:
    public class ButtonCellRenderer extends JButton implements ListCellRenderer
        public ButtonCellRenderer()
            super();
            setOpaque(true);
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
                String val = value.toString();
                setText(val);
            setSelected(isSelected);
            return this;
        }Any suggestion?
    Thanks in advance,
    Hanoch

    Hi michael,
    I modified your test program so you could see what my problem is.
    I set MyListUI as the ListUI of the ButtonList.
    Now If you'll run the testing program you'll see on the console that when you press the one cell a lot of rows are repainted.
    For example if you press the button with "0" and then the press the button with "47" than all of the cells between them are repainted.
    My application is runnung on VIA800 with 256MB and I have 2 ButtonList like that on the screen so the user can choose Items from that list (This is a touch screen application). All of the unnecessary painting causes the CPU to be at its maximum.
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.event.*;
    import javax.swing.plaf.basic.BasicListUI;
    class Testing extends JFrame
        DefaultListModel listModel = new DefaultListModel();
        ButtonList list = new ButtonList(listModel);
        public Testing()
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            for (int x = 0; x < 200; x++)
                listModel.addElement("" + x);
            JScrollPane sp = new JScrollPane(list);
            sp.setPreferredSize(new Dimension(400, 75));
            getContentPane().add(sp);
            setSize(600, 800);
            setLocationRelativeTo(null);
        public static void main(String[] args)
            new Testing().setVisible(true);
    class ButtonList extends JList
        public ButtonList(ListModel dataModel)
            super(dataModel);
            setCellRenderer(createCellRenderer());
            setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            setFixedCellHeight(90);
            setFixedCellWidth(90);
            setLayoutOrientation(HORIZONTAL_WRAP);
            setVisibleRowCount(0);
            setUI(new MyListUI());
        protected ListCellRenderer createCellRenderer()
            return new ButtonCellRenderer();
    class ButtonCellRenderer extends JButton implements ListCellRenderer
        public ButtonCellRenderer()
            super();
            setOpaque(true);
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
            String val = value.toString();
            setText(val);
            setSelected(isSelected);
            return this;
    class MyListUI extends BasicListUI
        public MyListUI()
            super();
        /* (non-Javadoc)
         * @see javax.swing.plaf.basic.BasicListUI#paint(java.awt.Graphics, javax.swing.JComponent)
        @Override
        public void paint(Graphics g, JComponent c)
            System.out.println("-----------------------");
            super.paint(g, c);
        /* (non-Javadoc)
         * @see javax.swing.plaf.basic.BasicListUI#paintCell(java.awt.Graphics, int, java.awt.Rectangle, javax.swing.ListCellRenderer, javax.swing.ListModel, javax.swing.ListSelectionModel, int)
        @Override
        protected void paintCell(Graphics g, int row, Rectangle rowBounds, ListCellRenderer cellRenderer, ListModel dataModel, ListSelectionModel selModel, int leadIndex)
            System.out.println("Row = " + row);
            super.paintCell(g, row, rowBounds, cellRenderer, dataModel, selModel, leadIndex);
    }

  • How do I determine the size of an event queue?

    Hi,
    I'd like to be able to programmatically determine how many events are in queue so that I can change how they are processed based on how far behind the loop is.
    Is there a way to easily do this in labview? 
    I suppose I could create an identical parallel event loop that just counts the events as they come in, and then subtract the ones that get processed by the main event loop, but it seems like there should be an easier way.
    I'm using LV 8.1
    Thanks,
    Greg

    So you are recomending running two event loops, one waiting for the faster events and one waiting for the slower events?
    I wouldn't put it that way.
    Any event that takes 'long' (eg. a significant amount of time), should be processed in a consumer loop.
    So the event arives in the normal event structure, and is than feed to a consumer loop via a queue.
    In the LabVIEW examples there is a framework example called 'Produces/consumer with events' (or something like that).
    If you have a specific type of event generating very fast and you are only interested in the last a notifier might be usefull.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

Maybe you are looking for

  • Some options are greyed out in Captivate 8.0.1 and my bullets do not work?

    Hi, I am using Captivate 8.0.1 and am having trouble with 2 things: 1. The bullets and indents that I have formated for my responsive project appear very messed up and not as I have formatted when I view my project in Edge Inspect? 2. Some options in

  • Exclude NULL values from SUM and AVG calculation

    Hi, I have column in report that contains some NULL values. When i perform SUM,MAX,MIN or AVG calculation on this column the NULL values are treated as '0' and included in calculation. Is there any way to exclude them while calculating aggregate func

  • Document merge problem due to embedded fonts

    I am trying to merge 6 single page pdf documents into one pdf file. I am receiving this error on two of the six docs: "These documents contain subset fonts that have the same name and cannot be merged" Can anyone help me work through this issue? I am

  • How to give query in lookup type udf in OIM 11g

    Hi, In OIM 9.x, we were able to provide query in lookup type field in users UDF to fetch data from DB and display it in lookup table. Where as in OIM 11g, I cant find that option. We need to provide user id in lookuptype field based on some query. Pl

  • Problem with Merge..Pls help !!!

    MERGE INTO main m USING temp t ON ( t.id = m.id ) WHEN NOT MATCHED THEN UPDATE set m.edate=t.sdate where m.edate is null INSERT (m.id , m.name , m.address , m.sdate , m.edate) VALUES (t.id , t.name , t.address ,t.sdate ,t.edate); When i execute this