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.

Similar Messages

  • How to load an Applet on a panel, within another Applet

    Hi,
    I want to know if and how it is possible to load an applet/application on a Panel within another Applet/Apllication.
    Who can help me?
    tnx

    You want to use an applet inside an other applet?
    Applet extends Panel
    you can take the source of the second applet, and instead of extending Applet extends Panel, and call the init method from the first applet.
    Hope this help

  • JLable components not being displayed in the panel of the applet

    I am having the problem with the display of the JLabel components in the Panel component of the Applet.
    The JLabel components do not appear in the Panel of the applet unless i minimize or maximize the applet.

    hello...
    i just had the same problem... it was solved by using the .updateUI() method.
    in my case several textFields were dynamically added to a jpanel, there we called the method on that panel.
    ptf.updateUI();     
    hope it works.
    ----------++-----+
    ...algun dia todos seremos luz...
    -zoe

  • I have a trouble with the clipboard inside an applet

    I have created simple text editor as applet (by JTextPane). I have a trouble with the clipboard. The clipboard works correctly inside the applet, but I'm not able to paste text from outside text editors (e.g. notepad). But I found out that clipboard works correctly inside appletviewer.
    You can visit the applet on: http://www.newlink.be/abst/
    Please help
    P.S.: I'm sorry for my bad english

    This is because applets do not have access to the system clipboard by default. The only way to get around this is to make a signed applet.

  • How i use multi panel in single applet

    hi master
    sir i need three panel in single applet
    i use this code but not set the panel
    pnl.setBounds(20, 10, 10, 20);
    and
    pnl.setLocation(12, 12);
    and
    pnl.setSize(12, 20);
    this is my class code
    JTable table = new JTable(rdata, columnNames);
    getContentPane().add(table.getTableHeader(),BorderLayout.NORTH);
    getContentPane().add(table);
    JPanel pnl = new JPanel();
    //pnl.setBounds(20, 10, 10, 20);
    //pnl.setLocation(12, 12);
    pnl.setSize(12, 20);
    pnl.add(new JScrollPane(table));
    getContentPane().add(pnl);
    //pnl.setBounds(10, 10, 10, 20);
    please sir give me idea how i use multi panel and how i set panel boundry
    thanking you
    aamir

    http://forum.java.sun.com/thread.jspa?threadID=5118094&tstart=0

  • Problem with Spry Panels inside a Table.

    This might be in the wrong section, but I hope someone knows what i'm doing wrong.
    I'm putting together a simple html website with a spry tabbed panel inside a table. I can insert the panel, switch between the different tabs to insert content, but when I preview the page in IE or Firefox all the content is in the first tabbe panel. I can hover over the other tabs but nothing happens when I click on them.
    I am slightly new to dreamweaver so it might just be something i'm overlooking.

    Hi Vinay,
    Check Valery`s great blogs:
    /people/valery.silaev/blog/2005/06/13/master-of-columns-part-i
    /people/valery.silaev/blog/2005/06/20/master-of-columns-part-ii
    For your case this piece of code could be usefull
    private IPrivateTreeTableCV.IEntriesElement currentEntry()
      try
        IWDNodeElement el;
        for
          el = wdContext.nodeEntries().getTreeSelection();
          !( el == null || el instanceof IPrivateTreeTableCV.IEntriesElement);
          el = el.node().getParentElement()
        return (IPrivateTreeTableCV.IEntriesElement)el;
      catch (final WDContextException ex)
        return null;
    Best regards, Maksim Rashchynski.

  • Sending emails from inside an applet (Please help!)

    Hi all!
    I�d like to send an email from inside the applet. For this reason I need to get the Systemproperties, don't I ?
    Properties props = System.getProperties();
    props.put("mail.smtp.host", mailhost);
    ... and set the mail.smtp.host Property my smtp-host.
    But as I try to get the systemproperties from the applet, I get the exception:
    com.ms.security.SecurityExceptionEx[Sendmsg.<init>]: Unable to access system properties.
    Can somebody tell me, how I can solve this problem? Which properties are needed to send mails?
    Does it work, if I just create my Properties, and set only the smtp.host?
    As I continued my experiments, I realised that it is not only the mail.smtp.host property, that is needed by the applet, but java.home, and many more...
    So is it possible to send emails in this form at all??
    Pleeaaaase help, I have to hand in my project very soon!
    Thanks a lot,
    Gabor

    I've found a site about signing:
    http://www.suitable.com/Doc_CodeSigning.shtml
    I think you can read german, therefore the german newsgroup de.comp.lang.java is a good point to search. Use http://groups.google.com to search the group.
    Uwe

  • Running old Flash panel inside an HTML5 panel

    Is it possible to run the SWF file of my old flash panel inside a new HTML5 panel and let the SWF communicate with Photoshop? Or do I have to write some intermediate code that passes the SWF commands to Photoshop? Is something like that possible at all? I am looking for an easy way to convert my flash panel to an HTML5 panel without having to recode its UI.

    Ok, I tried it myself. Where the Flash content should be there is only a "Couldn't load plugin" text. So why not
    support the Flash Player plugin inside HTML5 extensions in Photoshop CC 2014?

  • Resizing panels inside of panels inside of panels...

    I'm trying to organize a GUI by using a series of panels inside a JFrame. I have added panels within these panels to organize my information since I've never been able to figure out that ghastly GridBagLayout. Anyway, I've hit a wall. It seems that I can't resize an object inside of a panel that's inside of a panel. I use the setPrefferedSize method, but it just doesn't have any effect. This is true for both panels and buttons. Am I right in my assumption that there's a limit to how far into a pile of panels one can use the setPrefferedSize method? I'm using primarily BoxLayouts if that makes any difference. Any help or suggestions or advice would be appreciated.

    I'm afraid the SwingUtilities.updateComponentTreeUI didn't work. When I say I'm a novice, I'm afraid I'm kind of shooting in the dark as to some solutions and problems. Let me try and clarify my problem a little bit with an example. I have JPanels A, B, C, D, E, F, G and JCheckBoxes 1, 2, 3. JPanel A is added to the JFrame. The rest go as follows:
    A.add(B);
    B.add(C);
    C.add(D);
    C.add(E);
    D.add(F);
    D.add(G);
    G.add(1);
    G.add(2);
    G.add(3);
    Every JPanel has used the .setPreferredSize() method to define the size I desire. JPanels A, B, C, D, and E all keep their preferred sizes. However, F and G mock me by resizing according to the sizes of JCheckBoxes 1, 2, and 3. Even though they are coded to take up a certain amount of space (which is well within the limits of JPanel D), they don't. Instead they just go to the default size, which is to allow all components within it to be visible. I have this same problem when I add other components into JPanels D and E, like buttons, other JPanels, etc. I hope this clarified more than it confused.

  • TabbedPane inside an applet

    Hi guys.
    I've to implement an applet and in its interface I'd like to use something like tabbedpane, but there is in AWT class with these features.
    I can't use swing inside my applet.
    Does anyone has any idea ?
    plz help me.

    Yes you can. But the user will need a plugin to run. The plugin will install automaically. Whe they open your applet.

  • Which is better - 1 HTML page with multiple applet panels or 1 applet with

    Hi friends,
    This is a critical doubt which decides the future of my project.
    I have implemented a graph in which an html shows 3 panels on the screen via calling that applet 3 times.
    Would it be good if we call that applet only once and modify the applet to show 3 panels?
    Thanks in advance

    hai paskal,
    well having 3 panels in a single applet will not make a big difference when compared to having 3 diff applets with 1 panel each ...
    what matters most is how u want to have ur web page ...
    if you have 3 different applets then you can place them in a position according to ur wish ...
    if it is one then all of them will be together ...
    Peter

  • Opening a frame inside IE applet (window)

    I have an applet whih creates an instance of a frame .. the frame opens up in a separate IE window .. is there a way for the frame to overlay the applet window or is the nature of the frame always going to force a new window to open .. thanks to all who reply in advance

    If you want the frame to overlap the applet, don't use a frame but a panel.
    Kind regards,
      Levi

  • Html panel - inside html panel?

    hi everyone
    i have a page with a main content div which is an html panel theat will load different content
    one of the (fragment) pages it loads has xml data etc on it.
    i now need on this dynamic page a little html  in a div too, but that means an html panel within an html panel!
    i declared var infolpanel; on the main page, and the maincontent htmlpanel div has evalscripts set true
    on the dynamic fragment page, the xml datasets are working etc, but i need another html panel
    infopanel = new Spry.Widget.HTMLPanel("info");
    infopanel.loadContent('products/'+ product + '/info.html');}};
    now when i load the page, none of the xml data populates either, instead showing {dataset::variable} instead :-s
    removing the above javascript again fixes it.
    so, is there any (other?) way for this fragmented page to load a smaller fragment into the div?
    thanks
    delboy

    How do I open another collapsible panel, on a different page
    through a link? I have tried many different ways, including trying
    to use SpryURLUtils.js and am not having any luck? I really wanted
    to jump to a different pages' collapsible panel, open it, and then
    populate the SpryHTMLPanel, located inside that targeted
    collapsible panel. My collapsible panels and HTML panels all work
    fine on the target page, when just interacting on the page itself,
    with mouseclicks. Inside the collapsible panels I have unordered
    list of links, that populate HTMLpanels, with the appropriate HTML
    fragments. My problems lies in crosslinking from other webpages to
    the exact collapsible panel, and then populating the exact HTML
    fragment, just as if I had clicked on the link in the list, if I
    had been on the target page in the first place.
    <a href="../OA_qi_docreq.html?panel=0#cp1">
    <a href="../OA_qi_docreq.html#cp1">
    <a href="../OA_qi_docreq.html#cp1.open();">

  • How to save image which is inside an applet?

    In my web application, I am displaying some graphs using applet. I wish to let the user save the graphs as images from the browser.
    I would really appreciate if somebody could inform me about this.
    Thanks
    Sachin

    A couple of things...
    1) You will need to sign your applet afterwards, otherwise the user will not be able to save the graphic to their hard drive due to the Java security policy.
    2) I did something similar, a code snippet is below. Mine was a Servlet version though, and sent the buffered stream to a JSP page where it was displayed as a graphic. You can figure out how to modify this so that it goes to a File stream instead... You will
    OutputStream stream;
    BufferedImage bi = new BufferedImage(pieValueObject.getCanvasWidth(),                          pieValueObject.getCanvasHeight(),
    BufferedImage.TYPE_BYTE_INDEXED);
    Graphics2D graphics = (Graphics2D)bi.createGraphics();
    // paint all your stuff on the graphics object created above
    // use a JPEG encoder to actually take what is on the graphics
    // object inside the BufferedImage, and encode it to the stream.
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(stream);
    JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
    param.setQuality(1.0f, false);
    encoder.setJPEGEncodeParam(param);
    encoder.encode(bi);
    // Your graphic is now in the Output stream.

  • Drawing on panels using an applet

    hi could someone take a look at my code and explain why the shapes i have drawn are not showing on the applet. I am totally bewildered with it
    thankyou
    * @(#)JukeBox.java
    * Sample Applet application
    * @author
    * @version 1.00 06/12/26
    import java.awt.*;
    import java.applet.*;
    import java.awt.Graphics;
    public class JukeBox extends Applet
         private Panel topPanel,middlePanel,bottomPanel,drawPanel,pPanel;
         private Button changegenre;
         private Choice ch1,ch2;
         private Label title;
         private CheckboxGroup cb1;
         private Checkbox rock,pop;
         private Button play,stop;
         public void init()
         setLayout(new BorderLayout());
         pPanel=new Panel();
         drawPanel=new Panel();
         topPanel=new Panel();
         topPanel.setLayout(new FlowLayout());
         middlePanel=new Panel();
         middlePanel.setLayout(new GridLayout(3,1,40,5));
         bottomPanel=new Panel();
         bottomPanel.setLayout(new BorderLayout());
         title=new Label("Wurlitzer Jukebox");
         play = new Button("Play");
         stop=new Button("Stop");
         pPanel.add(stop);
         pPanel.add(play);
         drawPanel.add(title);
         cb1=new CheckboxGroup();
         rock=new Checkbox("Rock",cb1,true);
         pop=new Checkbox("Pop",cb1,false);
         middlePanel.add(rock);
         middlePanel.add(pop);
         changegenre=new Button(" Genre");
         middlePanel.add("Bottom",changegenre);
         add("North",drawPanel);
         add("West",middlePanel);
         add("Center",topPanel);
         add("East",bottomPanel);
         add("South",pPanel);
         repaint();
              public void paint(Graphics g)
              g.setColor(Color.yellow);
              g.fillRect(98,30,310,200);
              g.setColor(Color.blue);
              g.fillRoundRect(150,200,200,100,130,150);
    }

    //  <applet code="JB" width = "400" height="400"></applet>
    import java.awt.*;
    import java.applet.*;
    import java.awt.Graphics;
    public class JB extends Applet
        private Panel topPanel,middlePanel,bottomPanel,drawPanel,pPanel;
        private Button changegenre;
        private Choice ch1,ch2;
        private Label title;
        private CheckboxGroup cb1;
        private Checkbox rock,pop;
        private Button play,stop;
        public void init()
            setLayout(new BorderLayout());
            pPanel=new Panel();
            drawPanel=new Panel();
            TopPanel topPanel=new TopPanel();
            topPanel.setLayout(new FlowLayout());
            middlePanel=new Panel();
            middlePanel.setLayout(new GridLayout(3,1,40,5));
            bottomPanel=new Panel();
            bottomPanel.setLayout(new BorderLayout());
            title=new Label("Wurlitzer Jukebox");
            play = new Button("Play");
            stop=new Button("Stop");
            pPanel.add(stop);
            pPanel.add(play);
            drawPanel.add(title);
            cb1=new CheckboxGroup();
            rock=new Checkbox("Rock",cb1,true);
            pop=new Checkbox("Pop",cb1,false);
            middlePanel.add(rock);
            middlePanel.add(pop);
            changegenre=new Button(" Genre");
            middlePanel.add("Bottom",changegenre);
            add("North",  drawPanel);
            add("West",   middlePanel);
            add("Center", topPanel);
            add("East",   bottomPanel);
            add("South",  pPanel);
            // There is nothing to repaint at this point.
    //        repaint();
        // Try this.
        // The original topPanel was covering up your drawing.
        private class TopPanel extends Panel
            public void paint(Graphics g)
                super.paint(g);
                g.setColor(Color.yellow);
                g.fillRect(98,30,310,200);
                g.setColor(Color.blue);
                g.fillRoundRect(150,200,200,100,130,150);
    }

Maybe you are looking for

  • Is there any way to find SHMMAX used by the system? sysdef is not useful.

    Since the SHMMAX is obsolete we could not set it. Also we are not able to find a way to current value that is used by system for SHMMAX(sysdef is not giving any value). Is there any other way to find out it's current value?

  • Photo gallery show the exif information

    Hi Is it possible to show any information in every photos i upload to iWEB when people click on my photos. Thanks kpo

  • Spoken Podcast compression problem

    For the podcast I host I've always edited the audio in Soundtrack Pro and then imported the AIFF audio file into iTunes to compress using the AAC Spoken Podcast preset. This worked great for years but ever since iTunes 9 was released the audio sounds

  • Iphone video creation and iphone freeze

    I have and Iphone 3G S running in OS 4.0.0. Yesterday, I was taking a video with the original software of Iphone (no third party applications for camera are installed in my Iphone), then when I was ten minutes recording continuously, suddenly appears

  • Forms 2 j2ee migration

    Hi, We are in the process of migrating (web) Forms/Reports 6i app to the J2EE framework. It looks like the number of source files will increase 10 folds. For each and every .fmb (or .rdf) we will have about 10 new .java sources. The migrated app will