Panels in applets

Hey guys,
Im writing an applet that uses the ImageIcon class. In addition to the images I need to add TextFileds, buttons, labels etc. Can seperate the two things(the images and the awt objects) into seperate panels. If so could somone help me out with the start of the code.
Thanks guys any help would be greatly appreciated.

get one of the online books
there is one all about swing it explains it with code

Similar Messages

  • Remove/add panel to applet speedy in 1.3.x; painfully slow in 1.4.1/2.beta

    The following code (which was working for years, including even 1.3.x) suddenly fails in 1.4.1 and 1.4.2beta on both win 2000 and win xp
    DESCRIPTION OF PROBLEM :
    An applet consists of 2 components: a contents panel and a button. The contents panel consists of one of several panels of components which are swapped at run-time. The first time a panel is added, the applet works fine, but subsequent additions of the "cached" panel cause 1.4.1 and 1.4.2beta to go to 100% utilization and take 10 seconds before properly displaying the panel.
    STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
    Load applet described above (and whose short complete example is reproduced below), then click on button "Swap Contents". Each click should swap the contents between 2 panels very quickly. 1.3.x releases did all swaps quickly as expected. Suddenly, in 1.4.1 and 1.4.2beta, the first click is fine, but subsequent clicks are painfully slow.
    ---------- BEGIN SOURCE ----------
    // Java code to reproduce bug followed by html file to load applet
    import java.awt.*;
    import java.awt.event.*;
    public class TestRemoveAddApplet extends java.applet.Applet {
    Container contentPanel = new Panel();
    Button button = new Button("Swap contents");
    Panel contents1 = new Panel();
    Panel contents2 = new Panel();
    Label contentsL1 = new Label("Contents #1");
    Label contentsL2 = new Label("Contents #2");
    Component current = contents2;
    public void init() {
    setLayout(new BorderLayout());
    add(contentPanel,"Center");
    add(button,"South");
    button.addActionListener(new Swap());
    contents1.add(contentsL1);
    contents2.add(contentsL2);
    // initialize contents
    swapContents();
    class Swap implements ActionListener {
    public void actionPerformed(ActionEvent e) {
    swapContents();
    void swapContents() {
    current = (current == contents1 ? contents2 : contents1);
    // remove contents of previous contents panel
    contentPanel.removeAll();
    // display new contents
    contentPanel.add(current);
    validate();
    HTML file follows:
    <HTML>
    <HEAD>
    <TITLE>Test Remove / Add in Applet</TITLE>
    </HEAD>
    <BODY>
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    WIDTH = 100% HEIGHT = 100% >
    <PARAM NAME = CODE VALUE = "TestRemoveAddApplet" >
    <PARAM TYPE = "application/x-java-applet;version=1.1" >
    </OBJECT>
    </BODY>
    </HTML>
    ---------- END SOURCE ----------

    Try hiding the panels first then adding them then show. I know its crazy but I have gotten better performance this way with 1.4.1x. Try it.
    current.setVisible(false);
    contentPanel.add(current);
    current.setVisible(false);

  • [SOLVED] xmonad + panel logging applets

    Until recently I used xmonad-log-applet, but after the last update, xmonad is unable to connect to dbus. I get the following error:
    xmonad-x86_64-linux: D-Bus Error (org.freedesktop.DBus.Error.NoReply): Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
    As this is quite a generic message, google wasn't of much help. and I know practically nothing about dbus, so I do not to know where to start looking for the problem. As an alternative I also tried this, which seems to take a simpler approach. But when I try to load it into my (xfce) panel (via XfApplet) I get this message:
    An internal error occurred and the applet could not be loaded.
    which is also quite informative... Starting a "real" gnome panel also doesn't help. Here I have the suspicion of some missing dependencies, although the program compiles just fine.
    Does anyone have some clues?
    Last edited by davvil (2011-04-28 09:19:15)

    I deserve a big facepalm! For the gnome-socket-applet I didn't export the GNOME_SOCKET_APPLET_PORT variable, so the program didn't start. I should have RTFM in more detail. But the socket-applet works at my computer at home, but not on the one at work
    I will mark this topic as solved, as I can use the dbus solution at work and the socket solution at home, but I am still intrigued why the difference arises. If I find the time, I will try to port the gnome-socket-applet to a native xfce panel applet and hopefully it will be more stable.
    BTW I uploaded a PKGBUILD for gnome-socket-applet

  • Panel in applet

    HI,
    We have created an applet which uses Panel to display images. This applet works fine in netscape but fails in IE.
    Please suggest.
    This is the code :
    * Class : DispImage
    * Modification History :
    *     July 23, 2000
    *          File Created.
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.lang.*;
    import java.applet.*;
    import java.net.URL;
    import java.net.MalformedURLException;
    public class SimpleImage extends Applet
    String myFile;
    String msg = "";
    URL url;
    Image img;
    int displayTime;
         ImagePanel imagePanel = null;
    public void init()
         setLayout(new BorderLayout());
         setBackground(Color.green);
    System.err.println("Init");
    displayTime = new Integer(getParameter("displayTime")).intValue();
    myFile = getParameter("img");
         try
         img = getImage(new URL(getCodeBase(),myFile));
         catch(Exception e)
         imagePanel = new ImagePanel(img);
         add(imagePanel);
    class ImagePanel extends Panel
         Image img;
         ImagePanel(Image img)
              setBackground(Color.blue);
              this.img = img;
         public void paint(Graphics g)
         if (img != null)
         g.drawImage(img, 0, 0, img.getWidth(this), img.getHeight(this),Color.white, this);

    How does it fail?
    Any exceptions in the java console?
    how about adding some debugging code?
    suggestions for some tracing to place nicely around in your code:
    System.out.println("panelsize "+getSize().width+", "+getSize().height);
    if(img == null)
    System.out.println("img is null");
    else
    System.out.println("img is painted");

  • JLabel components not being displayed on the content Panel in Applet

    Hi everyone!!
    Plz give a solution to the following problem:
    I have an applet in which i have JPanel component and on that component i am adding a lot of JLabel components but the problem is that the JLabel components are not displayed on the applet unless i minimize or maximize the applet.
    kindly give solution to the problem.
    Thanks

    Howdy,
    code would be helpful. Here is a very simple JApplet that displays labels okay here in appletviewer. You talk of applets and JLabels. I assume you are using JApplets.
    import javax.swing.*;
    import java.applet.*;
    import java.awt.*;
    public class AppletPie extends JApplet {
         public void init() {
              Container cp = getContentPane();
              cp.setLayout(new FlowLayout());
              cp.add(new JLabel("Show"));
              cp.add(new JLabel("up"));
              cp.add(new JLabel("you"));
              cp.add(new JLabel("dumb"));
              cp.add(new JLabel("labels"));
    }Perhaps something in this code will help you to solve your problem.
    regards
    sjl

  • Applet and panels

    I want to add panel in applet in which an image is painted in the center and i want to display a panel as popup window in the applet

    I want to add panel in applet in which an image is
    painted in the center and i want to display a panel
    as popup window in the appletJApplet
    JPanel
    ImageIcon
    Graphics
    JWindow/JDialog/JFrame

  • Panel inside an applet

    Hi,
    I have try to include a panel in applet with the code as follow:
    private LoginPanel loginPanel = null;
    public void init() {
    loginPanel = new LoginPanel();
    add(loginPanel);
    the LoginPanel class is as follow:
    import java.awt.*;
    public class LoginPanel extends Panel {
    private Button submitButton = null;
    private Button resetButton = null;
    private Label userIDLabel = null;
    private Label userPwdLabel = null;
    protected TextField userIDTextField = null;
    protected TextField userPwdTextField = null;
    public LoginPanel() {
    super();
    setFont(new Font("Serif", Font.PLAIN, 12));
    setBackground(Color.white);
    setLayout(new FlowLayout());
    userIDLabel = new Label("User ID: ");
    userIDLabel.setBackground(Color.yellow);
    userPwdLabel = new Label("User Password: ");
    userPwdLabel.setBackground(Color.yellow);
    public void paint(Graphics g) {
    Dimension d = getSize();
    Point p = getLocation();
    g.drawRect(p.x, p.y, d.width-1, d.height-1);
    However, the paint function of the LoginPanel can't draw the the rectangle. Is there any problem with the code??
    Thank you very much.

    Hi,
    Your problem relates to layoutManagers and has nothing to do with painting. By default an Applet and a Panel use FlowLayout manager. Your problem is that you don't give anything a size except for the applet. Therefore, your LoginPanel is very small. You have two choices to make it work.
    1. Use a BorderLayout for the Applet layout manager and it will make sure that your LoginApplet is the same size as the Applet.
      public void init()
        loginPanel = new LoginPanel();
        setLayout( new BorderLayout() );
        add( loginPanel );
      }2. There is no setPrefferedSize method in AWT so you will need to override the getPrefferedSize method inside your LoginPanel class to give it some size. This is because FlowLayout will call this class in order to perform its' layout.
      public Dimension getPreferredSize()
        return( new Dimension( 500, 300 ) );
      }Regards,
    Manfred.

  • Mouse clicks inside image in applet

    How can I respond to mouse clicks inside particular regions in an image loaded as part of an applet in a browser? ie, I want to send these clicks onto the server for the server to handle it and the server should change the image according to the mouse clicks.
    Thanks,

    /*  <applet code="ImageMouse" width="400" height="400"></applet>
    *  use: >appletviewer ImageMouse.java
    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.*;
    public class ImageMouse extends JApplet
        JLabel label;
        public void init()
            ImageMousePanel panel = new ImageMousePanel();
            ImageMouser mouser = new ImageMouser(panel, this);
            panel.addMouseMotionListener(mouser);
            getContentPane().add(panel);
            getContentPane().add(getLabel(), "South");
        private JLabel getLabel()
            label = new JLabel(" ");
            label.setHorizontalAlignment(JLabel.CENTER);
            label.setBorder(BorderFactory.createTitledBorder("image coordinates"));
            Dimension d = label.getPreferredSize();
            d.height = 35;
            label.setPreferredSize(d);
            return label;
        public static void main(String[] args)
            JApplet applet = new ImageMouse();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(applet);
            f.setSize(400,400);
            f.setLocation(200,200);
            applet.init();
            f.setVisible(true);
    class ImageMousePanel extends JPanel
        BufferedImage image;
        Rectangle r;
        public ImageMousePanel()
            loadImage();
            r = new Rectangle(getPreferredSize());
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            int w = getWidth();
            int h = getHeight();
            int imageWidth = image.getWidth();
            int imageHeight = image.getHeight();
            r.x = (w - imageWidth)/2;
            r.y = (h - imageHeight)/2;
            g2.drawImage(image, r.x, r.y, this);
            //g2.setPaint(Color.red);
            //g2.draw(r);
        public Dimension getPreferredSize()
            return new Dimension(image.getWidth(), image.getHeight());
        private void loadImage()
            String s = "images/greathornedowl.jpg";
            try
                URL url = getClass().getResource(s);
                image = ImageIO.read(url);
            catch(MalformedURLException mue)
                System.err.println("url: " + mue.getMessage());
            catch(IOException ioe)
                System.err.println("read: " + ioe.getMessage());
    class ImageMouser extends MouseMotionAdapter
        ImageMousePanel panel;
        ImageMouse applet;
        boolean outsideImage;
        public ImageMouser(ImageMousePanel imp, ImageMouse applet)
            panel = imp;
            this.applet = applet;
            outsideImage = true;
        public void mouseMoved(MouseEvent e)
            Point p = e.getPoint();
            if(panel.r.contains(p))
                int x = p.x - panel.r.x;
                int y = p.y - panel.r.y;
                applet.label.setText("x = " + x + "  y = " + y);
                if(outsideImage)
                    outsideImage = false;
            else if(!outsideImage)
                outsideImage = true;
                applet.label.setText("outside image");
    }

  • [SOLVED] GNOME 3.8 Classic mode - can't edit panels

    Hi!
    I've just switched from MATE to GNOME (3.8.4).
    I use gnome-classic ("gnome-session --session gnome-classic" opened from whether gdm or slim/xinitrc).
    How do I edit panels and applets on them?
    I know that Alt+Right click on the panel doesn't always work and everybody recommends Super+Alt+Right click on a panel but it doesn't work for me either.
    I also tried a lot of other shortcut combinations (Ctrl+Super+Alt+Right Click, Shift+Super+Alt+Right Click, etc.), I still can't get the menu to show.
    I tried clicking both on top and bottom panels.
    How do I debug this?
    I tried removing all user configs (.config/dconf, .config/gconf, .config/gtk*, etc.), creating a new user, reinstalling GNOME, nothing helped.
    I also tried default gnome-session (without any flashbacks/fallbacks/classic parameters). It doesn't work there either.
    Thanks in advance.
    Last edited by ioxenus (2013-09-04 13:36:53)

    City-busz wrote:
    It is not supported in GNOME Classic. You can't edit the panel, but you can enable any GNOME Shell extensions with gnome-tweak-tool, or download more extensions from the http://extensions.gnome.org/ website.
    If you want to edit the panel, then try GNOME Flashback by installing gnome-flashback-session. It uses the old GNOME panel, which is very similar to MATE panel.
    Oops. Thanks a lot, got TopIcons and Frippery plugins installed, that looks like a great solution for me.
    Sorry!
    Last edited by ioxenus (2013-09-04 13:39:24)

  • How can you get an applet to obey the CSS z-index attribute?

    How can you get an applet to obey the CSS z-index attribute?
    I have a DHMTL page with a panel that I want to slide back and forth. But another part of the requirement is to have the panel look like it is sliding under another panel.
    The problem is that an applet is on the panel that slides. When the sliding panel move under the stationary panel the applet does not go under the stationary panel, but the reset of the sliding panel does render looking like it is sliding under.
    See below.
    - ~~~~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -
    - ~                      ~ ^                         ^ -
    - ~                      ~ ^                         ^ -
    - ~           #############***************           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #############^**************           ^ -
    - ~                      ~ ^                         ^ -
    - ~                      ~ ^                         ^ -
    - ~                      ~ ^                         ^ -
    - ~~~~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -
    ~ has a z-index of 1
    # and * have a z-index 2
    # shows above ~ and below ^
    ^ has a z-index of 3What I am getting with the applet on the panel with a z-index of 2 is the following
    - ~~~~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -
    - ~                      ~ ^                         ^ -
    - ~                      ~ ^                         ^ -
    - ~           #############***************           ^ -
    - ~           #            ^             *           ^ -
    - ~           #  @@@@@@@@@@@@@@@@@@@@    *           ^ -
    - ~           #  @                  @    *           ^ -
    - ~           #  @                  @    *           ^ -
    - ~           #  @                  @    *           ^ -
    - ~           #  @                  @    *           ^ -
    - ~           #  @                  @    *           ^ -
    - ~           #  @                  @    *           ^ -
    - ~           #  @@@@@@@@@@@@@@@@@@@@    *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #            ^             *           ^ -
    - ~           #############^**************           ^ -
    - ~                      ~ ^                         ^ -
    - ~                      ~ ^                         ^ -
    - ~                      ~ ^                         ^ -
    - ~~~~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -
    --------------------------------------------------------Where @ is the applet. Notice how the applet is on top of the ^ but the panel under it, ^, is under like it should be. All the panels are 1x1 tables with a border. So how can I get the applet on the drawing shown with # and * to follow the rendering of the z-index of 2?

    Hi,
    I have the same problem, and don't know how to solve it, So, i had tried to put my applet in a div tag wih z-index=0, but it still hide my other Dhtml divs with bigger Z-index (z-index =1000)
    Have you any idea to solve this.
    Thanks
    Hakim

  • Need to paint objects from one applet into another

    Maybe this question is more at home here; I have an applet test program which uses the timer class to make a car drive across the screen. The test works fine with the rectangle I used, but now I need to use the car created in this class:
       import java.applet.Applet;
       import java.awt.Graphics;
       import java.awt.Graphics2D;
       import java.awt.Rectangle;
       import java.awt.geom.Ellipse2D; 
       import java.awt.geom.Line2D;
       import java.awt.geom.Point2D;
         public class Car extends Applet
              public void paint(Graphics g)
                   Graphics2D g2 =(Graphics2D)g;
                   Rectangle body =new Rectangle(100, 110, 60, 10);
                   Ellipse2D.Double frontTire =new Ellipse2D.Double(110, 120, 10, 10);
                   Ellipse2D.Double rearTire =new Ellipse2D.Double(140, 120, 10, 10);
                   Point2D.Double r1 =new Point2D.Double(110, 110);
                   //the bottom of the front windshield
                   Point2D.Double r2 =new Point2D.Double(120, 100);
                   //the front of the roof
                   Point2D.Double r3 =new Point2D.Double(140, 100);
                   //the rear of the roof
                   Point2D.Double r4 =new Point2D.Double(150, 110);
                   //the bottom of the rear windshield
                   Line2D.Double frontWindshield =new Line2D.Double(r1, r2);
                   Line2D.Double roofTop =new Line2D.Double(r2, r3);
                   Line2D.Double rearWindshield =new Line2D.Double(r3, r4);
                   g2.draw(body);
                   g2.draw(frontTire);
                   g2.draw(rearTire);
                   g2.draw(frontWindshield);
                   g2.draw(roofTop);
                   g2.draw(rearWindshield);
         }The only thing I could think of was making an object of type Car in the test program and then doing something like this:
    Car c =new Car();
    g2.draw(c.paint(g));
    But it says in the test program void type not allowed here. Any tips as to what I'm doing wrong? My guess is that its a problem in the Car class and not the test program, but I didn't think I was supposed to alter Car. (Plus I tried already and couldn't get it to work.)

    what? I don't see what you are trying to do..
    You are trying to make an instance of a class which has no constructor?
    You are trying to move a Panel (an Applet is a subclass of Panel) in another Panel (in Test class?)
    Keep in mind that the Panel automatically has flow layout. In flow layout the components are sized to minimum size, and if the component is another Panel, the minimum size is 0 if there are no components in it.
    Do you need both applets open at once?
    Why not just copy this paint code into your test class?
    Also note that you CAN copy the Graphics from one component onto another, but the Graphics object cannot be null, or you will get a NullPointerException... which is what will happen if you try to copy it in the init() of your test class.
    Why not just make your car a Component (or a Panel even) and give it a constructor? (And make sure to set minimum size to something other than zero?)
    I think you have more than one problem..
    Jen

  • Adding image to JDialog in Applet

    Well.. I've decided to make my Applet load via a JDialog. Which I know is possible :). And to a start I'll make a very simple Applet in the JDialog, including a background picture, which I just can't add! So to make a long story short, I want an image in my JDialog, but my code gives me a nullPointerException during the Runtime.. Here's the exact Runtime error:
    Exception in thread "main" java.lang.NullPointerException
            at applet.<init>(applet.java:16)
            at applet.main(applet.java:100)And here's my exact applet.java file:
    import java.applet.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.imageio.*;
    import javax.swing.plaf.metal.*;
    public class applet extends Applet implements Runnable
        private ImagePanel panel;   
    public applet()
         panel.createGUI();
        public void init()
        public void run()
    public void start()
         Thread thread = new Thread(this);
         thread.start();
    public void stop()
    public void destroy()
    public void paint(Graphics g)
    private class ImagePanel extends JPanel
        BufferedImage buffered = null;
        public ImagePanel(String name)
            try
                buffered = ImageIO.read(new File(name));
                setPreferredSize(new Dimension(buffered.getWidth(), buffered.getHeight()));
            } catch(IOException ioe)
                ioe.printStackTrace();
        public void paintComponent(Graphics g)
            if (buffered == null)
                g.drawString("No Image", 10, 40);
            else
                g.drawImage(buffered, 0, 0, null);
        public void createGUI()
         MetalLookAndFeel.setCurrentTheme(new BlackTheme());
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
            JPopupMenu.setDefaultLightWeightPopupEnabled(false);
         JDialog dialog = new JDialog();
      dialog.setTitle("Applet loading via. JDialog");
      Container container = dialog.getContentPane();
      ImagePanel panel = new ImagePanel("background.gif");
      dialog.pack();
      dialog.setSize(1000, 1000);
      dialog.setVisible(true);
      dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        public static void main(String[] args)
         applet app = new applet();
    }And I don't see any errors, but still.. Runtime error.. -.-' So a little bit of help would really be appretaiced!

    Okay I guess I spoke to soon.. :O Now I have no Runtime error but my JDialog is completly empty.. And my BlackTheme stopped working.. Not It's a blue theme instead..
    Here take a look at my applet.java:
    import java.applet.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.imageio.*;
    import javax.swing.plaf.metal.*;
    public class applet extends Applet implements Runnable
        ImagePanel panel = new ImagePanel("background.gif");  
    public applet()
         panel.createGUI();
        public void init()
        public void run()
    public void start()
         Thread thread = new Thread(this);
         thread.start();
    public void stop()
    public void destroy()
    public void paint(Graphics g)
    private class ImagePanel extends JPanel
        BufferedImage buffered = null;
        public ImagePanel(String s)
            try
                buffered = ImageIO.read(new File(s));
                setPreferredSize(new Dimension(buffered.getWidth(), buffered.getHeight()));
            } catch(IOException ioe)
                ioe.printStackTrace();
        public void paintComponent(Graphics g)
            if(buffered == null)
                System.out.println("No image to display.");
            else
                g.drawImage(buffered, 0, 0, null);
        public void createGUI()
            MetalLookAndFeel.setCurrentTheme(new BlackTheme());
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
            JPopupMenu.setDefaultLightWeightPopupEnabled(false);
         JDialog dialog = new JDialog();
      dialog.setTitle("Applet loading via. JDialog");
      Container container = dialog.getContentPane();
      ImagePanel panel = new ImagePanel("background.gif");
      dialog.pack();
      dialog.setSize(1000, 1000);
      dialog.setVisible(true);
      dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        public static void main(String[] args)
         applet app = new applet();
    }

  • Query Panel unable to show me Radio Group.

    Hi Eweryone
    I am using Jdev 11.1.1.4.
    I am using a Transient Attribute in my ViewObject1("Updatable = Always") with Static List of Values coming from Different View Object2.
    I included this Transient Attribute in my View Criteria and assigned a Bind Variable to it.
    Settings for the Transient Attribute are
    in the ViewObject1 its " ControlType : Radio Group"
    in its List Of Values " Default List Type " Radio Group"
    to its BindVariable "Control Type : Radio Group"(i tried keeping this and not keeping this ,but no luck.)
    Now in the UI side when i am using this ViewCriteria as Query Panel with table in my page,i am unable to see the Radio Group for the Transient Attribute.(ChoiceList , CombeBox with Listof Values are coming)
    https://forums.oracle.com/forums/thread.jspa?threadID=2519882&tstart=0
    i saw this but no help.
    I really appreciate if some one helps me .Thanks in advance.

    The need to override paint() is that i want to show an image for which i am trying to use g.drawimage() method in paint. I don't know whether i can show an Image in a panel or not .
    The image that i want to show is in a byte[] array. For which i was previously using
    ImageIcon img = new ImageIcon(buffer);
    Then i took a JLabel
    JLabel label = new JLabel();
    label.setIcon(img);
    The problem in using this method is that i am continously updating this buffer with a timer and it continously update the image on the label. This shows flickering in the display .
    whereas if i use g.drawimage of paint method it does not show any flickering but then i am unable to use my other panels of Applet.
    Please tell me is there any imagelabel kind of a component on which i can show an image .

  • Easiest way to pass GET parameters to applet - Javascript really required??

    I want to transfer GET parameters to an appelt, i.e. in the call
    http://***/test.html?param1=abc&param2=def
    the param/values should be available in the applet.
    After some searching I've got the impression that this requires Javascript
    (http://stackoverflow.com/questions/12585022/how-to-pass-values-from-html-page-to-java-applet),
    but I would like to avoid this...
    Any help appreciated,
    Dieter

    found something:
    http://docs.oracle.com/javase/tutorial/deployment/applet/invokingAppletMethodsFromJavaScript.html
    http://stackoverflow.com/questions/14016972/call-java-applet-function-from-javascript
    and this is doing the trick, the Applet has Setters for my params
    <html>
    <head>
    <script language="Javascript">
    function readGetParams(){
       x = window.location.search.replace("?","");
       y = x.split("&");
       v1 = y[0].split("=")[1];
       v2 = y[1].split("=")[1];
       //alert( p1 + " -- " + v1 + " -- " + p2 + " -- " + v2);
       document.getElementById("fscapp").setUserID(v1);
       document.getElementById("fscapp").setCourseID(v2);
    </script>
    <title>FS Control Panel</title>
    </head>
    <body onload="readGetParams()">
    <h1>FS Control Panel</h1>
    <applet code="fsc.class" archive="fsc.jar" id="fscapp" width=500 height=500>
    </applet>
    </body>
    </html>

  • Buttons showing in panel help

    HI,
    This was my final year project and im trying to tidy it up a bit so I can add it to my protfolio but im having a big problem with the following:
    I have several panels all in a container, one is a button panel and one is a screen which shows an algorithm running. When you press or hover over a button in the button panel, it is displayed in the top left corner of the screen panel.
    the applet is here: http://homepage.ntlworld.com/k.wood143/FinalCopy/algo.html
    to get to the source just take off algo.html
    the classes you want are algoApp.java, and /runjava/GrahamScan.java
    any help or questions will be greatly appreciated, thanks in advance

    this edited version of your code does not show the buttons in the panel. The problem was your incorrect implementation of JPanels. You should never override paint(..) but paintComponent(..) instead. your implementation would have been ok for AWT but not Swing. get rid of all of your update and paint functions. put your 'update' code in paintComponent() save the call to repaint(). The DefaultPoints Panel is unnecessary. here is a revision of GrahamScan:
    package runjava;
    * Author Paul wood
    * This class is a JPanel used to display all of the steps
    * involved in the Grahams Scan algorithm. It addds an animation
    * feature to the JPanel using threads
    import javax.swing.JOptionPane;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    public class GrahamScan extends JPanel implements Runnable {
         //Edited by BlairTheMagician
         static int[][]coords = new int[][]{ {20, 90}, {100, 140}, {25, 200}, {150, 140},
                        {120, 220}, {115, 200}, {150, 55}, {125, 120},
                        {200, 140}, {250, 210},{220, 265}, {240, 240} };
         // Create an array of type Point
         static Point[] defaultPoints = new Point[coords.length];
         static
              //     add the points of the coords 2d array into the point array
             for(int i = 0; i < defaultPoints.length; i++)
                 defaultPoints[i] = new Point(coords[0],coords[i][1]);
         }// end edit by the Magician
    // initialise constants used for button presses
    public final static int COMPLETE = 1;
    public final static int ANCHOR = 2;
    public final static int ANGLE = 3;
    public final static int CONVEX = 4;
    public final static int ANIMATION = 5;
    public final static int STOPANIM = 6;
    public final static int STEP = 7;
    public final static int BUILD = 8;
    private int complete;
    private int anchor;
    private int angle;
    private int build;
    private int convex;
    private int step;
    private int nextStep;
    Point test1;
    Point test2;
    // these are used to get the sets of points
    DefaultPanel defaultPanel;
    OwnPointsDemo ownPointsPanel;
    Point[] points;
              // this is still not workink
    //Point[] points = ownPointPanel.points;
    int draw = 2;
    int count = 2;
    int val = 0;
    int[][] lineDraw;
    boolean completeHull = false;
    int start = 0;
    // default delay
    int delay = 1000;
    // animation stuff
    int frameNumber = 0;
    volatile Thread animatorThread = null;
    boolean threadSuspended = false;
         // create an array to hold the final convex hull points
         Point[] convexHull;
         ArrayStack S;
    public GrahamScan(DefaultPanel defaultPanel, OwnPointsDemo ownPointsPanel )
    // add demo panel
    // JPanel grahamScanPanel = new JPanel();
    this.defaultPanel = defaultPanel;
    this.ownPointsPanel = ownPointsPanel;
    points = defaultPanel.points;
    convexHull = new Point[points.length];
         S = new ArrayStack(points.length);
    //Point[] points = ownPointPanel.points;
    lineDraw = new int[points.length][points.length];
    public void startAnimation()
    //Create and start the animating thread.
              if (animatorThread == null) {
                   animatorThread = new Thread(this);
                   animatorThread.start();
    public void stopAnimation() {
    //Stop the animating thread.
    if (animatorThread != null) {
                   animatorThread = null;
         public void run()
              final Thread currentThread = Thread.currentThread();
              reset();
              step = STEP;
              while( animatorThread == currentThread) {
                   try{
                        currentThread.sleep(delay);
                        synchronized(this) {
                             while (threadSuspended && animatorThread == currentThread)
                                  wait();
                   }catch( InterruptedException ex ){}
                   frameNumber++;
                   nextStep++;
                   repaint();
    public void paint( Graphics g )
         update(g);
         public void paintComponent( Graphics g )
         Graphics2D g2 = (Graphics2D)g;
    //super.paint( g2 );
         g2.setColor(Color.white);
         g2.fillRect(0,0,this.getWidth(),this.getHeight());
         g2.setColor(Color.black);
         // edit by BTM begin
         // draw default points
         for(int i = 0; i < defaultPoints.length; i++)
    g2.fillOval( defaultPoints[i].x, defaultPoints[i].y, 4, 4 );
         // end edit by BTM
    // initialise a polygon for visual testing of the algorithm
    Polygon polygon1 = new Polygon();
    g2.drawString("frame = " + frameNumber, ( 200 ),( 300 ) );
    if( anchor == ANCHOR )
              // now start the algoithm by finding the anchor point
              findAnchorPoint();
              g2.setColor(Color.blue);
              g2.drawString("<-- Anchor point", ( points[0].x + 5 ),( points[0].y +5 ) );
         if( angle == ANGLE )
              // next sort the array into angular order
              angleSort( points );
              for(int i = 1; i < points.length; i++)
              g2.drawLine(points[0].x, points[0].y, points[i].x, points[i].y );
    if( step == STEP )
              g2.drawString("step = " + nextStep, ( 100 ),( 300 ) );
              if( nextStep == 1 )
                   anchor(ANCHOR);
                   // this is needed to stop the image being repainted until
                   // step is pressed again
                   nextStep++;
              else if( nextStep == 3 )
                   angle( ANGLE );
              // this is needed to stop the image being repainted until
                   // step is pressed again
                   nextStep++;     
              else if( nextStep == 5 )
                        buildConvex( BUILD );
                        // this is needed to stop the image being repainted until
                   // step is pressed again
                   nextStep++;      
    if( build == BUILD )
         convexHull( points );
                   if (completeHull == true)
                        // add the points in the point array to the polygon
         for ( int i = 0; i < convexHull.length && convexHull[ i ] != null; i++ )
         polygon1.addPoint( convexHull[ i ].x, convexHull[ i ].y );
         // draw the polygon
         g2.drawPolygon( polygon1 );
    else
    //     g2.drawLine(points[0].x, points[0].y, points[1].x, points[1].y);
         test1 = S.top();
                        test2 = S.secTop();
                        if( val < 1 )
                             lineDraw[0][0] = points[0].x;
                             lineDraw[0][1] = points[0].y;
                        //     lineDraw[1][0] = points[1].x;
                        //     lineDraw[1][1] = points[1].y;
                             lineDraw[1][0] = test2.x;
                             lineDraw[1][1] = test2.y;
                             lineDraw[2][0] = test1.x;
                             lineDraw[2][1] = test1.y;
                             val++;
                        if(test1.x == lineDraw[draw][0] && test1.y == lineDraw[draw][1] )
                             //just draw what we've already got
                             for( int i = 1; i < lineDraw.length && lineDraw[i][0] > 0; i++ )
                                  g2.setColor( Color.blue );
                                  g2.drawLine(lineDraw[i-1][0], lineDraw[i-1][1], lineDraw[i][0], lineDraw[i][1] );
                        else
                             //add to lineDraw then draw lines
                             lineDraw[draw][0] = test1.x;
                             lineDraw[draw][1] = test1.y;
                             lineDraw[draw][0] = test2.x;
                             lineDraw[draw][1] = test2.y;
                             for( int i = 1; i < lineDraw.length && lineDraw[i][0] > 0; i++ )
                                  g2.setColor( Color.blue );
                                  g2.drawLine(lineDraw[i-1][0], lineDraw[i-1][1], lineDraw[i][0], lineDraw[i][1] );
         g2.setColor( Color.red );     
                        g2.drawLine(test1.x, test1.y, test2.x, test2.y);
    if( convex == CONVEX )
         // finally find which points are on the convex hull
              testMeth( points );
    // add the points in the point array to the polygon
    for ( int i = 0; i < convexHull.length && convexHull[ i ] != null; i++ )
    polygon1.addPoint( convexHull[ i ].x, convexHull[ i ].y );
    // draw the polygon
    g2.setColor(Color.blue);
    g2.drawPolygon( polygon1 );
    // these next methods all relate to button presses in he main AlgoApp class
    public void anim ( int animation )
         convex = 0;
         angle = 0;
         anchor = 0;
         if( animation == ANIMATION )
              threadSuspended = false;
    startAnimation();
         else if( animation == STOPANIM )
              threadSuspended = true;
    stopAnimation();
    public void anchor ( int anchorPoint )
         convex = 0;
         angle = 0;
         anchor = anchorPoint;
         repaint();
    public void angle ( int angleSort )
         convex = 0;
         angle = angleSort;
         repaint();
    public void step ( int stepByStep )
         convex = 0;
         step = stepByStep;
         nextStep++;
         repaint();
    public void buildConvex( int buildHull )
         angle = 0;
         build = buildHull;
         repaint();
    public void convex ( int convexHull )
         angle = 0;
         convex = convexHull;
         repaint();
    public void sliderValue( int slider )
         delay = slider;
    public void reset()
         complete = 0;
         anchor = 0;
         angle = 0;
         build = 0;
         convex = 0;
         step = 0;
         nextStep = 0;
         frameNumber = 0;
         start = 0;
         draw = 2;
         count = 2;
         val = 0;
         completeHull = false;
         // used to delete lineDraw array so it redraws from the start
         for( int i = 0; i < lineDraw.length; i++)
              lineDraw[i][0] = 0;
              lineDraw[i][1] = 0;
         repaint();
    *This is where Graham's Scan algorithm is
    // first we find the anchor point
    public void findAnchorPoint()
    int min = points[0].y;
    int max = points[0].x;
    int anchorPoint = 0;
    int anchorIndex = 0;
    for (int i = 0; i < points.length && points[i] != null; i++)
    if (points[i].y > min)
    min = points[i].y;
    max = points[i].x;
    anchorPoint = i;
    else if (points[i].y == min)
    if (points[i].x > max)
    min = points[i].y;
    max = points[i].x;
    anchorPoint = i;
    // puts the anchor point at the beginning of the array
    swapPoint( points, anchorPoint, anchorIndex );
    public void swapPoint( Point pointArray[], int first, int second )
    Point hold;
    hold = pointArray[ first ];
    pointArray[ first ] = pointArray[ second ];
    pointArray[ second ] = hold;
    public void swapDouble( double doubleArray[], int first, int second )
    double temp;
    temp = doubleArray[ first ];
    doubleArray[ first ] = doubleArray[ second ];
    doubleArray[ second ] = temp;
    public double[] arraySort(double sortArray[])
    for( int pass = 0; pass < sortArray.length; pass++)
    for(int i = 2; i < sortArray.length; i++)
    if(sortArray[i] > sortArray[i-1] )
    swapPoint(points, i, i-1);
    swapDouble(sortArray, i, i-1);
    return sortArray;
    // next we calculate the angles
    public void angleSort( Point arr2[] )
    double angleArray[] = new double[arr2.length];
    double orderArray[] = new double[arr2.length];
    int indexOfAngle = 0;
    // works out angle of every point with x0 and y0 as the anchor point
    for (int i = 0; i < arr2.length; i++) {
    double pointAngle = Math.atan2((arr2[i].y - arr2[0].y), (arr2[ i ].x - arr2[0].x));
    // if its on the line with the anchor point at 180 degrees, this equals PI.
    // to make this come last in the array change PI to minus PI
    if ( pointAngle == Math.PI)
    pointAngle = -Math.PI;
    angleArray[i] = pointAngle;
    // call sortArray to sort the array angularly
    orderArray = arraySort(angleArray);
         // finally we claculate the final convex hull
    public void convexHull(Point stackArr[] )
    float leftCheck;
    if ( start == 0 )
              S.push(stackArr[0]);
              S.push(stackArr[1]);
              start += 1;
         if ( draw < stackArr.length )
              Point pt1 = S.top();
              Point pt2 = S.secTop();
              leftCheck = isLeft(pt1,pt2,stackArr[draw]);
              if ( leftCheck > 0)
                   S.push(stackArr[draw]);
                   count++;
                   draw++;
              else
              S.pop();
              count--;
         if ( draw == stackArr.length )
    completeHull = true;
              // stack called temp is used to get elements output in the correct order
              ArrayStack temp = new ArrayStack(stackArr.length);
              for ( int counter = 0; counter < count; counter++ )
              Point tempPoint = S.pop();
              temp.push(tempPoint);
              // put the coordinate onto final convex hull array
              for (int j = 0; j < count; j++)
              convexHull[j] = temp.pop();
              draw++;
    // this testMeth is used to allow the Get Convex Hull button to work
    public void testMeth(Point stackArr[] )
    int count = 2;
    int i = 2 ;
    float leftCheck;
    ArrayStack S = new ArrayStack(stackArr.length);
    S.push(stackArr[0]);
    S.push(stackArr[1]);
    while ( i < stackArr.length)
    Point pt1 = S.top();
    Point pt2 = S.secTop();
    leftCheck = isLeft(pt1,pt2,stackArr[i]);
    if ( leftCheck > 0)
    S.push(stackArr[i]);
    count++;
    i++;
    else
    S.pop();
    count--;
    // stack called temp is used to get elements output in the correct order
    ArrayStack temp = new ArrayStack(stackArr.length);
    String testOutput = "\nConvex Hull = \n ";
    for ( int counter = 0; counter < count; counter++ )
    Point tempPoint = S.pop();
    temp.push(tempPoint);
    // put the coordinate onto final convex hull array
    for (int j = 0; j < count; j++)
    convexHull[j] = temp.pop();
    //==============================================================================
    // Copyright 2001, softSurfer (www.softsurfer.com)
    // This code may be freely used and modified for any purpose
    // providing that this copyright notice is included with it.
    // SoftSurfer makes no warranty for this code, and cannot be held
    // liable for any real or imagined damage resulting from its use.
    // Users of this code must verify correctness for their application.
    // This is a C++ implementation which I, Paul Wood have modified slighty
    // for use in Java (07/03/2005).
    // isLeft(): tests if a point is Left|On|Right of an infinite line.
    // Input: three points P0, P1, and P2
    // Return: >0 for P2 left of the line through P0 and P1
    // =0 for P2 on the line
    // <0 for P2 right of the line
    public float isLeft( Point P0, Point P1, Point P2 )
    return (P1.x - P0.x)*(P2.y - P0.y) - (P2.x - P0.x)*(P1.y - P0.y);
    //==============================================================================

Maybe you are looking for

  • Crystal Report Printing - A4 Issue

    Hello Experts, One of our customers use third party rental add-on with SAP B1. The add-on has cyrstal reports files. All these reports are set to letter size by default in report page setup. Client does not to print in A4 . When the user clicks on Pr

  • How to track the utlisation of raw material given by cusomer

    My business scenario is like this,my customer will supply raw material to my company we have to process the material,sell it to same customer.as a result of this we will processing charge per kg of material.The customer need to know how the raw mater

  • Iphone Sync Error. attempting to copy to the disc c:\ you do not have enough access privileges for this operation sync

    Nothing has changed, all i am trying to do is sync my iPhone 3GS to my iTunes (Latest Update). After clicking sync it attempts to do so, it gets to the backing up stage, then soon as this completes i get the following 2 errors right after eachother.

  • Who has the answer to email in iPhoto?

    who can get the email to work from iphone? please let us know because I have a case open and we still can't get it fixed. To save your typing. It is not my prefernces, u/n-password, or configurations in iphoto. It is done right. I re-entered it a tho

  • Unexpected Error Message - RoboHelp 6

    This is the second time that I have received this error message when I generate WebHelp. The .swf file does not work when the project generates. I really appreciate any help. Here is the message that I received. Thanks Preparing to create WebHelp...