Resizing Applets

I've another question. I wont be suprised actually if
you start ignoring my mails but I'll keep chancing my
arm until then.
This applet SHOULD create musical sheet music, by
selecting keys on a virtualy keyboard or chords from a
drop down box. IT WORKS PERFECTLY AS A FRAME
PROBLEM: when i converted the code to applet: the
applet isn't big enough to show the stave(i.e. 5
paralled lines on whihc music is written) and the
keyboard and the edit box. Problem is once i ressize
the applet (manually clicking and dragging) i get an
exceptipon error and nothing works after that.
BASICALLY: WHEN THE APPLET OPENS AND I CLICK A KEY OR
SELECT A CHORD THEN RESIZE THE APPLET SO I CAN SEE THE
STAVE I CAN SEE THE NOTE I JUST ENTERED BUT CAN'T
ENTER ANYMORE AFTER THAT.
I'm not asking you to fix it, but if you have any idea
why that happens I'd be delighted.
to see what I mean go to:
http://musicmaker.compsoc.com
choose C.P. (on right of screen)
choose WRITE (on top of screen)
or go straight to
http://musicmaker.compsoc.com/Write.htm
here's the construnctor of the main class:
public Write1302A() {
initComponents ();
Box box = Box.createVerticalBox();
     getContentPane().add(box);
getContentPane().show();
getContentPane().setSize(550,600);
//stave diagram
pane*****************************
//displays appropriate stave diagram
staveDiagramPane = new JPanel(new
BorderLayout());
staveDiagramPane.setLocation(10,10);
staveDiagramPane.setBounds(0,0,400,150);
box.add(staveDiagramPane);
//keyboard pane*****************************
JPanel kbPane = new JPanel(new
BorderLayout());
kbPane.add(virtualKeyboard);
kbPane.setLocation(200,20);
box.add(kbPane);
//input pane**********************************
     //will show user entered chord name
inputPane = new JPanel(new FlowLayout());
label =new JLabel( "Enter Chord Name");
input = new JComboBox(names);
input.setMaximumRowCount(35);
input.addItemListener( new ItemListener(){
public void itemStateChanged(ItemEvent e)
int s = input.getSelectedIndex();
buildInput(s,1);
label2 = new JLabel("Note Name:");
noteNameText = new JTextField(5);
noteNameText.disable();
inputPane.add(label2);
inputPane.add(noteNameText);
inputPane.add(label);
inputPane.add(input);
inputPane.setLocation(240,20);
box.add(inputPane);
//****refresh
button**************************
buttonPanel = new JPanel();
buttonPanel.setLayout(
new GridLayout(1,1));
refresh = new JButton("Refresh");
refresh.addActionListener(new
ActionListener(){
public void actionPerformed(ActionEvent e)
refresh();
buttonPanel.add(refresh);
box.add(buttonPanel);
setVisible(true);

I'm not sure to understand all, but the size of an applet is defined in the html page

Similar Messages

  • Resize applet within a HTML frame

    Hi,
    I am using an applet to display a tree in a HTML frame of a web page.
    I would like to resize or refresh the applet when the HTML frame is resized. Is there a way for the applet to know when the HTML frame is resized?
    Any help will be appreciated.
    Thanks

    I tried using the componentResized() method to solve this problem but I was unsuccessful.
    Here is what I tried:
    My application consists of using a Java applet to display a tree in a HTML frame. In addition I put the tree in a scroll pane. I tried using addComponentListener(this) to get the componentResized() method to be involked. I tried adding the component listener to the scroll pane:
    JScrollPane treeView = new JScrollPane(tree);
    treeView.addComponentListener(this);
    I tried adding the component listener to the root pane:
    JRootPane root = getRootPane();
    root.addComponentListener(this);
    and I tried adding the comoponent listener to the glass pane and the content pane.
    The componentResized() method was involked when the tree was initially displayed in some of my attempts but I was never able to get the componentResized() method to be involked when I resized the html frame.
    I believe that I am having a problem determining which component to add the addComponentListener to so that the componentResized() method get invoked when I resize the html frame.

  • Resize applet - more info

    I want to be more specific: i have a class that extends applet to this class i added two panels. to one of the panels i added 100 buttons, to the other 4 labels.
    i have also a class that extends frame, in order to run my applet as an application. i added to this frame my applet, when i create a new instance of the applet the constructor add's all the panels and buttons.
    In order that when i resize the frame also the applet including all its panels and buttons will be resized, i added to the frame a componentlistener and called setsize in my applet with the appropiriate dimenstion, it seemd to work, but the panels didnt resize, so i overlapped in my applet the setsize method and added pnael.setsize for the two panels but it still doesnt work.What is the right way to do this??

    >
    In order that when i resize the frame also the applet
    including all its panels and buttons will be resized,
    i added to the frame a componentlistener and called
    setsize in my applet with the appropiriate dimenstion,you don't need a componentlistener - the LayoutManager of the Frame (a BorderLayout) takes care of the resizing of the applet
    it seemd to work, but the panels didnt resize, so i
    overlapped in my applet the setsize method and added
    pnael.setsize for the two panels but it still doesnt
    work.What is the right way to do this??wookash is right, you'll need to set the correct LayoutManager in your applet (its currently a FlowLayout)
    I think you should use an GridLayout in the Applet
    for example:
    myApplet.setLayout(new GridLayout(1,2));
    myApplet.add(panel1);
    myApplet.add(panel2);

  • Win98 need to resize applet viewer to see forms client

    Is there any work around that will aliviate the problem of needing resize the applet viewr (JInitiator) manually to see the java applet?
    This is consistent bug and it seems to appear on all of our Win98 clients (WinNT works fine) in both IE 5.0 and Netscape 4.0

    There is a work around for this problem by using the resize_window(FORMS_MDI_WINDOW, height, width) you can force the refresh of the applet window. The ability to use the resize_window on the MDI window web deployed was supposedly just made available with patch 5. I had the same problem and this fixed it for me.

  • Problem "resizing" applet

    Can someone please help me with resizing an applet. I can't figure out how to decrease or increase the applet more than once. If the "smaller" button is clicked, the applet decreases in size only once. If the "bigger" button is clicked, the applet increases only once. What I need to accomplish is that everytime the "smaller" button is clicked, the size of the applet (both width and height) should be decreased by 10 pixels and everytime the "bigger" button is click, the size of the applet (both width and height) should be increased by 10 pixels. I have attached the code below. Any help will be appreciated....Thanks in advance.
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Resizable extends Applet implements ActionListener {
    int apWidth = 0;
    int apHeight = 0;
    private Label myLabel;
    private TextField myText;
    private Button sButton;
    private Button bButton;
    public void init() {
    apWidth = getSize().width;
    apHeight = getSize().height;
    myLabel = new Label("Applet Size Is: ");
    add(myLabel);
    myText = new TextField(8);
    myText.setText("200 100");
    myText.setEditable(false);
    add(myText);
    sButton = new Button("smaller");
    sButton.addActionListener(this);
    add(sButton);
    bButton = new Button("bigger");
    bButton.addActionListener(this);
    add(bButton);
    public void actionPerformed(ActionEvent e) {
    if (e.getSource() == sButton) {
    myText.setText("30 30");
    this.setSize((apWidth - 10), (apHeight - 10));
    else {
    myText.setText("90 90");
    this.setSize((apWidth + 10), (apHeight + 10));
    }

    not sure about this but try this:
    public boolean actionPerformed(ActionEvent e) {
    if (e.getSource() == sButton) {
    myText.setText("30 30");
    this.setSize((apWidth - 10), (apHeight - 10));
    else {
    myText.setText("90 90");
    this.setSize((apWidth + 10), (apHeight + 10));
    return(true);

  • JProgressBar leaves double behind when browser resized (Applet)

    I have an applet that runs inside the browser (IE). It has a progress bar. If I initially open the browser without having it maximized, let the applet load and run the program such that the progress bar starts, an then resize the window, the progress bar shows up towards the upper left corner as it should, but it also continues to show up in the space it was before, which means it is now over other components. The old "double" does not update it's value as the correct one does, but keeps the value in it that it was when it started. I am updating the progressbar using SwingUtilites.invokeLater. Please let me know any ideas you may have, or sections of code I should post to help out. Here is the code that updates the panel
    private void updateStatus(final int i, final JProgressBar progressBar)
         Runnable update = new Runnable()
                        public void run()
                             progressBar.setValue(i);
         SwingUtilities.invokeLater(update);

    I am not moving the progressbar. It resides on a panel in my applet.
    My applet's contentpane has a border layout. In the WEST position, I have a panel. This panel also has a border layout. It has a JList (in a scroll pane) in the CENTER position, and it has the progressBar in the NORTH position:
    nodeListPanel.add(nodeScroll, BorderLayout.CENTER);
    nodeListPanel.add(listProgress, BorderLayout.NORTH);The progress bar moves when the browser window moves. The details should be done by the layout manager. All of my other components appear correctly after the window is resized, only the progress bar leaves a double.
    The only difference between the progress bar and my other components, that I can think of, is that it is, of course, constantly updated, whereas the others are updated at one particular instant in time, which is unlikely to coincide exactly with the resizing of the window.
    Here is the code that starts the process that updates the progress bar.
    * Gets the List of Nodes of all nodes in the database.
    private void getNodeListData()
       Runnable r = new Runnable()
            public void run()
              Runnable r2 = new Runnable()
                 public void run()
                            //disable some buttons
                   filteringList = true;
                   nodeList.clear();
                       SwingUtilities.invokeLater(r2);
                 Creator create = panel.getCreator();
                 final Vector newNodes = create.getAllNodes(apply, listProgress);
                 Runnable r3 = new Runnable()
                          public void run()
                        nodeList.setData(newNodes);
                        filteringList = false;
                        //Enable some buttons                                        }
                     SwingUtilities.invokeLater(r3);
         Thread getNodes = new Thread(r);
         getNodes.start();
         return;
    }

  • Netscape Window Resize/Applet Reload Problem

    Is there anyway to keep a java applet from restarting when a Netscape window is resized? This problem doesn't happen in IE.

    In my case, someone told me to eliminate in applet's HTML this directives:
    <META HTTP-EQUIV="Pragma" CONTENT="No-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <META HTTP-EQUIV="Cache-Control" CONTENT="must-revalidate">
    <META HTTP-EQUIV="Cache-Control" CONTENT="mag-age=0">
    Further, to set in Preferences/Advanced/Cache the option "Once per session" for "Document in cache is compared to document to network"
    Believe me, in my case, it's worked with no aditional changes in the original applet's code. (Don't thank to me, my chilean friend Christian was the magician).

  • Resizing applet

    Hi,
    I have an applet which is quite large, when you run the applet using appletviewer it fills the whole screen, this means when I run the applet in an HTML document it is partly obscured and you have to scroll. I know you can size the applet in HTML but this will obscure it. It means I have to resize the layout in java, which would mean resizing every component etc (there are a few). I would like the applet to open and just fill the bowser screen. Is there an easy way around this.
    cheers
    macnero

    1. Use a layout
    2. Use constants for the frame size
    3. Allow Java to "fit" all of the components in the frame, don't explicitly try to assign sizes of you don't need to do so.

  • CANNOT RESIZE APPLET

    Hello
    I was wondering if anyone could tell me why I cannot adjust an applet,sometimes I cannot see things at the bottom of the applet page because it is not long enough but I cannot make it longer to view what is at the bottom because it has no scrollbars,I have reinstalled both 1.4 plugin and JESE 5,I really don't know which to use,is there another smaller plugin to try for games?,I know that I used to be able to pull dpwn the page with the mouse or use scrollbars but I cannot do either now ,this happened after I updated last year.

    Are you talking about the grey bar at the bottom of yahoo games that says java applet window? this bar keeps me from having conversations with my opponent while playing literati, its also under their profile box. Its annoying and i cannot see my score either

  • Resize Applet Window - How?

    I know how to set a specific size by numbe for an applet window,
    but I would like to know if there is a way of telling the applet window to open in full view mode - like instead of saying open (650, 650) in a separate window, I would like it to take up the entire screen to the exact size of the screen in the internet explorer browser.

    Hi,
    This forum is for discussions related to Sun Java Studio Creator. Please post your query in the appropriate forum. You can try posting your query at:
    http://forum.java.sun.com/forum.jspa?forumID=421
    Cheers
    Girish

  • Filling Background for Applet

    Hi everyone,
    I created Applet1 that I just had to fill in the background (blue) of the applet and after resizing the applet by using appletviewer, the applet is still filled entirely with blue.
    So I use fillRect method with d.width, d.height (Dimession d = getSize())
    It worked OK by using appletviewer.
    For example:
    First time after loading: 500 x 500: applet is blue
    Resizing applet (appletviewer) to 600 x 700 : applet is still blue
    Good, that I expected.
    Unfortunately, the applet is flickering!
    In order to avoid the flickering problem, I created Applet2 that extends the Applet1 but it used offscreen image.
    When I run this Applet2, I did NOT see the flickering anymore. Cool!
    However, another problem appeared.
    After I resizing, the applet was not totally filled with blue. It was only filled the area when it loaded first time, that mean it was filled in area 500 x 500 no matter I resizing the applet bigger or smaller.
    So please help me so the this Applet2 can be filled entirely after resizing the applet (again, this Applet2 extends Applet1)
    Thank you so much.

    Stop using an applet viewer, they are the work of the devil. Also, instead of using a fill rect, just change the background color. You also have the fillrect method in the wrong place anyways.

  • Resize() of applet is not working properly in java6.0

    Hi iam new to applets i have given one task,that is to display multiple tiff pages in applet, So i have written one applet which displays multiple pages tiff file, i have kept next and previous buttons in the applet to navigate to different pages and here iam using resize() of applet for refreshing applet up to now all fine this all thing i have done in java5.0, but i got a requirement to do in java6.0, in java6.0 applet is not refeshing in the webpage.
    i found the reason that resize() is not working properly.
    Please can someone help me..........
    Thanks&Regards
    Manmohan A

    Dear Aravindth
      (.*?) means -> Select all contents from where you start and end,
    For Ex. <month>(.*?)</month> then Select for start <month> and end last </month> tag.
    (?) Match zero or one occurrences. Equivalent to {0,1}.
    (*) Match zero or more occurrences. Equivalent to {0,}.
    (+) Match one or more occurrences. Equivalent to {1,}.
    (.) (Dot). Match any character except newline or another Unicode line terminator.
    (.*?) means -> Zero or more times Match any character except newline or another Unicode line terminator + Match zero or more occurrences. Equivalent to {0,}.+Match zero or one occurrences. Equivalent to {0,1}.
    Could you please refere the below cite :
    http://www.javascriptkit.com/jsref/regexp.shtml
    Thanks & Regards
    T.R.Harihara SudhaN

  • Avoiding applet main window resizing when using browser zoom?

    Hello, I haven a applet embedded into a jsp page into an APPLET tag, with a fixed height and width, same values as the JPanel has on the applet with all the elements inside of it, my problem is, that if I use the browser zoom, the JPanel respects width and height but JApplet window does not, and increases until I stop zooming the site, I'd like to avoid this, I already tried by setting these parameters on the init function on the JApplet class:
    this.setSize(593, 468);
    this.setMaximumSize(new Dimension(593,468));
    this.setMinimumSize(new Dimension(593,468));
    this.setBounds(0, 0, 593, 468);
    this.setPreferredSize(new Dimension(593,468));
    But it does not work, is there something like a this.setResizable(false) for the JApplet class? I understand that JApplet is a subclass of JFrame isn't? please, any idea would be highly appreciated, have a nice day!!

    saman0suke wrote:
    So far I have the layout as NULL,Java doesn't have a NULL. Presumably you have a null layout. Don't do that/ Learn how to use layout managers and maybe you won't have a problem with the container being resized.
    db

  • Applet not draw anything after resizing

    Hello.
    We have applet, which show tree manualy in it.
    And it works fine for JRE1.4.2_05.
    But after swithing to JRE1.5.0_03 we have problem:
    It is not draw anything(blank window) after resizing.
    But if we move other window over it or hide/show browser with applet, then it show content normally.
    Is it a bug of JRE1.5.0_03 ? And how we can solve this problem?

    Yeah I got similar problem with 1.5. The problem is Applet's Paint method is often called incorrectly after resizing. My case is that when I drag(resizing) the applet by its top border, it is first displayed with previous size(overlapping other frame). Folks here do not know how to resolve this.

  • Components Resizing to follow width of applet

    Hi,
    does anyone know how i can stop components from resizing to follow the width of the applet they are in once i have grabbed the applets edges?
    Thanks
    Richard.

    Darryl.Burke gave some excellent advice.
    Still, I am prepared to go out on a limb and make a WAG that you are talking about a floating applet.
    This occurs in three cases..
    1) The applet is in development/testing and launched by applet viewer.
    2) The applet is deployed, and launched using webstart (also shown using applet viewer).
    3) The applet is targeted at a 1.6.0_10+ VM, and has a JNLP file specified - so it is dragable.
    In the first case, it is irrelevant if the applet will become a 'plain old embedded' applet, which is (usually) not resizable.
    In the second and third cases, you probably need to look to the layouts used for the components. To prevent the components from resizing, either a FlowLayout or BoxLayout would probably be required.
    As an aside, one way to indicate interest in a solution is to add [Duke stars|http://wikis.sun.com/display/SunForums/Duke+Stars+Program+Overview], though DB's advice will get you further. I recommend doing/acting on both.
    Edited by: AndrewThompson64 on Aug 28, 2008 11:05 AM

Maybe you are looking for