Knowing Completion of Repaint

Hi Folks,
I am having a JPanel and I will be adding button to it on the fly
and removing too.
My problem is when I add a button, I want to know the button's width.
This I cannot do because I tried the code in a ContainerListener.containerAdded() and ContainerListener.containerRemoved()
Just after I had added the button and called revalidate() and repaint() on the JPanel.
The width of the just added button I get is 0. I guess it is because my peice of code runs BEFORE the repaint is finished its job.
Am I right? If yes, then how can I know when a component repaint() has finishe doing its job??

<b>Code: </b>
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.util.Vector;
public class ButtonScroller extends JPanel {
     FlowLayout flow = new FlowLayout(FlowLayout.LEFT);
     JPanel rightPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
     JPanel buttonPanel = new JPanel(flow);
     JPanel o1;
     Vector bv = new Vector();
     int buttonGap = 0;
     JButton lb, rb;
     public ButtonScroller() {
          BorderLayout layout = new BorderLayout();
          layout.setVgap(0);
          layout.setHgap(0);
          BorderLayout layout1 = new BorderLayout();
          layout1.setVgap(0);
          layout1.setHgap(0);
          BorderLayout layout2 = new BorderLayout();
          layout2.setVgap(0);
          layout2.setHgap(0);
          BorderLayout layout3 = new BorderLayout();
          layout3.setVgap(0);
          layout3.setHgap(0);
          setLayout(layout);
          flow.setHgap(5);
          buttonGap = flow.getHgap();
          o1 = new JPanel(layout1);
          JPanel i1 = new JPanel(layout2);
          JPanel i2 = new JPanel(layout3);
          o1.add(i1, BorderLayout.CENTER);
          o1.add(i2, BorderLayout.EAST);
          i1.add(buttonPanel, BorderLayout.NORTH);
          i2.add(rightPanel, BorderLayout.NORTH);
          //add(buttonPanel, BorderLayout.CENTER);
          //add(rightPanel, BorderLayout.EAST);
          add(o1, BorderLayout.CENTER);
          rightPanel.setBorder(new SoftBevelBorder(BevelBorder.RAISED));
          buttonPanel.setBorder(new SoftBevelBorder(BevelBorder.RAISED));
          setup();
          buttonPanel.addContainerListener(new ContainerListener() {
               public void componentAdded(ContainerEvent ce) {
                    areBMTA();     
               public void componentRemoved(ContainerEvent ce) {
                    areBMTA();
     void setup() {
          lb = new JButton("L");
          rightPanel.add(lb);
          rb = new JButton("R");
          rightPanel.add(rb);
          lb.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent ae) {
                    System.out.println("Left Button Clicked");
          rb.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent ae) {
                    System.out.println("Right Button Clicked");
          rb.addMouseListener(new MouseAdapter() {
               public void mouseClicked(MouseEvent me) {
                    if (SwingUtilities.isRightMouseButton(me)) {
                         System.out.println("Right Click on right button");
                         JButton button = new JButton("(- " + (bv.size() + 10) + "-)");
                         //button.setBorder(new EmptyBorder(0,0,0,0));
                         buttonPanel.add(button);
                         button.addComponentListener(new ComponentAdapter() {
                              public void componentShown(ComponentEvent ce) {
                                   System.out.println("The button is now visible");
                         bv.add(button);
                         buttonPanel.revalidate();
                         buttonPanel.repaint(0);
          lb.addMouseListener(new MouseAdapter() {
               public void mouseClicked(MouseEvent me) {
                    if (SwingUtilities.isRightMouseButton(me)) {
                         System.out.println("Right Click on left button");
                         int size = bv.size();
                         if (size == 0) return;
                         JButton button = (JButton) bv.elementAt(0);
                         buttonPanel.remove(button);
                         bv.remove(button);
                         buttonPanel.revalidate();
                         buttonPanel.repaint(0);
     private boolean areBMTA() {
          int pWidth = buttonPanel.getSize().width;
          int bWidth = 0;
          int totButtons = buttonPanel.getComponentCount();
          int totalButtonWidth = 0;
          if (totButtons ==0 ) return false;
          for(int i=0; i<totButtons; i++) {
               JButton button = (JButton)buttonPanel.getComponent(i);
               System.out.println("The Width of the button at [" + i +"] is " + button.getWidth());
               if (button.isVisible()) {
                    //bWidth = button.getSize().width;
                    bWidth = button.getWidth();
                    System.out.println("We found a button that was visible and its width is " + bWidth);
                    break;
          System.out.println("Button Gap :" + buttonGap);
          System.out.println("Button Width :" + bWidth);
          int extraWidth = (totButtons + 1) * buttonGap;
          totalButtonWidth += extraWidth;
          totalButtonWidth += (totButtons * bWidth);
          System.out.println("TBW:" + totalButtonWidth + "And Panel Width: " + pWidth);
          System.out.println("Right Panel Width is " + rightPanel.getSize().width);
          System.out.println("o1 Panel Width is " + o1.getSize().width);
          if (totalButtonWidth > pWidth)
               return true;
          else
               return false;
     private boolean scroll(char ch) {
          return false;

Similar Messages

  • I wan to know complete process(business) in procurement area in SCM

    Hi,
    I want to know complete business process in procurement area in SCM.
    Thanks in advance,
    ravi.

    hi ravi,
    Food & Beverages Industry Business Processes
    Procurement & Supply Chain:
    Raw Materials Procurement
    Machinery Procurement
    Food / Beverages Manufacturing:
    Food Preparations Operations
    Quality Control
    Storage & Inventory Control:
    Specialised Storage for Perishable Items
    Inventory Management
    Distribution:
    Transportation
    Sales & Channel Management:
    Order Processing & Fulfilment
    Marketing Management
    Retail Sales Monitoring & Management
    In-store Exposure Management
    Strategy:
    Marketing & Competitor Intelligence Gathering
    Web & E-commerce Strategy
    Daily, Weekly & Monthly
    SAP for Retail supports the following business process categories for food retailers:
    Category and merchandise management-- Manage consumer-driven categories as strategic business units and gain efficiencies in areas such as category and assortment planning, allocations, and item management. Solutions support a full range of processes, including category strategy roll-out and scorecard review, key item planning, image items new product introduction, and SKU rationalization.
    Buying and vendor management -- Strengthen supplier relationship management and overall operational procurement to optimize supplier selection, compress cycle times, and devise sourcing and purchasing strategies. Solutions support a broad range of purchasing activities, including perishable management, private label management, vendor managed inventory, purchase order management, self service, forward and line buying, and invoice matching.
    Revenue management -- Execute the pricing strategies needed to achieve your profitability goals through cost management, optimization and demand creation, and price management. Solutions support base price optimization, demand forecasting, markdown optimization, retail price management and execution, promotions management, clearance management, and total landed cost, deal, and rebate management.
    Supply chain management -- Optimize supply chain planning, execution, and monitoring to streamline your merchandise flow, reduce out-of-stock situations, and balance out your inventory. Solutions enable private label production, perishable planning, collaborative planning forecast and replenishment, available to promise, warehouse and yard management, transportation planning, reverse logistics, global import management, and supply chain visibility and tracking.
    Store and channel management -- Enhance customer relationship management, store operations, workforce management, and point of sale to offer the best services through different channels. Solutions support key multi channel retail activities, including customer segmentation, market basket analysis, alternative store sourcing, custom order management, returns authorization, store level inventory management, mobile checkout, and labor scheduling.
    Enterprise management and support -- Solve business issues in real-time on both a strategic and an operational level -- and gain control of business processes and assets -- through functionality for finance, human capital management, and corporate services. Solutions support key processes, including financial and management accounting, corporate governance, real estate management, payroll and benefits administration, workforce management, life cycle data management, and enterprise asset management.
    Visit the followingl links:
    http://www.spesfeed.co.za/Supply%20Chain%20Management.htm
    http://www.ebpo.in/ind/food/food.html
    http://www.sap.com/usa/industries/retail/businessprocesses/food/index.epx
    Regards,
    partha

  • Who knows why the "repaint()"doesn't work when ....?

    I use a "while(threadgroup.activeCount()!=0){} "to block the sentence below
    from being excecuted before I finish the thread above, however since this "while"
    the repaint() in the thread above doesn't work , but I have evidence that the thread
    is really going on ( I use Sytem.out.print() to prove this)

    I'm not sure I follow. Try providing a snippet of the relevant code, and we'll see if anybody on the forum can figure it out for you.

  • Need to know completly safe way to flash bios plz! (I have mobile chip!)

    I want to flash to the newest bios because they fully support mobile chips I heard. I'm pretty sure flashing with a floppy drive would be best.(i also have a usb pen drive, would this work?) How can I flash so that if something does go wrong I can easily go back to the bios that was just in it? Because I want to be sure it will run with my mobile chip. Thanks.

    Quote
    Originally posted by WhatTheSchmidt
    yea I wish I had dual bios  
    Did you ever sort a BIOS savior out for this mothererbaord?
    I read down here..
    One more suggestion, if you are going to play with different bios get a bios savior.I had one from my DFI mb so I switched it over as soon as I got my MSI K8N Neo platinum
    I am going to assume that it must work, and is prolly the RD1-PMC4 Bios Savior as that fits the DFI Nforce2 board.
    I have just sent http://www.ioss.com.tw/eg/index.html an e-mail, and see what they have to say.
    Will prolly ask thet guy on amdmb.com to be sure.

  • How to know the current Task/Job ID in which a request is waiting for

    Hi Team,
    Is there any table/view in IDM 7.2 that provides current task/job ID number a request is waiting for?
    Even though the last completed phase of the request can be seen from admin UI that only shows the description of the completed steps but not the technical details like task ID/Job ID of the current step.
    Knowing the current step/Job ID helps the admin a lot to directly go the step when the request is waiting for long/got failed etc..
    Regards,
    Venkata Bavirisetty

    Hi Matt,
    Thanks for your response.
    I read few articles in your blog couple of weeks before and they are very much informative.
    The information provided in the provisioning queue just shows the task ID and no.of requests (without request nos) waiting in that task.
    Basically the question I have mentioned in my previous post is not related to any specific task type. It is like using request no we wanted to know complete request history specially the current task (task ID) at which the request is waiting for.
    Regards,
    Venkata Bavirisetty

  • Want to complete information about Generic WHT report-S_P00_07000134

    Hi Experts,
    I want to know complete information about Generic WHT report-S_P00_07000134
    My following questions
    1) Once executed report,why it is asking addition selection like address and more informaiton and where it will help.
    2)Why is asking for variant,if click on yes,what will happen
    3) Selected "always allow in the context"option and seen the file in c:\drive.Butnot able to understand the format.What is this and for change allow option in future,what can i do?
    Please help.
    Regards,
    Kishore.J

    Hi,
    Check whether you have maintained Tax ID in T.Code J1ID Vendor Excise details.
    Regards,

  • Slowness in repainting and scrolling

    OK. I probably know everything about repainting and paint that you know. Just trust me there :). so this isn't a newbie "why is my redraw slow" question. I am interested to hear from anyone who has noticed this or who, after reading this, notices that it explains their situation.
    First I'll give you the symptom, then I'll give you the cure for the symptom then I'll ask about the disease, then present some evidence that it's not such a simple problem.
    Symptom- very slow redrawing and scrolling.
    Cure- stop running certain other programs which are essentially non-malware TSRs (Terminate and Stay Resident) programs. In my particular case, its FastStone's capture utility but I am pretty sure it's not specific to that program.
    The disease- it only manifests itself while doing plain old launches from the development environment - in other words, write any simple GUI app in your development environment and launch it while running the TSR, as opposed to say, java programs like IntelliJ or Netbeans which have full installers etc. It does effect FreeMind however.
    Some clues:
    I have to say it's not the amount of memory, since the smallest GUI tester program run via a PSVM (public static void main) will elicit the effect and anyways my machine has a disgusting amount of RAM.
    The effect of closing (or opening the TSR) is instantaneous. There's a clear cause and effect at work.
    It does not effect Netbeans that I can tell nor IntelliJ (just to stay concrete). It devastates FreeMind and any stupid little GUI tester, as I said.
    It does not effect non- Java programs.
    So here is my thinking. Suppose there's something that windows programs can tap into- some resource, function call, whatever, that has the side effect (MS would never do this deliberately) of really undermining the Java VM in some way or forcing resources away from it.. it feels like a resource starvation scenario of some sort-- either CPU or RAM or thread priority or whatever.
    On top of the why does this happen question, there's the why are some Java programs immune question. It makes me think there's something about the way those programs are installed or launched that's different from the plain old PSVM that makes them immune. AFAIK, PSVM is how things are ultimately launched in Java, period, after all the scripts and whatever have run.
    So I am asking
    does anyone notice this themselves?
    is this a well known problem that other people know the solution to and understand?
    now that I've described it in the way I have, does it shed light on any mysteries that anyone else has?
    Really just trying to spark a discussion / line of investigation.
    many thanks.

    So here is my thinking. Suppose there's something that windows programs can tap into- some resource, function call, whatever, that has the side effect (MS would never do this deliberately) of really undermining the Java VM in some way or forcing resources away from it.. it feels like a resource starvation scenario of some sort-- either CPU or RAM or thread priority or whatever.
    I love a good conspiracy theory as much as anyone, and MS being the butt of the folly makes it even better, but I don't think so. I have not noticed that my Java applications over the last 10 years have been affected any more or less than any "native code application" (such as those developed in C/C++ or .Net and compiled specifically for the MS environment.
    On top of the why does this happen question, there's the why are some Java programs immune question. It makes me think there's something about the way those programs are installed or launched that's different from the plain old PSVM that makes them immune. AFAIK, PSVM is how things are ultimately launched in Java, period, after all the scripts and whatever have run.
    I would have to say, some Java applications are immune probably because their structure is better for that specific environment.
    So I am asking
    does anyone notice this themselves?
    My system degradations seem to be non-discriminatory and even several of the MS products suffer way more than any of the Java based applications.
    is this a well known problem that other people know the solution to and understand?
    now that I've described it in the way I have, does it shed light on any mysteries that anyone else has?
    Not really, the MS bloat-ware that I run seem to suffer the symptoms you have described too. As do other companies' products equally.
    I had part of the problem explained to me one time by a Senior Engineer from Digital, concerning OLE: You have a cooperative interface standard that asks one company to expose their proprietary interfaces so other companies can gain from their use. Not everyone will share nor will what they share always be totally accurate. It's just not viewed as being in their best interest to give it all away.

  • Repainting with custom TreeModel

    I have created my own class implementing TreeModel, and it works okay most of the time. My problem is that when I change the model, I don't know how to repaint the tree to show the changes. I have tried many solutions but cannot find one that works. I need a solution with the same functionality of reload() in DefaultTreeModel. Any help would be appreciated.

    The tree registers by your model as a TreeModelListener and expects you to fire a TreeModelEvent events whenever the model changes. When the tree receives an event, it should correctly repaint. You probably don't fire these events. Look into the DefaultTreeModel class, there are fireXXX()methods that solve that.

  • Repainting swing components

    I have some radio buttons which I change the labels of, but I don't know how to repaint them so the new labels show up.
    I've tried getContentPane().repaint();
    but that doesn't work.
    Any help would be much appreciated.
    Thanks for looking

    I guess I don't understand the question because you don't do anything special, just use the setText() method. Here's the code I used to test:
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class RadioButtonTest extends JFrame
         public RadioButtonTest()
              JPanel panel = new JPanel();
              getContentPane().add( panel );
              final JRadioButton radioButton = new JRadioButton( "Open" );
              panel.add( radioButton );
              JRadioButton radioButton2 = new JRadioButton( "Close" );
              panel.add( radioButton2 );
              radioButton2.setEnabled( false );
              JButton button = new JButton( "Reset Label" );
              button.addActionListener( new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        radioButton.setText( new Date().toString() );
                        pack();
              getContentPane().add( button, BorderLayout.SOUTH );
         public static void main(String[] args)
              RadioButtonTest frame = new RadioButtonTest();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
    }If you're asking how to resize the frame to reflect the new size of the text then don't forget the pack() method.

  • Vague problem description, looking for hints

    Hello,
    I am maintaining several Swing based apps, written by a number of different people (different generations, skills and knowledge) of which most of them are gone already. There's this user reported bug which clearly describes his problem, but as it occurs intermittently, is so for impossible for me to reproduce. (I guess I could leave it at that, not reproduced).
    While a JFrame is showing JTabbedPane with several tabs, some work is being done on a fresh Thread. That thread may occasionally (in error/unexpected situations) pop up a dialog using JOptionPane.confirmDialog. The reported problem is that the text in the pop up is at times not visible while a specific tab in the frame is visible, the problem "never" occurs while other tabs are active. Of course the tab that is related to the problem is one which holds a component for which paintComponent() is custom.
    Clearly this is a messy situation. I hoped that describing it would clarify something for myself and if not, any one of you could offer me hints and experiences where to start looking.
    So far (being unable to reproduce and see "it" happen) I have taken the angle of hunting for usual suspects in the code: Threading, EDT, paint() vs repaint() but I am sort of at the end of my list.
    Thanks in advance.

    It could be an exception as you suggest:
    One thing I found so far is a ConcurrentModificationException on an AWT thread. Our code causing it has been corrected in that respect: the paintComponent iterated a List while other threads would try to clear or add to that same List. My solution is to take a local snapshot of the now SynchonizedList before passing the local list to the paint.     As i still am unable to reproduce the problem, I cannot confirm this "fixed" it. Do we know that if the paint thread excepts (on the said Concurrent mod exception, CME), all pending paints will be lost? If so, it is quite likely the cause of the user problem: both my custom paint panel and the dialog have a repaint pending, the repaint starts executing and exepts in the custom paint with the CME and the dialog never receives the text.
    If the above is a valid scenario, would the following then work? If the user sees an empty Dialog, move the dialog around such that it becomes hidded or resize it to cause a repaint and then see the text appear?
    I wrote this SSCE for the scenario above, but it does not give the problem. This may mean that program is just not good enough, although I altered the flow and timings to provoke Swing/AWT several times. Or perhaps the problem disappeared since we switched to JRE 1.6.0.17 (I believe at the time of reporting, we were still 1.5 something).
    package esa.isoc.oss.gui;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    import javax.swing.SwingWorker;
    import javax.swing.Timer;
    public class PossibleCauseSPR1044 extends JFrame {
         private ExceptInPaint customPaint = new ExceptInPaint();
         private JButton workButton;
         public PossibleCauseSPR1044() {
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel panel = new JPanel();
              panel.setLayout(new BorderLayout());
              panel.add(new JLabel("<html><b>SPR 1044</b>: " +
                        "In OSS, it is possible to view the scheduling for a revolution either " +
                        "as a horizontal bar chart on a timeline: the schedule display, or as " +
                        "pointings and slews overlaid on the sky: the sky display. When the " +
                        "system is actively scheduling, popup messages sometimes appear to warn " +
                        "about long slews, visibility constraints, not enough time to finish an " +
                        "observation, etc. While these messages appear normally when the revolution " +
                        "is viewed in the schedule display, when it is viewed using the sky display, the " +
                        "box of the popup message appears but the contents, i.e. the text, do not. This " +
                        "happens for all popups and happens every time, at least on the operational system. " +
                        "Moreover, the window does not refresh itself even if we wait for a long time.</html>")
                   , BorderLayout.CENTER);
              panel.add(customPaint, BorderLayout.NORTH);
              panel.add(getWorkButton(), BorderLayout.SOUTH);
              panel.setPreferredSize(new Dimension(500, 300));
              getContentPane().add(panel);
              pack();
         JButton getWorkButton() {
              if (workButton == null) {
                   workButton = new JButton("Except!");
                   workButton.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                             new SwingWorker<Void, Void> (){
                                  @Override
                                  protected Void doInBackground() throws Exception {
                                       Timer t = new Timer(150, new ActionListener() {
                                            @Override
                                            public void actionPerformed(ActionEvent e) {
                                                 customPaint.repaint();
                                       t.start();
                                       customPaint.setExcept(2);
                                       Thread.yield();
                                       int r = JOptionPane.showConfirmDialog(null
                                                 , "Clear the exception and you see this text? ("+customPaint.except+")"
                                                 , "Help us"
                                                 , JOptionPane.YES_NO_OPTION);
                                       if (r == JOptionPane.YES_OPTION) {
                                            customPaint.setExcept(0);
                                       t.stop();
                                       return null;
                             }.execute();
              return workButton;
         public static class ExceptInPaint extends JLabel {
              private volatile int except = 0;
              public ExceptInPaint() {
                   setText("Complete paint");
              @Override
              protected void paintComponent(Graphics g) {
                   super.paintComponent(g);
                   if (except > 0) {
                        except -= 1;
                        if (except ==0) {
                             throw new RuntimeException("Purposely throwing this");
              public void setExcept(int except) {
                   this.except = except;
                   if (except > 0) {
                        setText("Except in paint " + except);
                   }else {
                        setText("Complete paint");
                   repaint();
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   @Override
                   public void run() {
                        new PossibleCauseSPR1044().setVisible(true);
         Edited by: isocdev_mb on May 13, 2010 7:15 AM

  • Garbage collector and JPEG decoder

    Hi,
    I have a problem with the garbage collector decoding JPEG images received on a TCP socket. The process works but each time that I have to decode an image I have to create a new decoder, this causes that the garbage collector starts to work constantly looking for memory. When the gc starts to work the streamed images almost stop since the gc takes all the process.
    Here is the code that has the problem. On this code you can see that I create a new ByteArrayInputStream and a MediaTracker, but I know how reuse this objets, the problem is on the decoder.
    Does any one have an idea of how to solve it?
    Thanks
    public void cargarImagen(Visualizador vision,
                                  Cabecera cabImg,
                                  boolean completa,
                                  boolean grabar,
                                  boolean pantCIF,
                                  JFrame1 jf1)throws Exception{
            Visualizador aux;
            ByteArrayInputStream byis = new ByteArrayInputStream(s1.buffer);
            try{
                    decoder=JPEGCodec.createJPEGDecoder(byis);
                    try{
                           // decode
                                                   vision.image_Webcam=decoder.decodeAsBufferedImage();
                    }catch(ImageFormatException b){
                      System.out.println("Incorrect image format");
                    }catch(Exception a){
                      System.out.println("Incorrect image");
                    mediaTracker_track = new MediaTracker(vision);
                    mediaTracker_track.addImage(vision.image_Webcam, 0);
                 mediaTracker_track.waitForID(0,500);
            }finally{
                      byis.close();
            if(mediaTracker_track.statusID(0, false) == MediaTracker.COMPLETE){
                  vision.repaint();
             else{    /* incorrect image */
                  vision.image_Webcam = null;
                  System.out.println("Discarded image");
    }

    I think that this is not the case. Images come from a TCP connection and the application start to read the next image from the socket when the previous one has been decoded and painted.
    So, images are not stored on memory and the received images rate depens on how fast is the application reading images from the socket.
    However, it is a good idea to start gc before getting next image, the average rate will decrease but it will avoid the "jumps" on visualization.

  • Problems diplaying image on double buffered Panel

    Hello, I made a very simple image visualizer using double buffer. I load the images using ImageIO.read(File file) and display the image on the Panel by drawing it first to a buffer Image using a buffer Graphics, and then painting the buffer Image on the Panel surface. The problem is: sometimes the images are not dislplayed completely, and repainting again by calling repaint() does not work, it`s only displayed correctly if I try to resize the window. When I do the resizeing the paint function is called by a function other then repaint(), update(Graphics g) and paintComponents(Graphics g), and, this time, the paint() display the image correctly.
    What should I do to always display the entire image? I apreciate any help.
    Thankyou. Gustavo Peixoto
    The code:
    import java.awt.Graphics;
    import java.awt.Panel;
    import java.awt.image.BufferedImage;
    public abstract class BufferGraphicsPanel extends Panel {
         private Graphics bufferGraphics;
         private BufferedImage bufferImage;
         private int bufferWidth;
         private int bufferHeight;
         public BufferGraphicsPanel() {
         public void resetBuffer() {
              bufferWidth = getWidth();
              bufferHeight = getHeight();
              if (bufferGraphics != null) {
                   bufferGraphics.dispose();
                   bufferGraphics = null;
              if (bufferImage != null) {
                   bufferImage.flush();
                   bufferImage = null;
              System.gc();
              bufferImage = (BufferedImage) createImage(bufferWidth, bufferHeight);
              bufferGraphics = bufferImage.getGraphics();
         public void paint(Graphics g) {
              System.out.println("paint");
              if (bufferWidth != getWidth() || bufferHeight != getHeight()
                        || bufferImage == null || bufferGraphics == null) {
                   resetBuffer();
              bufferGraphics.clearRect(0, 0, bufferWidth, bufferHeight);
              paintBuffer(bufferGraphics);
              g.drawImage(bufferImage, 0, 0, this);
         public void update(Graphics g) {
              System.out.println("update");
              paint(g);
         public void repaint(){
              System.out.println("repaint");
              super.repaint();
         public abstract void paintBuffer(Graphics bufg);
    import java.awt.Frame;
    import java.awt.Graphics;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    public class VisualisadorDeImagens extends BufferGraphicsPanel {
         BufferedImage image;
         Frame frame;
         String dirPath;
         String fileNames[];
         int x, y;
         int pos;
         public static void main(String[] args) {
              new VisualisadorDeImagens(
                        "C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\Sample Pictures");
         public VisualisadorDeImagens(String dirPath) {
              this.dirPath = dirPath;
              fileNames = new File(dirPath).list();
              frame = new Frame();
              frame.setSize(400, 200);
              frame.add(this);
              frame.addKeyListener(new KeyAdapter() {
                   public void keyPressed(KeyEvent e) {
                        if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                             visualisar();
                        super.keyPressed(e);
              frame.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                        super.windowClosing(e);
                        frame.dispose();
                        System.gc();
                        System.exit(0);
              pos = 1;
              frame.setVisible(true);
         public void visualisar() {
              if (loadImage(dirPath + "\\" + fileNames[pos - 1])) {
                   frame.setSize(image.getWidth(), image.getHeight() + 30);
              } else {
                   frame.setSize(400, 200);
              frame.setTitle(fileNames[pos - 1]);
              pos = (pos % fileNames.length) + 1;
              repaint();
         public void paintBuffer(Graphics bufg) {
              if (image != null) {
                   x = (frame.getWidth() / 2) - (image.getWidth() / 2);
                   y = (frame.getHeight() / 2) - (image.getHeight() / 2);
                   bufg.drawImage(image, x, y, this);
              } else
                   bufg.drawString("Imagem indispon�vel", 130, 100);
         public boolean loadImage(String path) {
              try {
                   image = ImageIO.read(new File(path));
              } catch (IOException e) {
                   e.printStackTrace();
              if (image != null)
                   return true;
              return false;
    }

    Hi camickr, thanks for the tip, I understood the approach used, but it`s different of mine. I know that what I`m doing works, I think I`m missing something. Thankyou.
    ps. here is the code formated correctly:
    import java.awt.Frame;
    import java.awt.Graphics;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    public class VisualisadorDeImagens extends BufferGraphicsPanel {
         BufferedImage image;
         Frame frame;
         String dirPath;
         String fileNames[];
         int x, y;
         int pos;
         public static void main(String[] args) {
              new VisualisadorDeImagens(
                        "C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\Sample Pictures");
         public VisualisadorDeImagens(String dirPath) {
              this.dirPath = dirPath;
              fileNames = new File(dirPath).list();
              frame = new Frame();
              frame.setSize(400, 200);
              frame.add(this);
              frame.addKeyListener(new KeyAdapter() {
                   public void keyPressed(KeyEvent e) {
                        if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                             visualisar();
                        super.keyPressed(e);
              frame.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                        super.windowClosing(e);
                        frame.dispose();
                        System.gc();
                        System.exit(0);
              pos = 1;
              frame.setVisible(true);
         public void visualisar() {
              if (loadImage(dirPath + "\\" + fileNames[pos - 1])) {
                   frame.setSize(image.getWidth(), image.getHeight());
              } else {
                   frame.setSize(400, 200);
              frame.setTitle(fileNames[pos - 1]);
              pos = (pos % fileNames.length) + 1;
              repaint();
         public void paintBuffer(Graphics bufg) {
              if (image != null) {
                   x = (frame.getWidth() / 2) - (image.getWidth() / 2);
                   y = (frame.getHeight() / 2) - (image.getHeight() / 2);
                   bufg.drawImage(image, x, y, this);
              } else
                   bufg.drawString("Imagem indispon�vel", 130, 100);
         public boolean loadImage(String path) {
              try {
                   image = ImageIO.read(new File(path));
              } catch (IOException e) {
                   e.printStackTrace();
              if (image != null)
                   return true;
              return false;
    import java.awt.Graphics;
    import java.awt.Panel;
    import java.awt.image.BufferedImage;
    public abstract class BufferGraphicsPanel extends Panel {
         private Graphics bufferGraphics;
         private BufferedImage bufferImage;
         private int bufferWidth;
         private int bufferHeight;
         public BufferGraphicsPanel() {
         public void resetBuffer() {
              bufferWidth = getWidth();
              bufferHeight = getHeight();
              if (bufferGraphics != null) {
                   bufferGraphics.dispose();
                   bufferGraphics = null;
              if (bufferImage != null) {
                   bufferImage.flush();
                   bufferImage = null;
              System.gc();
              bufferImage = (BufferedImage) createImage(bufferWidth, bufferHeight);
              bufferGraphics = bufferImage.getGraphics();
         public void paint(Graphics g) {
              System.out.println("paint");
              if (bufferWidth != getWidth() || bufferHeight != getHeight()
                        || bufferImage == null || bufferGraphics == null) {
                   resetBuffer();
              bufferGraphics.clearRect(0, 0, bufferWidth, bufferHeight);
              paintBuffer(bufferGraphics);
              g.drawImage(bufferImage, 0, 0, this);
         public void update(Graphics g) {
              System.out.println("update");
              paint(g);
         public void repaint(){
              System.out.println("repaint");
              super.repaint();
         public abstract void paintBuffer(Graphics bufg);
    }

  • How to use open query in oracle select statement

    hi i have a requirement like this. I need to use the output of a procedure ( pl/sql table ) in developing a report
    like  (  SELECT * FROM <procedure name >)
    please help me.

    You can do it by using classic report but I can't tell you without knowing complete detail. If possible can you post your procedure query which you want to use to create report.
    Thanks
    Lakshmi

  • Transfer sales orders from one compnay code to another

    Hi
    Is it possible to transfer pending sales order from one company code to another? if yes please let me know complete procedure.
    thanks
    Sanjay

    Hi,
    You cannot transfer the sales order like this.If your company is getting closed then you can keep a deadline date before which you can close all the open orders and after that you can start creating the orders in the new company code.
    If your delivery date is beyond the deadline date then you can reject the sales orders and create them with new G/L accounts from the new company code.
    For this,you have to assign your sales organisation to the new company code.
    Reward points if it helps.
    Regards
    Karan

  • HP update of Realtek HD audio SP64224 version. 6.0.1.7071 fails -5009 : 0x8002802b

    Hi,
    Just got ouf of the box HP Pavilion 15-n056so.
    EDIT: product number F4C38EA#UUW
    All windows 8.0 updates available was installed, then 8.1 windows update was installed.
    Origin and battlefield4 was installed.
    I used HP Support Assistance to install those drivers and programs it suggested but ran into problems with Realtek update SP64224. This fails. I tried to find more details but none in event viewer.
    Did some searching and found from HP sites the same driver package separately downloadable.
    http://h10025.www1.hp.com/ewfrf/wc/softwareDownloa​dIndex?cc=fi&lc=en&dlc=fi&softwareitem=ob-125625-1
    When I tried to install this manually (not using HP Support Assistant), I got error:
    Virhekoodi: -5009 : 0x8002802b
    Virheilmoitus:
    >Ctor\ObjectWrapper.cpp (163)
    >Ctor\ObjectWrapper.cpp (402)
    >Kernel\Component.cpp (1163)
    >Kernel\CABFile.cpp (389)
    >SetupDLL\SetupDLL.cpp (1541)
    pAPP:Realtek High Definition Audio Driver
    PVENDOR:Realtek Semiconductor Corp.
    PGUID:f132af7f-7bca-4ede-8a7c-958108fe7dbc
    $11.50.0.42618
    @Windows   (9200) BT_OTHER 546.548
    Did some searching again and found some discussions where realtek hd audio should be uninstalled from the Programs and Features. Did that , rebooted, tried again installing through HP Support Assistance + manually and faced same problem again.
    I tried renaming folders:
    C:\Program Files\Realtek -> C:\Program Files\Realtek_old
    C:\Program Files (x86)\Realtek\Audio -> C:\Program Files (x86)\Realtek\Audio_old
    änd then running installation manually again. Same problem.
    I know what error code means, but why it appears is mystery as well as how it could be installed successfully.
    I am also little worried, that when and if the update is done I might face other issues like:
    http://h30434.www3.hp.com/t5/Notebook-Display-and-​Video/video-driver-stopped-responding/td-p/3270697​...
    I do not know completely what benefit it brings to update the driver to the one suggested by HP support Assistance. It is purely annoying that I can't get the update done as there should not be anything disturbing the installation + the exclamaison mark is extremely annoying as well.
    has anyone else had this kind of problem?
    Any ideas how to resolve the problem?
    Thank you for assistance.

    1stHP
    please deactivate Virusscanner for uninstall and Install for every driver
    Check your Bios Version push Start-Run  Msinfo32.exe
    New Bios Version  is F.12
    http://ftp.hp.com/pub/softpaq/sp64001-64500/sp6448​0.exe
    please deactivate Virusscanner for install
    Realtek HD download
    http://www.realtek.com.tw/downloads/downloadsView.​aspx?Langid=1&PNid=14&PFid=24&Level=4&Conn=3&DownT​...
    AMD Graphics Driver
    First uninstall the old reboot and install the new
    http://ftp.hp.com/pub/softpaq/sp64001-64500/sp6421​8.exe
    Test the new driver
    ftp://15.192.45.22/ftp1/pub/softpaq/sp64501-65000/​sp64660.exe
    Say thanks by clicking the "Kudos! Star" which is on the left.
    Make it easier for other people to find solutions, by marking my answer with "Accept as Solution" if it solves your issue.

Maybe you are looking for

  • Transaction FB50L - Item as profit center display General Ledger

    Hi Dears, I am running transaction FB50L, and fill lines, but a item has profit center, other is blank, when saves document, in data entry view, field Profit Center line 1 is blank (OK), and line 2 is filled, but in display General Ledger is filled t

  • File to JDBC scenario error

    hi , I am getting an error like "Error while parsing or executing XML-SQL document: Error processing request in sax parser: Error when executing statement for table/stored proc. 'ADDRESS' (structure 'insert'): java.sql.SQLException: XXXXXX: integrity

  • My mac's sound system seems to be having problems.

    I can't seem to adjust it from the keyoard shortcuts usin f10,11 and 12. The only way i can adjust them is by going into the sound part of system preferences.

  • THE REDEMPTION CODE IS NOT WORKING  ..... WHY  ?

    `why  wont the redemption code work ?  i put it in and than put in the code and it comes back the code is not good  ...

  • Need Pages or Word for MacBook Pro w/ SL OS 10.6.x

    I am a new Mac user and purchased a used macbook for my daughter. It has SL 10.6.x. I want to load Pages but the OS is too old for the version that is available to buy. How can I upgrade the OS? Or is there an older version of Pages (or Word) I can u