MS JView  & adding Canvas to Panel

Hi,
I want to animate the opening of my Dialogs by a dotted line starting from one edge of the main frame and finally leading to the dialog. I've put the code into the setVisible method of the Dialog. It adds small canvases to the main frame's panel, one by one with a break of 5 ms and after reaching the position of the dialog it shows up the dialog. It works fine on Sun jdks, but it does not show the canvases on MS JView until the dialog is visible. That means, it runs the code, I can hear the ticks, but it does not refresh the frame's panel until the dialog is visible. It doesn't matter if it is a modal dialog or not.
Has anymone any clue how to make it work on JView?
Here's the Dialog.setVisible code (just the basics):
public void setVisible(boolean visible) {
     if (visible) {
          for (int i = 0; i < 20; i++) {
               Panel dot = new Panel();
               dot.setBackground(Color.black);
               dot.setBounds(20 * i, 20 * i, 2, 2);
               frame.getPanel().add(dot, 0); // frame is a reference to my main frame
               try {
                    Thread.sleep(5);
               } catch (InterruptedException ex) { }
          super.setVisible(visible);
}Thanks
Mani

Hi Noah,
I tried almost everything I can imagine before posting here. I'm going mad about that. It seems that jview doesn't want to add the component until the dispatcher thread gets unblocked again. Here's what I tried:
dot.getPeer().show();
frame.dispatchEvent(new ContainerEvent(this, ContainerEvent.ComponentAdded, ...));and many more things. Finally, I created a new Thread inside of the set visible method, which created the dots and called super.setVisible(). That works, but if you need a modal dialog like for example a message box for confirmation, it won't wait for the response (since it is a new thread). So, that can't be my solution.
By the way, you can try the applet under http://www.jq-consulting.de/pages/psm.html
Thanks, but no Duke Dollars, unfortunately.
Mani

Similar Messages

  • Suggestion: Adding a "Pages Panel" in Edge Reflow, similar to Adobe Fireworks

    Hello Adobe Team:
    I realize ER is mostly to set up fluid layout prototypes, which so far I'm loving this software.  Especially the feature of your align panel. 
    But, I have a suggestion that I would love to see implemented in the near future. 
    Allowing for more than one File to be opened in ER
    Adding a "Pages Panel" similar to the Fireworks pages panel
    Master Page
    Pages

    Thanks for the suggestion!  I filed a Feature Request in our public github at: https://github.com/edge-reflow/issues/issues/38
    If you have a free github account, feel free to add additional feature requests there.  Posting them here is fine, too!

  • Canvas or Panel?

    Hi guys,
    What's the difference between Canvas and Panel? Since I'm able to draw on both of them? For example, I have got users input from text field and would like to draw something with the given values, do i use canvas or panel to do the drawing in an applet?

    you can use both, since both extend the Component class. A Canvas "represents a blank rectangular area of the screen onto which the application can draw" whereas a Panel "provides space in which an application can attach any other component". I would favour a Canvas for drawing because it can have a BufferStrategy. The advantage of a Panel is its Container functionality.

  • Adding mouselistener on Panel and Canvas

    Hi,
    I m building an application in which I m making a frame, adding a panel on it and then adding a Canvas on the panel. On this Canvas my Native C code is drawing an Image. This image is very small with respect to the size of the frame.
    The size of the Panel and the Canvas is made equal to the size of Image drawn.
    Now I want a mouseclick event on this image.
    Now the problem is that when I add mouselistener to the Panel I don't get any event.
    And when I add mouselistener to the Canvas I get the event but I get the event on the whole frame even if I set the canvas size equal to the drawn image size. I only want the mouse event only if mouse is clicked on the image.
    Can anyone tell the mistake or suggest any other way of doing this ?

    Hi,
    I m building an application in which I m making a frame, adding a panel on it and then adding a Canvas on the panel. On this Canvas my Native C code is drawing an Image. This image is very small with respect to the size of the frame.
    The size of the Panel and the Canvas is made equal to the size of Image drawn.
    Now I want a mouseclick event on this image.
    Now the problem is that when I add mouselistener to the Panel I don't get any event.
    And when I add mouselistener to the Canvas I get the event but I get the event on the whole frame even if I set the canvas size equal to the drawn image size. I only want the mouse event only if mouse is clicked on the image.
    Can anyone tell the mistake or suggest any other way of doing this ?

  • Re: adding canvas to applet

    Hi
    I am trying to add a canvas to an applet. I am successful in doing so. There is a JMenuBar added to the applet. when I click on the file menu The contents are being displayed behind the canvas and as a result I am neither able to see the buttons nor select them. Could some one help me with this.
    Note: Once you compile the code you wouldn't be able to see the contents right away. Click on left top,immidiately below the applet menu. This will repaint the contentpane. This is some thing I am working on.
    applet class
    package aple;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Shape;
    import java.awt.geom.AffineTransform;
    import java.util.ArrayList;
    import javax.swing.JApplet;
    public class NewJApplet extends JApplet{
        public Graphics2D g2;
        AffineTransform atf = new AffineTransform();
        sketch sk = new sketch();   
            @Override
        public void init() {      
            getContentPane().add(sk);
           Gui gui = new Gui();
            // menubar
            this.setJMenuBar(gui.Gui());     
        @Override
    gui class
    package aple;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    public class Gui {
        JMenuBar menuBar;
        JMenu file,edit,insert,view,draw,circle;
        JMenuItem nu,close,saveAs,open,centreandradius,line,rectangle,point,arc;
        public JMenuBar Gui(){
            //Menubar
            menuBar = new JMenuBar();
            //Menus
            file = new JMenu("File");
            menuBar.add(file);
            edit = new JMenu("Edit");
            menuBar.add(edit);
            view = new JMenu("View");
            menuBar.add(view);
            insert = new JMenu("Insert");       
            draw = new JMenu("Draw");
            circle = new JMenu("Circle");
            draw.add(circle);
            insert.add(draw);       
            menuBar.add(insert);
            //MenuItems
            nu = new JMenuItem("New");
            file.add(nu);
            open = new JMenuItem("Open");
            file.add(open);
            saveAs = new JMenuItem("SaveAs");
            file.add(saveAs);
            close = new JMenuItem("Close");
            file.add(close);
            line = new JMenuItem("Line");
            draw.add(line);
            centreandradius = new JMenuItem("Centre and Radius");
            circle.add(centreandradius);
            rectangle = new JMenuItem("Rectangle");
            draw.add(rectangle);
            point = new JMenuItem("Point");
            draw.add(point);
            arc = new JMenuItem("arc");
            draw.add("Arc");
            return(menuBar);
    sketch class
    package aple;
    import java.awt.Canvas;
    import java.awt.Color;
    import java.awt.Graphics;
    public class sketch extends Canvas{
        public void sketch(){
            this.setBackground(Color.green);
        @Override
        public void paint(Graphics g){
         // g.fillRect(50,50, 50, 50); 
    }

    When you were using JPanel, your "setBackground" didn't work because you were overriding its paint(Graphics) method without calling "super.paint(g);". If you don't do this, the panel won't paint its background.
    You should also override "protected void paintComponent(Graphics g)" in any JComponent, such as JPanel, instead of just "paint(Graphics)". (And don't forget to call super.paintComponent(g) FIRST in your subclass's overridden method, if you want the background painted):
    class MyJPanelSubclass extends JPanel {
       protected void paintComponent(Graphics g) {
          super.paintComponent(g); // Paints background and any other stuff normally painted.
          // Do your custom painting here.
    }

  • Gif in Canvas or panel or window (newbie)

    I am looking for help for a long time now...
    I try to draw a gif into a window.
    Adding it to a panel, an new instance of a inner Canva calass or directly to the window results at the best in displaying only a red
    piece not a red Image.
    I start to believe that the component ( panel ) is not big enough ...
    Can someone give me a example of a code ( from A to Z please ).
    PS: I overrid the paint method in the canvas, if that is the solution

    Thanks,
    The application works, thanks again.
    Should it also work in a normal applet ?
    I do not know if I ask for to much but here is my code, I want to insert the image in f.
    import.java.all.stuff.*
    public class Caller extends Applet implements ActionListener
    ClosableFrame f=new ClosableFrame("CallCast");
    ClosableFrame winWork=new ClosableFrame("CallCast Play");
    boolean winWorkActive=false;
    ................. declaring Textareas and Textfields ..................
    Panel p1=new Panel();
    Panel fP1=new Panel();
    Image logo=null ;
    .........Adding Menu bars
    public void init()
    logo=getImage(getCodeBase(),"Logo.gif");
    adding Labels ......
    f.setResizable(false);
    f.setMenuBar(settings);
    f.add(startCall);
    f.setLayout(new FlowLayout(FlowLayout.LEFT));
    f.add(intro);
    f.add........................................................TextAreas;
    ------------------------------->>>>>>> I WANT TO ADD AN IMAGE HERE
    f.setSize(450,600);
    f.setLocation(20,10);
    f.show();
    public void WorkFrames()
    public class ClosableFrame extends Frame implements WindowListener
    public ClosableFrame()
    this.addWindowListener(this);
    public ClosableFrame(String s)
    super(s);
    this.addWindowListener(this);
    public void windowClosing(WindowEvent e)
    ynF.show();
    public void windowOpened(WindowEvent e) {}
    public void windowClosed(WindowEvent e){}
    public void windowIconified(WindowEvent e){}
    public void windowDeiconified(WindowEvent e){}
    public void windowActivated(WindowEvent e)
    name.selectAll();
    public void windowDeactivated(WindowEvent e){}
    public void actionPerformed(ActionEvent e)
    Info da= new Info(new Frame(),"string1", "string2","string3");
    da.show();
    ......................................

  • Panel class not adding to main panel...

    I have a panel class that has a borderlayout which is to be nested in another panel with a borderlayout. I'm not sure what I'm doing wrong. Here is my code for the problematic classes:
    1st: Panel that needs to be added:
    public class SizePanel extends JFrame
         private JPanel sizePanel;
         private JPanel selectedSizePanel;
         private JList sizeList;
         private JScrollPane scrollPane;
         private JTextField selectedSize;
         private JLabel sizeLbl;
         private String[] sizes = {"Starter", "Standard", "Better", "Best" };
         public SizePanel()
              setLayout(new BorderLayout());
              buildSizePanel();
              buildSelectedSizePanel();
              add(sizePanel, BorderLayout.CENTER);
              add(selectedSizePanel, BorderLayout.SOUTH);
              pack();
              setVisible(false);
         private void buildSizePanel()
              sizePanel = new JPanel();
              sizeList = new JList(sizes);          
              sizeList.setSelectionMode(
                        ListSelectionModel.SINGLE_SELECTION);          
              sizeList.addListSelectionListener(
                        new ListListener());     
              sizeList.setVisibleRowCount(4);     
              scrollPane = new JScrollPane(sizeList);     
              sizePanel.add(scrollPane);
         private void buildSelectedSizePanel()
              selectedSizePanel = new JPanel();          
              sizeLbl = new JLabel("Price: ");     
              selectedSize = new JTextField(9);     
              selectedSize.setEditable(false);     
              selectedSizePanel.add(sizeLbl);
              selectedSizePanel.add(selectedSize);
         private class ListListener implements ListSelectionListener
              public void valueChanged(ListSelectionEvent e)
                   String selection = (String) sizeList.getSelectedValue();
                   selectedSize.setText(selection);
    }2nd: My code for adding it to the main panel:
    public HouseCalcGUI() {
            setTitle("McKeown's Real Estate Program");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setLayout(new BorderLayout());
            greetingPnl = new GreetingPanel();
            featuresPnl = new FeaturesPanel();
            sizePnl = new SizePanel();
            stylePnl = new StylePanel();
            buildButtonPanel();
            add(greetingPnl, BorderLayout.NORTH);
            add(stylePnl, BorderLayout.EAST);
            add(featuresPnl, BorderLayout.CENTER);
            add(sizePnl, BorderLayout.WEST);
            add(buttonPanel, BorderLayout.SOUTH);
            pack();
            setVisible(true);
        }

    Hey, guess what I just did...? BANGED MY HEAD AGAINST THE WALL. Your ingeniousness is in the form of my stupidity. Thank you though. Here are your dukes...What I did was take some sample program from my text to make my program.

  • Adding Jtree to Panel

    Hi all,
    I have a JTree in a scrollpane rendered with checkbox on each node. I
    When I try adding to JFrame its displaying with scrollbar as expected. like this
    frame.setContentPane(scrollPane); //working fineBut When I try adding to panel and try to display that its not working
    JPanel panel = new JPanel();
    panel.add(scrollPane);
    frame.setContentPane(panel); // displaying tree without scrollbarsthanks,
    sur

    scrollPane.setPreferredSize(new Dimension(x,y));where x,y can be the width/height of the frame

  • Moving canvas or panel over image

    Hello!
    Let's say I have a class that extends from panel, and in the paint method i draw an image on the panel. Now I need another object, transparent, but with some graphics on it, let's say a canvas, or another panel, with a rounded rectangle drawn inside, but otherwise transparent. Now I want to move that other canvas on the original panel panel, and i want original image to be seen where the canvas is transparent. How can I do this? How can I make such a canvas and add it to the panel?

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import javax.swing.event.MouseInputAdapter;
    public class OverlayTest extends JPanel
        BufferedImage image;
        public OverlayTest()
            loadImage();
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            int w = getWidth();
            int h = getHeight();
            int imageWidth = image.getWidth();
            int imageHeight = image.getHeight();
            int x = (w - imageWidth)/2;
            int y = (h - imageHeight)/2;
            g.drawImage(image, x, y, this);
        private void loadImage()
            String fileName = "images/redfox.jpg";
            try
                URL url = getClass().getResource(fileName);
                image = ImageIO.read(url);
            catch(MalformedURLException mue)
                System.err.println("url: " + mue.getMessage());
            catch(IOException ioe)
                System.err.println("read: " + ioe.getMessage());
        public static void main(String[] args)
            JPanel panel = new JPanel();
            OverlayLayout overlay = new OverlayLayout(panel);
            panel.setLayout(overlay);
            panel.add(new TopPanel());
            panel.add(new OverlayTest());
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(panel);
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    class TopPanel extends JPanel
        Point loc;
        int width, height, arcRadius;
        Rectangle r;       // for mouse ops in TopRanger
        public TopPanel()
            setOpaque(false);
            width = 300;
            height = 240;
            arcRadius = 35;
            r = new Rectangle(width, height);
            TopRanger ranger = new TopRanger(this);
            addMouseListener(ranger);
            addMouseMotionListener(ranger);
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            if(loc == null)
                init();
            g2.setPaint(Color.red);
            g2.drawRoundRect(loc.x, loc.y, width, height, arcRadius, arcRadius);
        private void init()
            int w = getWidth();
            int h = getHeight();
            loc = new Point();
            loc.x = (w - width)/2;
            loc.y = (h - height)/2;
            r.x = loc.x;
            r.y = loc.y;
    class TopRanger extends MouseInputAdapter
        TopPanel top;
        Point offset;
        boolean dragging;
        public TopRanger(TopPanel top)
            this.top = top;
            offset = new Point();
            dragging = false;
        public void mousePressed(MouseEvent e)
            Point p = e.getPoint();
            if(top.r.contains(p))
                offset.x = p.x - top.r.x;
                offset.y = p.y - top.r.y;
                dragging = true;
        public void mouseReleased(MouseEvent e)
            dragging = false;
            // update top.r
            top.r.x = top.loc.x;
            top.r.y = top.loc.y;
        public void mouseDragged(MouseEvent e)
            if(dragging)
                top.loc.x = e.getX() - offset.x;
                top.loc.y = e.getY() - offset.y;
                top.repaint();
    }

  • Hp 4315: some hp updates cause a new hp fax# to be added to control panel.

    I now have six (6) hp faxes listed in control panel. Which ones should I delete?

    Did you check the "Device Settings" in the 8600 printer properties.
    Please mark the post that solves your issue as "Accept as Solution".
    If my answer was helpful click the “Thumbs Up" on the left to say “Thanks”!
    I am not a HP employee.

  • Adding image to panel gives an error

    any ideas whatz wrong with this
    Panel p = new Panel();
    Graphics g = getGraphics();
    g.drawImage(splashImage, 0,0, p);
    add(p,BorderLayout.CENTER );
    the error i get is
    "AWT-Windows" (TID:0x14bda60, sys_thread_t:0x56a0cb8, state:R, native ID:0x540) prio=5
    at sun.awt.windows.WToolkit.eventLoop(Native Method)
    at sun.awt.windows.WToolkit.run(WToolkit.java:130)
    at java.lang.Thread.run(Thread.java:479)
    "SunToolkit.PostEventQueue-0" (TID:0x14bde28, sys_thread_t:0x569f970, state:CW, native ID:0
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:417)
    at sun.awt.PostEventQueue.run(SunToolkit.java:406)
    "AWT-EventQueue-0" (TID:0x14be1f0, sys_thread_t:0x5673818, state:CW, native ID:0x270) prio=
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:417)
    at java.awt.EventQueue.getNextEvent(EventQueue.java:216)
    at java.awt.EventDispatchThread.pumpOneEventForComponent(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEventsForComponent(EventDispatchThread.java:89)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:84)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:76)
    "SymcJIT-LazyCompilation-0" (TID:0x14ae228, sys_thread_t:0x4a1cf90, state:CW, native ID:0x4
    at SymantecJITCompilationThread.DoCompileMethod(Native Method)
    at SymantecJITCompilationThread.run(JITcompilationthread.java, Compiled Code)
    "SymcJIT-LazyCompilation-PA" (TID:0x14ae1f0, sys_thread_t:0x4a1b9e8, state:CW, native ID:0x
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:417)
    at SymantecJITCompilationThread.run(JITcompilationthread.java, Compiled Code)
    "Finalizer" (TID:0x14a9590, sys_thread_t:0x4964e10, state:CW, native ID:0x4dc) prio=8
    at java.lang.Object.wait(Native Method)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:105)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:120)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:167)
    "Reference Handler" (TID:0x14a9338, sys_thread_t:0x4961460, state:CW, native ID:0x598) prio
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:417)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:107)
    "Signal dispatcher" (TID:0x14a9370, sys_thread_t:0x4960130, state:R, native ID:0x55c) prio=
    "main" (TID:0x14a9420, sys_thread_t:0x2f2888, state:CW, native ID:0x528) prio=5
    Monitor Cache Dump:
    sun.awt.PostEventQueue@14BDE28/153CBC0: <unowned>
    Waiting to be notified:
    "SunToolkit.PostEventQueue-0" (0x569f970)
    java.lang.ref.Reference$Lock@14A9348/14DEB30: <unowned>
    Waiting to be notified:
    "Reference Handler" (0x4961460)
    java.awt.EventQueue@14BE108/153C848: <unowned>
    Waiting to be notified:
    "AWT-EventQueue-0" (0x5673818)
    SymantecJITCompilationThread@14AE228/1505068: <unowned>
    Waiting to be notified:
    "SymcJIT-LazyCompilation-PA" (0x4a1b9e8)
    java.lang.ref.ReferenceQueue$Lock@14A92F0/14DEEB8: <unowned>
    Waiting to be notified:
    "Finalizer" (0x4964e10)
    Registered Monitor Dump:
    SymcJIT Method Monitor: <unowned>
    SymcJIT Lazy Queue Lock: <unowned>
    Waiting to be notified:
    "SymcJIT-LazyCompilation-0" (0x4a1cf90)
    SymcJIT Method Monitor: <unowned>
    SymcJIT Method List Monitor: <unowned>
    SymcJIT Lock: <unowned>
    utf8 hash table: <unowned>
    JNI pinning lock: <unowned>
    JNI global reference lock: <unowned>
    BinClass lock: <unowned>
    Class linking lock: <unowned>
    System class loader lock: <unowned>
    Code rewrite lock: <unowned>
    Heap lock: <unowned>
    Monitor cache lock: owner "Signal dispatcher" (0x4960130) 1 entry
    Thread queue lock: owner "Signal dispatcher" (0x4960130) 1 entry
    Waiting to be notified:
    "main" (0x2f2888)
    Monitor registry: owner "Signal dispatcher" (0x4960130) 1 entry

    Following is the code i am using
    i create an instance of this class in another class.
    when i run this class, i get to see only a blank window but no image on that...
    any ideas!!
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.*;
    class SplashWindow extends Window
         Label l;
         Label l2;
         Label l3;
         Label l4;
         SplashWindow(Frame parent)
                   super(parent);
                   Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
                   Rectangle winDim = getBounds();     
                   setSize(300,200);
                   setLayout(new BorderLayout());
                   //l = new Label(" Solutions Demo");
                   //l.setFont(new Font("",1,20));
                   Image splashImage = Toolkit.getDefaultToolkit().getImage("spalsh.jpg");
                   //add(l, BorderLayout.WEST);     /* Center the window */     
                   JLabel label = new JLabel(new ImageIcon(splashImage));
                   add(label, BorderLayout.CENTER);     
                   setLocation((screenDim.width - winDim.width) / 2,     (screenDim.height - winDim.height) / 2);     
                   setBackground(Color.gray);     
                   setVisible(true);
                   try
                        Thread.sleep(4000);
                        dispose();
                   catch (InterruptedException ie)

  • Adding image on panel

    My applet is in 5 panel and I would like to add an image to my South panel. How can I do this?

    Try this,
    class p1 extends Panel
    Image image;
    public canpan(Image img)
    image = img;
    public void paint (Graphics g)
    if (image == null)
    return;
    g.drawImage(image, 0, 0, this);
    }

  • Adding Canvas to JScrollPane

    I'm trying to add a Canvas to a JScrollPane, but it always seems to show the ENTIRE canvas instead of just a scrollable portion of it.
    I've read about and tried examples using methods such as 'setPreferredSize' for both the scroll pane and it's container (I'm using a JPanel), but neither of these seem to stop the canvas from showing at full size.
    I've also tried 'scrollPane.setViewportView(myCanvas)', but this doesn't work either.
    Any ideas anyone?? I'm really stuck on this.

    Canvas is a heavy component and JScrollPane is a light component. A heavy component always paint on top a light component.
    The better is using only Swing's components or only AWT's components. Mixing have some problems
    Hope this help.

  • Error when adding textField to panel

    Hi, I am trying to learn some about swings and my first test code is like this:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Frename implements ActionListener{
         JButton btn_Aceptar;
         JButton btn_Cancelar;
         JButton btn_Ruta;
         JTextField txt_Nombre;
         JTextField txt_Ruta;
         JFrame frm_Frame;
         JPanel pnl_Panel;
        public static void main(String[] args) {
             //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    CrearMostrarGUI();
         private static void CrearMostrarGUI() {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            Frename frename = new Frename();
        public Frename(){
             frm_Frame = new JFrame("Renombrador de Archivos");
             frm_Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             frm_Frame.setSize(new Dimension(200,200));
             pnl_Panel = new JPanel(new GridLayout(2,3));
             AgregarComponentes();
             frm_Frame.getContentPane().add(pnl_Panel, BorderLayout.CENTER);
             frm_Frame.pack();
             frm_Frame.setVisible(true);
        public void AgregarComponentes(){
             txt_Ruta = new JTextField();
             txt_Ruta = new JTextField();
             txt_Ruta.enable(false);
             btn_Aceptar = new JButton("Iniciar");
             btn_Cancelar = new JButton("Salir");
             btn_Ruta = new JButton("Ruta");
             btn_Aceptar.addActionListener(this);
             btn_Cancelar.addActionListener(this);
             btn_Ruta.addActionListener(this);
             pnl_Panel.add(btn_Ruta);
             //THIS TWO FOLLOWING LINES PRODUCE ERRORS
             //pnl_Panel.add(txt_Ruta);
             //pnl_Panel.add(txt_Nombre);                  
             pnl_Panel.add(btn_Aceptar);
             pnl_Panel.add(btn_Cancelar);
        public void actionPerformed(ActionEvent e){     
               *THINGS THAT MUST BE DONE
               *WHEN ACTION IS PERFORMED
    }if I leave the lines that add the textfield to the panel as a comment the program runs good, otherwise the following erros are displayed:
    --------------------Configuration: <Default>--------------------
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at java.awt.Container.addImpl(Container.java:1031)
    at java.awt.Container.add(Container.java:352)
    at Frename.AgregarComponentes(Frename.java:65)
    at Frename.<init>(Frename.java:43)
    at Frename.CrearMostrarGUI(Frename.java:35)
    at Frename.access$000(Frename.java:13)
    at Frename$1.run(Frename.java:27)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
    Process completed.
    Please help me understand whats going on with this....
    The other question I have is why does the buildouput screen shows this:
    --------------------Configuration: <Default>--------------------
    Note: D:\Fred\Java Projects\Frename.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Process completed.

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Projekt2 implements ActionListener{
         JButton btn_Aceptar;
         JButton btn_Cancelar;
         JButton btn_Ruta;
         JTextField txt_Nombre;
         JTextField txt_Ruta;
         JFrame frm_Frame;
         JPanel pnl_Panel;
        public static void main(String[] args) {
             //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    CrearMostrarGUI();
         private static void CrearMostrarGUI() {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            Projekt2 Projekt2 = new Projekt2();
        public Projekt2(){
             frm_Frame = new JFrame("Renombrador de Archivos");
             frm_Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             frm_Frame.setSize(new Dimension(200,200));
             pnl_Panel = new JPanel(new GridLayout(2,3));
             AgregarComponentes();
             frm_Frame.getContentPane().add(pnl_Panel, BorderLayout.CENTER);
             frm_Frame.pack();
             frm_Frame.setVisible(true);
        public void AgregarComponentes(){
             txt_Ruta = new JTextField();
             txt_Nombre = new JTextField(); //I found your error here!!!
             txt_Ruta.enable(false);
             btn_Aceptar = new JButton("Iniciar");
             btn_Cancelar = new JButton("Salir");
             btn_Ruta = new JButton("Ruta");
             btn_Aceptar.addActionListener(this);
             btn_Cancelar.addActionListener(this);
             btn_Ruta.addActionListener(this);
             pnl_Panel.add(btn_Ruta);
             //THIS TWO FOLLOWING LINES PRODUCE ERRORS
             pnl_Panel.add(txt_Ruta);
             pnl_Panel.add(txt_Nombre);                  
             pnl_Panel.add(btn_Aceptar);
             pnl_Panel.add(btn_Cancelar);
        public void actionPerformed(ActionEvent e){     
               *THINGS THAT MUST BE DONE
               *WHEN ACTION IS PERFORMED
    }

  • Changing/Adding to Filter panel?

    Hello!
    I have question about posibility to add Color Mode from Metadata to Filter panel because i'm in a need to be able to easy separate and see what colormode have images. Like for poligraphy images supposed to be in CMYK and to see which images are still in RGB and so and on.
    So is that possible or not? In CS3 or CS5?
    P.S. acctually i don't understand why Metadata is made so tuneable (can not show what i don't need to know at all) but Filters panel are so weak (or i miss totaly something).
    Thank You!

    I know, my english isn't so good (making sense skill neither)
    I haven't trouble with getting Color Profile but getting Color Mode to filter by, as i start understand it's not posible.
    And it's a big comfort question.
    Like diference
    By profile: 4 sRGB, 1 NikonRGB, 3 ISO Coated, 1 U.S. Web Coated and 7 Untagged. (often CMYK profile aren't save so PROBABLY 80% chance it's CMYK)
    Teoreticly by mode: 7 RGB and 9 CMYK.
    Easy to "see" easy to use.
    But i get it, i'll use that profile and wait for "miracle".

Maybe you are looking for

  • I cant download apps in oman

    I am living in Oman ,no apple store available here ,when I want to register on iTunes store it require an account in UAE ,so how can I get the apps ?

  • Umlauts not displayed correctly

    Hi, We have developed a screen in 12.1 and the umlauts (German & Spanish) are not display correctly. Is there a language pack / custom actions we need deploy for this to work properly? Regards, Chanti.

  • Confused about Java Image Processing APIs

    I'm working on a Java application to which I'd like to add some advanced visual effects. Specifically, I'd like to make the application UI "dissolve" away when a specific selection is made. (See this link - http://www.anfyteam.com/anj/deform/deform.h

  • Publish MSDS file on line via SAP DMS

    Dear experts, Is anyone have any knowledge on publishing/make available on the web MSDS files which are stored in SAP DMS? In case that it's not possible to have this link between internet and SAP DMS, I would like to know how can I send my document

  • How do i get the tab on the right where i type in words to search to come back? It disappeared, as did the arrows on the right.

    I was online, the page I was on redirected me to another site. when that happened my bar changed. The space on the left totype in words to search disappeared as did the arrows on the left side of the bar.