Question on repaint

hi,
i made this code to print numbers from 1 to 10 in an applet....
import java.applet.*;
import java.awt.*;
public class appmt extends Applet
public void paint(Graphics g)
g.drawString("applet demo",40,50);
try{
for(int i=0;i<10;i++)
String st = Integer.toString(i);
g.drawString(st,80,80);
Thread.sleep(1000);
repaint();
catch(InterruptedException e){}
/* <applet code="appmt" width=640 height=480> </applet> */the program compiles and runs in appletviewer but the number over-write on each other....why isnt repaint() working and painting the string afresh?

baftos wrote:
I checked and super.paint() ends up executing Container.paint(), which:
Paints the container. This forwards the paint to any lightweight components that are children of this container. If this method is reimplemented, super.paint(g) should be called so that lightweight components are properly rendered. If a child component is entirely clipped by the current clipping setting in g, paint() will not be forwarded to that child.i could merely grasp the essence of your explaination- that something which should be forwarded and transmitted is not being transmitted.
...but what is clipping?
...which is the child or derived class of container class here?...it should be unboubtly the applet class. so is it that something "bad" is happening when the method is re-implemented? is it that the "erase" information is not reaching the child of container?

Similar Messages

  • Graphics question. paint(), repaint(), update()

    Hi
    I have a GUI which consists of swing components and I want to paint onto them. For example if somebody select a component I want to paint a rectangle around it.
    The select event stores the component in a variable and calls repaint(). This shoul call paint() which looks like this:
    public void paint( graphics g){
    draw the rectangle
    super.paint(g);
    The rectangle is actually painted for half a second. Then it is gone again. I want to have it painted permanentely. Why is the rectangle erased after that? Is it because of the update() method?
    I tried to overwrite the update method with a plain method:
    public void update(graphics g) { }
    it didnt do anything.
    Another question. I have to paint differnt stuff regarding what events are thrown. Is it a good programming style to put all the draw stuff into the paint method and look what happend like:
    if(event a)
    else if(event b)
    ...

    Have you tried putting super.paint(g) before the code to draw the rectangle? I think what's happening is that the super's paint is drawing the component, thus erasing your rectangle.
    You may want to check the API for other options. There may be a property that indicates the size and color of a border. It would be easier and probably look better to adjust that, if it exists.
    I believe that update() draws a background (just a square of background color) and then calls paint(). If you override it with an empty method, I'd expect that nothing would be drawn.

  • Is repainting atomic?

    Hello all,
    I've got a few general questions regarding repainting. These are to do with a bug I've been assigned at work. I've been sent an image where a button has a half red half green background. This is a standard JButton and background changes are made through setBackground(Color) calls. The scenario that surrounds this is like so:
    1. Button green.
    2. A message gets pushed to the client app (non-EDT), which does 2 things: makes the button green, and creates a modal dialogue. (All GUI work done on the EDT though).
    3. Now we see a modal dialogue to the right of a half green half red button in the parent frame.
    My questions are:
    1. Is it possible to someway interrupt repainting?
    2. How does repainting of components occur? Left-to-right top-to-bottom, or top-to-bottom left-to-right?
    3. How can such a thing occur? :)
    Things to note:
    1. I can't reproduce this problem. (To me this normally spells threading issue).
    2. No Exception has been thrown. The logs indicate this.
    3. Not that this means a great deal, but I've been programming with Swing for a while now and I've never seen anything like this before!
    Any comments, questions, answers appreciated!
    Thanks,
    Muel.

    Your scenario says the button starts green and is turned green - is that a typo?
    1. Is it possible to someway interrupt repainting?
    If it's done correctly on the EDT then generally speaking, no.
    2. How does repainting of components occur? Left-to-right top-to-bottom, or top-to-bottom left-to-right?
    Depthwise hierarchical traversal. Actual geographic location is irrelevant.
    3. How can such a thing occur? :)
    Is there any off-screen buffering going on?
    Is the button re-rendered half and half or is it repainted when the dialog is moved? (That is to say, is the partially-repainted segment caused by a clipped repaint after a component is displayed partially over the button?)
    To me it sounds most likely that the button's properties have been changed without triggering a repaint, and then a clipped repaint has occurred, where the button repaints part of itself using its new properties.
    If so, the solution is to fire a repaint() when modifying the button color.
    But, of course, without seeing any code, that's a real shot in the dark.

  • Question about drawLIne(x1,y1,x2,y2) and repaint()

    i am doing this project, which i suppose to use drawLine and repaint() to generate graphs. my problem is, every time i hit a new button it will call the repaint() then my old graph is gone, only the new graph is left.
    for example
    i have 4 buttons. movesouth() movenorth() moveeast() movewest()
    when i hit movesouth two times there should be a staight line, when i hit movewest() my old graph is gone() it only left me with 1 unit to west cuz i have repaint() inside my actionPerformed function, my question is: is there a way that i can redraw these line without calling repaint () ? cuz repaint is kinda like redraw the new stuff and forget about the old ones, however i would like to keep the old one while adding the new graph to it.
    your suggestions would be great appreciated.

    well of course, your Graphics-Object is of the type Graphics2D, you just need a cast so that the compiler is happy ;-)
    Its the same Graphics2D object/instance as withought the cast...
    lg Clemens

  • A question about Graphics repaint

    hi all. I met a question about Graphics repaint
    I create mypane class extends JPane .
    Now I write a function to keep drawing a char at Screen when i resize my applet.
    the function code :
    bDrawChrToScr(Graphics2D bgr, char Chr,int iX,int iY,int iX1,int iY1)
    bgr.setColor(Color.black);
    bgr.fillRect(iX,iY,iX1,iY);
    bgr.setColor(Color.red);
    bgr.drawString(String.valueOf(Chr),iWidth,iHeight);
    bgr=thispane.getGraphics();
    and i call this function in paintcomponent .Now when i resize my applet ,i find it not work as my hope.
    the screen flash two. First it draw this char but sencond it erase it.Why? Thanks

    The super.paintComponent(g) method causes the default painting to occur - overriding you bDrawChrToScr() method. Therefore, change paintComponent() method to:
    super.paintComponent(g);
    bDrawChrToScr(...);

  • Question on screen repainting

    [I'm programming with JDK 1.2.1 / using JBuilder3 / the OS is windows 98]
    In the application I am writing I frequently remove swing components from the screen , add them back etc. Often I use
    removeAll();
    or
    this.getContentPane().removeAll();
    then add back a component
    however you don't see the removed components as gone - they are still showing on the screen
    (the added component does appear though)
    However when I click on the overallwindows98 icon in the top right hand corner of the screen (the small box just to the left of the one with an X in it, the the screen update takes place.
    I've tried :
    repaint();
    but that seems to make no difference
    How do I get the screen updates to work ??
    thanks in advance for any help
    Mike

    Hi Mike,
    I find that the handiest thing to do when adding/removing/modifying elements within a Container (or subclasses of Container, i.e., Panels, Applets etc.), is to call the Container's validate() method.
    This will cause the Container to layout its subcomponents again, removing any "sticky" elements.
    Hope that helps,
    Niul

  • Paint(), repaint(), update() question

    I have an applet window which paints text,
    then a request may be made to the applet to add more text,
    my problem is that i seem to be repainting evertything.
    please help :o|

    i have altered it slightly so that now my program uses a vector which is a list of names, if the list is updated the paint method will need recalling and the new list displayed
    //i havent used a canvas but i think it may be more useful is that right?
      public void init()
        this.setSize(250,350);
        this.addWindowListener(new java.awt.event.WindowAdapter()
          public void windowClosing(WindowEvent e)
            chatOnlineListClosing_windowClosing(e);
        this.setBackground(new Color(13, 79, 158));
      } //end init()
      public void paint(Graphics g)
        positionX = 80;
        positionY= 85;
        g.setColor(Color.white);
        g.fillRect(40,40,150,250);
        g.setColor(Color.black);
        g.setFont(new java.awt.Font("Dialog", 1, 11));
        g.drawString("GroupNames", 60, 70);
        if(! nameVec.elementAt(0).equals("")) //checks there is a value in the vector
          for(int i = 0; i < nameVec.size(); i++)
            String name = (String)nameVec.elementAt(i);
            g.drawString(name, positionX, positionY);
            positionY = positionY + 15;
      }//end paint()

  • Repaint question on j2me midp 2.0

    Hi,
    Is there a way to force repaint() happens at the time you want to call it instead of queueing it in an event queue? If I do that, what are the drawbacks?
    And on a real phone, what is the performance difference before repaint() a region verus repaint() the whole screen? And does setting up clipping rect help performance?
    Thank you.

    I think that you can call repaint() whenever you want in GameCanvas. The good thing is that you have the full control. The bad thing is that you will see the screen "flashing" if you call repaint() too frequently.
    The performance is dependent on the MIDP 2.0 implementation of the phone. MIDP 2.0-compatible phones might have different performance but they must have the same functionality.
    I have tried on Motorola V300 and V600, repainting on the clipped region is faster than repainting the whole screen.

  • Jframe blues ( another validate, repaint question )

    i can use validate() or repaint() just fine when i use it via a JButton or a JOptionPane.
    but when i use it via an event ( any event ) it doesnt work.
    the background changes to the background color but no components are showing
    when i click over where they're supposed to be they suddenly appear....
    even better, i use an option in my jmenu that pops a JOptionPane, click on the ok button and
    suddenly, all the components of me jframe suddenly appear!
    well, can somebody tell me what to do after
    frame.validate();
    so that all the components shows?
    thx
    PoPo

    ok all is well .....
    resolved the problem by starting a new thread
    SwingUtilities.invokeLater(new Runnable()
    public void run()
    // insert the code that updates the UI here.
    });

  • Repainting question for my syntax highlighter

    Hello there,
    I have a syntax highlighter which reuses much of the very useful code developed by Claude Dugauy, which can be found at http://www.fawcette.com/javapro/2003_07/magazine/columns/visualcomponents/default_pf.aspx
    . The syntax highlighting uses regular expressions, so its easily extendable to meet your needs.
    However, there is one problem: whenever the user presses a key, the whole of the TextPane containing the highlighted text, is repainted in its entirety. This is fine for small amounts of text to be highlighted, but is very slow when it comes to 1000+ lines.
    Please could someone be so excellent as to tell me how to go about addressing this problem, so that only a small amount of text is repainted whenever the user types something into the TextPane e.g. that inside the current viewport, or just the last typed word - thus removing this problem of inefficiency.
    Thanks in advance,
    Edd.

    I don't think it's going to be that easy. Every time a change is made, the default style is applied to the whole document, then the whole document is copied into a String so it can be reparsed and have the syntax styles applied again. Even if you could limit what actually gets painted, you'd still have all that unnecessary work going on.
    You could try forcing the highlighter to only reparse a portion of the document--like,say, a hundred lines before and after the point where the edit occurred--but deciding exactly where to start and stop can be pretty tricky.

  • Image repaint preformance and threading

    Folks,
    I'm trying to make this sucker run faster.
    My question is, can anyone please guide me, especially with regards synchronising the Threads more efficiently... I'm thinking of using join and i]notify to make the "navigator" threads yield to the swing threads, to give it a chance to repaint before continuing... does this sound sane to you?
    Currently, without the thread.sleep it paints get the first "burst", and then nothing until the alrorithm has completed... exactly not what I wanted, because the whole point of this GUI is to watch the algorithm at work... sort of a "visual debugger"... I find that watching an algorithm play out helps me to "imagineer" ways of improving it... and in this case improvement means optimisation... it's all about getting from A-J faster than anyone else on the planet, especially those smarty-wishbone-legs C# programmers ;-)
    The code is too big to post (darn that 7500 char limit!) so I'll split it over several posts here, and I've also posted it as a single download to [MazeOfBoltonGUI2.java|http://groups.google.com/group/comp_lang_java_exchange/web/MazeOfBoltonGUI2.java] on my google group (comp lang java exchange).
    Cheers all. Keith.
    package forums.maze;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.util.HashMap;
    import java.util.SortedMap;
    import java.util.TreeMap;
    import java.util.Stack;
    import java.util.Queue;
    import java.util.PriorityQueue;
    import java.util.Iterator;
    import java.util.Set;
    import java.util.concurrent.Callable;
    import java.util.concurrent.ExecutorService;
    import java.util.concurrent.Executors;
    import java.util.concurrent.Future;
    import java.util.concurrent.ExecutionException;
    import java.awt.Dimension;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Font;
    import java.awt.image.BufferedImage;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.JPanel;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    import javax.swing.SwingWorker;
    import java.io.PrintWriter;
    import java.io.BufferedWriter;
    import java.io.FileWriter;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.IOException;
    * A Visual debugger,
    * for the [A* Alogorithm|http://en.wikipedia.org/wiki/A*_search_algorithm] navigator
    * of the [Maze Of Bolton|http://cplus.about.com/od/programmingchallenges/a/challenge12.htm]
    * as implemented by [Prometheuz|http://forums.sun.com/profile.jspa?userID=550123]
    * with GUI by [Kajbj|http://forums.sun.com/profile.jspa?userID=91610]
    * hacked together by [Keith Corlett|http://forums.sun.com/profile.jspa?userID=640846]
    * and posted on [Sun's Java Forum|http://forums.sun.com/thread.jspa?threadID=5319334]
    * and posted on [Google news group|http://groups.google.com.au/group/comp_lang_java_exchange/]
    public class MazeOfBoltonGUI2
      static final char[][] matrix = readMatrix("map.txt");
      public static void main(String[] args) {
        SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              try {
                MazeNavigator navigator = new MazeNavigator(matrix);
                JFrame frame = new JFrame("MazeOfBoltonGUI2");
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setContentPane(new MainPanel(navigator));
                frame.pack();
                frame.setVisible(true);
              } catch (Exception e) {
                e.printStackTrace();
       * Reads the file into a char matrix[rows,cols] ie: an array of char arrays.
       * @param String filename - the name of the file to read
       * @return a fixed length array of strings containing file contents.
      private static char[][] readMatrix(String filename) {
        try {
          BufferedReader input = null;
          try {
            input = new BufferedReader(new FileReader(filename));
            char[][] matrix = null;
            List<String> lines = new ArrayList<String>();
            String line = null;
            while ( (line = input.readLine()) != null ) {
              lines.add(line);
            int rows = lines.size();
            matrix = new char[rows][];
            for (int i=0; i<rows; i++) {
              matrix[i] = lines.get(i).toCharArray();
            System.err.println("DEBUG: rows="+rows+", cols="+matrix[0].length);
            return matrix;
          } finally {
            if(input!=null)input.close();
        } catch (IOException e) {
          e.printStackTrace();
          throw new IllegalStateException("Failed to readMatrix!", e);
    class MainPanel extends JPanel
      private static final long serialVersionUID = 1L;
      // button panel
      private final JButton goButton;
      // maze panel
      private final MazeNavigator navigator;
      private final Monitor<Path> monitor;
      private BufferedImage background;
      private BufferedImage image;
      private List<Path>currentPaths;
      public MainPanel(MazeNavigator navigator) {
        this.navigator = navigator;
        this.monitor = new SwingMonitor();
        this.goButton = new JButton("Go");
        goButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              final String caption = goButton.getText();
              goButton.setVisible(false);
              monitor.execute();
        add(goButton);
        setPreferredSize(new Dimension(navigator.maze.cols*3, navigator.maze.rows*3)); //w,h
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (image==null) {
          image = (BufferedImage)createImage(navigator.maze.cols, navigator.maze.rows);
          mazeColors = createMazeColors(navigator.maze);
        this.draw(image.createGraphics());
        ((Graphics2D)g).drawImage(image, 0, 0, super.getWidth(), super.getHeight(), null);
      private static Color[][] mazeColors;
      private static Color[][] createMazeColors(Maze maze) {
        Color[][] colors = new Color[maze.rows][maze.cols];
        for (int r=0; r<maze.rows; r++) {
          for (int c=0; c<maze.cols; c++) {
            colors[r][c] = getColor(maze.matrix[r][c].ch);
        return colors;
      }*... PTO ...*

    I'm persuaded that the main issue (no intermediate results drawn) is the improper use of SwingWorker.
    When you've got over it, you may want to consider other smaller-effect optimizations:
    Reconsider usage of an offscreen image*
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (image==null) {
          image = (BufferedImage)createImage(navigator.maze.cols, navigator.maze.rows);
          mazeColors = createMazeColors(navigator.maze);
        this.draw(image.createGraphics());
        ((Graphics2D)g).drawImage(image, 0, 0, super.getWidth(), super.getHeight(), null);
      }At first I didn't get why you wanted to draw an offscreen image, then paint it to the screen, all that in the EDT.
    After reading the draw() method more closely, I guess you want to ease the coding of the scaling: you draw an image where one cell = one pixel, then paint the image, scaled to the panel's display size.
    In terms of performance, I don't know how it stands:
    On one hand, the image creation if lighter (1 pixel per cell). And you have a point that the built-in scaling offered by Graphics2D.drawImage(image, size) may be efficient. I can't comment on that, I hope the granphics and hardware acceleration folks will pop in the thread.
    On the other hand, if the built-in scaling had poor performance, it may be good to try what "manual" scaling would bring you. That means, in a simplified version, skip the offscreen image creation, and draw directly on the paintComponent()'s Graphics2D argument. the drawing of a cell at coordinates c,r, for example, would look like:
    g.fillRect(c*CELL_WIDTH, r*CELL_HEIGHT, WIDTH, HEIGHT);Performance apart, the scaling as you do it currently has functional drawbacks, if you want pathes as 1-pixel width lines over large cells:
    - if the maze is smaller (in rows, columns) than the panel displaying it (in pixels), the cells will be scaled but the pathes too: so your 1-pixel lines appear as large as the cells. May or may not be a desired effect.
    - if the maze is larger than the display panel, the cells are shrinked, fine, but the so are the path lines, to a point where they may be invisible (probably depending on color blending, I'm a n00b at graphics operations).
    But maybe I misunderstood the need, and maybe the intended drawing of a path is actually the drawing of the rectangles of all its traversed cells, in special path colors?
    Reconsider intermediate allocations*
    Each paintComponent() call results in the allocation of a 2D-array of Color objects (method createMazeColors(Maze)).
    I don't see what the mazeColors array brings you. I assume you wanted to decouple the determination of colors (depending on cell state) and the rendering of the colors: what does it bring: no performance advantage (on the contrary, it adds a 2D array allocation, and 2xN^2 2D-array access), and does not improve the code readability either (subjective rant, sorry).
    Why don't you pass the Maze as an argument to the draw() method, and call the getColor(cell.ch) from there?
    Side note, maybe a bit subjective: performance apart, the design of the usage of this mazeColor array is a no-go!
    An instance method alters a static variable reference,which is used subsequently in another instance method, with no synchronization. The current code does that in a single thread (+paintxxx()+ is only called in the EDT), which keeps that safe (I'd dare to say: by luck), but considerations exposed below may have you refactor the design to introduce other threads, and may exhibit the thread-unsafety of this design.
    Consider drawing the image in a background thread.*
    Indeed the technique of drawing to an offscreen image is quite common, but it is often done to improve responsiveness (not raw performance) of Swing applications. Here is a resource about this (what the author calls the passive approach), although it doesn't use a background thread.
    The idea is that if a paintCompobnent() methods involves lots of computation (arithmetics of traversing a 2D model, scaling things, etc.), this takes CPU times in the EDT, and all subsequent events (such as, a MouseEvent, but also other painting events) keep pending on the event queue, which is consumed by the single event-dispatch thread. The result is that the UI appear unresponsive, and painting of other areas may seem hung.
    The idea is to move the computation to a background thread, which posts rendering to the EDT when the Image is ready to be displayed.
    Of course this doesn't gain any CPU time. This only ensures the EDT uses a minimal part of this CPU (only render and image and process events), instead of performing the whole computation.
    In your case you already have a background thread, and indeed an appropriate choice, a SwingWorker. The application of this technique would consist in calling the draw() method in the worker thread (in the update(Path) method), and invoke super.publish() only after the image has been updated. Note that the process(List<Path>) could then ignore its argument (you may reconsider the choice of type parameter of the worker), and simply get the latest version of the image attribute).
    Of course in this technique, the offscreen image filling is called synchronously from the Navigator, so this halts the algorithm part itself, for the duration of the image generation. You may refine the technique by spawning a dedicated thread for the image generation - with subtle guard code to handle occasions when the algorithm goes faster than the image generation, and posts a new update(Path) while the image generation for the previous path has not completed yet...
    Recuce the number of things to redraw*
    Two parts:
    first, depending on the number of cells and pathes, there may be (yet another) optimization, to not redraw the whole offscreen image, but only the cells/path that have changed in the last update(). In particular, if a path is not a line but a list of cells, then it's quite easy, reusing the current offscreen image, to only fillRect(...) the appropriate cells.
    Second, if a path is not rendered as a thin line over larger cells, but as cells themselves rendered in special path colors, you may paint cells and path in one go: instead of drawing, first the cells, then the path, draw only the cells, electing the color using a decision method such as:
    private Color getColor(Cell) {
        if (cell.getPathState()!=NOT_IN_ANY_PATH) {
            return getColor(cell.getPathState());
        else {
            return getColor(cell.ch);
    }Of course this forces you to modify your data model, and update the new pathState as part of the algorithm (or better isolated, in the update(Path) method, before invoking the drawing machinery). Maybe that was the intention of the mazeColors array?
    I haven't studied your other posts on the logic of the MazeOfBolton algorithm, so I don't know if it's acceptable for you that a cell appear to have only one path state, as opposed to one for each of the pathes that traverse it. This last trick may then seem incorrect, but please consider it as only a graphical information, and indeed your current image drawing draws only ONE path for a given cell (the last path in currentPaths that traverses this cell ).

  • Repaint Problem in JInternalFrame!!!! help plz.

    hi,
    I have a question I have an application that has internal frames, Basically it is a MDI Application. I am using JDK 1.2.2 and windows 2000. The following example shows that when I drag my JInternalFrames only the border is shown and the contents are not shown as being dragged that's fine, but the application I am running have lot of components in my JInternalFrames. And when I drag the JInternalFrame my contents are not being dragged and that's what I want but when I let go the internalFrame it takes time to repaint all the components in the internalFrame. Is there any way I can make the repaint goes faster after I am done dragging the internalFrame. It takes lot of time to bring up the internalframe and it's components at a new location after dragging. Is there a way to speed up the repainting. The following example just shows how the outline border is shown when you drag the internalFrame. As there are not enough components in the internal frame so shows up quickly. But when there are lots of components specially gif images inside the internalframe it takes time.
    /*************** MDITest ************/
    import javax.swing.*;
    * An application that displays a frame that
    * contains internal frames in an MDI type
    * interface.
    * @author Mike Foley
    public class MDITest extends Object {
    * Application entry point.
    * Create the frame, and display it.
    * @param args Command line parameter. Not used.
    public static void main( String args[] ) {
    try {
    UIManager.setLookAndFeel(
    "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
    } catch( Exception ex ) {
    System.err.println( "Exception: " +
    ex.getLocalizedMessage() );
    JFrame frame = new MDIFrame( "MDI Test" );
    frame.pack();
    frame.setVisible( true );
    } // main
    } // MDITest
    /*********** MDIFrame.java ************/
    import java.awt.*;
    import java.awt.event.*;
    import java.io.Serializable;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    * A top-level frame. The frame configures itself
    * with a JDesktopPane in its content pane.
    * @author Mike Foley
    public class MDIFrame extends JFrame implements Serializable {
    * The desktop pane in our content pane.
    private JDesktopPane desktopPane;
    * MDIFrame, null constructor.
    public MDIFrame() {
    this( null );
    * MDIFrame, constructor.
    * @param title The title for the frame.
    public MDIFrame( String title ) {
    super( title );
    * Customize the frame for our application.
    protected void frameInit() {
    // Let the super create the panes.
    super.frameInit();
    JMenuBar menuBar = createMenu();
    setJMenuBar( menuBar );
    JToolBar toolBar = createToolBar();
    Container content = getContentPane();
    content.add( toolBar, BorderLayout.NORTH );
    desktopPane = new JDesktopPane();
    desktopPane.putClientProperty("JDesktopPane.dragMode", "outline");
    desktopPane.setPreferredSize( new Dimension( 400, 300 ) );
    content.add( desktopPane, BorderLayout.CENTER );
    } // frameInit
    * Create the menu for the frame.
    * <p>
    * @return The menu for the frame.
    protected JMenuBar createMenu() {
    JMenuBar menuBar = new JMenuBar();
    JMenu file = new JMenu( "File" );
    file.setMnemonic( KeyEvent.VK_F );
    JMenuItem item;
    file.add( new NewInternalFrameAction() );
    // file.add( new ExitAction() );
    menuBar.add( file );
    return( menuBar );
    } // createMenuBar
    * Create the toolbar for this frame.
    * <p>
    * @return The newly created toolbar.
    protected JToolBar createToolBar() {
    final JToolBar toolBar = new JToolBar();
    toolBar.setFloatable( false );
    toolBar.add( new NewInternalFrameAction() );
    // toolBar.add( new ExitAction() );
    return( toolBar );
    * Create an internal frame.
    * A JLabel is added to its content pane for an example
    * of content in the internal frame. However, any
    * JComponent may be used for content.
    * <p>
    * @return The newly created internal frame.
    public JInternalFrame createInternalFrame() {
    JInternalFrame internalFrame =
    new JInternalFrame( "Internal JLabel" );
    internalFrame.getContentPane().add(
    new JLabel( "Internal Frame Content" ) );
    internalFrame.setResizable( true );
    internalFrame.setClosable( true );
    internalFrame.setIconifiable( true );
    internalFrame.setMaximizable( true );
    internalFrame.pack();
    return( internalFrame );
    * An Action that creates a new internal frame and
    * adds it to this frame's desktop pane.
    public class NewInternalFrameAction extends AbstractAction {
    * NewInternalFrameAction, constructor.
    * Set the name and icon for this action.
    public NewInternalFrameAction() {
    super( "New", new ImageIcon( "new.gif" ) );
    * Perform the action, create an internal frame and
    * add it to the desktop pane.
    * <p>
    * @param e The event causing us to be called.
    public void actionPerformed( ActionEvent e ) {
    JInternalFrame internalFrame = createInternalFrame();
    desktopPane.add( internalFrame,
    JLayeredPane.DEFAULT_LAYER );
    } // NewInternalFrameAction
    } // MDIFrame
    I'll really appreciate for any help.
    Thank you

    Hi
    if you fill the ranges
    r_rundate-sign = 'I'.
    r_rundate-option = 'EQ'.
    r_rundate-low = '20080613'.
    r_rundate-high = '20080613'.
    APPEND r_rundate.
    EQ = 'equal', the select check the record with data EQ r_rundate-low.
    change EQ with BT  
    BT = between
    r_rundate-sign = 'I'.
    r_rundate-option = 'BT'.
    r_rundate-low = '20080613'.
    r_rundate-high = '20080613'.
    APPEND r_rundate.
    reward if useful, bye

  • 3 questions on visual changes and positioning

    Hello everyone,
    I hope I have the right section for my questions. (so many categories) I have three questions that I hope I can get answered.
    Question 1 ) I am writing an application that uses a JDesktopPane. I have a menu that each choice opens up a JInternalFrame. One of my internal frames contains option settings for the app. One of the option selections is the type of look and feel of the gui. I have three JRadioButtons that chooses the three built in types. When I use the method (see below) to change the gui look, it only effects the Internal Frame, not the rest of the app. Is there a way I can get it to change the rest of the frames and the main JDesktop.
    private UIManager.LookAndFeelInfo looks[];
    public void lookAndFeel()
              looks = UIManager.getInstalledLookAndFeels();
              try
                   UIManager.setLookAndFeel(looks[lookChoice].getClassName());
                   SwingUtilities.updateComponentTreeUI(this);
              catch(Exception exception)
                   try
                        UIManager.setLookAndFeel(looks[0].getClassName());
                   catch(Exception guiException)
                        // Nothing yet...
         }Question 2 ) Positioning --- I understand how to use layout managers, but is there a way I can override the positioning of objects? Sometimes, I want to postion objects to a point. Instead of automatic positioning.
    Question 3 ) Adjusting properties --- I notice that when I create a different font and if I want an object to use that font then I need to setFont() for the object. Unfortunately, I have noticed that this needs to be done for every object. Is there a way to set the font for all the objects in a JPanel or JFrame at once?
    Thanks everyone, (sorry for the numerous questions, just has been building for awhile)
    7

    Question 1 ) I am writing an application that uses a
    JDesktopPane. I have a menu that each choice opens up
    a JInternalFrame. One of my internal frames contains
    option settings for the app. One of the option
    selections is the type of look and feel of the gui. I
    have three JRadioButtons that chooses the three built
    in types. When I use the method (see below) to change
    the gui look, it only effects the Internal Frame, not
    the rest of the app. Is there a way I can get it to
    change the rest of the frames and the main JDesktop.Try doing
    revalidate();
    repaint()
    on all of them
    Question 2 ) Positioning --- I understand how to use
    layout managers, but is there a way I can override the
    positioning of objects? Sometimes, I want to postion
    objects to a point. Instead of automatic positioning.Your choice is either to call setLayout(null) and set component positions yourself or to create/extend your own layout manager
    >
    Question 3 ) Adjusting properties --- I notice that
    when I create a different font and if I want an object
    to use that font then I need to setFont() for the
    object. Unfortunately, I have noticed that this needs
    to be done for every object. Is there a way to set the
    font for all the objects in a JPanel or JFrame at
    once?Not that I can think of. Why not just create one method where you can set everybody's font with a font parameter?
    >
    Thanks everyone, (sorry for the numerous questions,
    just has been building for awhile)
    7

  • My repaint() doesnt work

    Hope somebody can help. I had posted this qtn on another site and got a response pointing to a java sun site talking about paint in general. unfortunately did not help.
    the issue is as follows:
    Heres the problem
    Have this drawing application with menus and stuff. so i draw box/lines/ circle etc. and when the mouse is released, i add the positions etc to an array, in my paint program, i parse thru the array and show the stuff. Now whatever i draw, doesnt appear immediately (although i have a repaint() (also tried validate, revalidate and every command i have learnt/come across).
    funny thing is, if i press my alt key, the "file" menu option will appear to be selected, when i press escape, the drawing window gets focus and immediately all my drawings appear. So my question, how do i make it do that.
    Additionally (while i am on the roll here) in my menu option i have a File/New when this is selected, i clear the array and do a repaint(). that works beautifully and all the drawing are gone. but if i click on a icon (designated as "new") that wont do anything until i go thru that pressing alt (or switching to another application using alt+tab and then coming back to my paint program).
    Any ideas?
    To add further this is how my code looks
    there is a frame called drawingWindow (my highest level).
    got a container Container drawBoard = getContentPane(); which is added to my frame.
    i got menubar and toolbar created and added to the drawingWindow
    Then i got this class which contains the paintcomponent routine.
    JPanel drawingArea = new DrawGraphics();
    and this is added to the container.
    drawBoard.add(drawingArea,BorderLayout.CENTER);
    as i mentioned earlier: when i draw something, the repaint doesnt show the stuff immediately. instead i have to switch to some other applications that overlaps this java program and when i switch back i will see my paint.
    why so and how can i ever get it to work.
    Thank you in advance.

    The same kind of problem I was also having some time back but what i did was sounding funny to me, but i did it.... as there is no way.Just do resize kind of operation.
    After calling repaint method , just get the current size of window, set it to next size and again set it back to original size.Screen will flicker for a fraction of second.It was working very well to me.Maybe it will help you too.......

  • Question on the engineering behind Swing

    I have been using the AWT for 5 years and love it, but I'd like to have Trees and Tables, etc.
    My question is this: Why do applets and applications that use Swing for their UI paint v-a-r-y slowly and sometimes don't work, or don't repaint when a menu is shown/removed. I have noticed this in many programs. I know that Swing is a "skin" painted onto the screen to represent UI components in a system-indpendent way, but still, why do slow? It's not my JVM and not my system. So the classes must be just too bulky for their own good. Is there are other Swing-like UI library? Theres AWT, Swing, and ???

    I'd be surprised to see Swing be faster than AWT.
    On Windows, Swing is pretty good, on other OSs, it ain't. Not the fault of the OS, but of Swing/JVM.
    I use Swing at the moment, but that's because AWT doesn't have enough features.
    I don't like the fact that Swing is non-native, and may consider SWT at some point (pending investigations into its licensing, how easy it is to deploy).
    The fact that Swing is non-native is far more important to me than its speed. If AWT were improved (feature-wise) to the same level as Swing, I'd be happy.

Maybe you are looking for

  • PDF SCANS ERROR MESSAGE: CAN'T "OPEN THE DEFAULT APP FOR THIS FILE TYPE" EG. PDF

    OFFICEJET PRO 8600 PLUS , WIN 7, SCAN TO COMPUTER AS A PDF FILE.  ERROR MESSAGE: "  CAN'T "OPEN THE DEFAULT APP FOR THIS FILE TYPE" EG. PDF

  • How to make my animation loop 3 times ?

    Hi Adobe, I have made a animation and want to loop it 3 times! Can you help my with that ? ;-) Best, Jesper

  • Firefox disabled my adobe flash player

    Firefox just out of nowhere decides to disable the flash plug-in without asking me. And everytime I go to a site that uses flash, I have to see this message (see link below.) https://support.mozilla.org/en-US/kb/why-do-i-have-click-activate-plugins S

  • Oracle

    Unable to load DLL 'OraOps10w.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) What is the solution for that .

  • Quality server  creshed

    hi my Quality server has been creshed , i have only online backup 17.08.2009 , i have a archive  backup till date , can i retore the all  database ,  if yes  ,please advise , how can i restore the data . venkat