Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can i restrict applet to be resized

 
Deepak Gavkar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't want to allow user to resize the applet while running. I used setSize(x, y); method but didn't worked and getting problem with setResizable(false); method.
Simple program i have written for testing but not working please help me out anyone. Thanks in advance.

My program code given below :

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class Great extends Applet implements ActionListener
{
Label l1,l2,l3;
TextField t1,t2,t3;
Button b1,b2;
public void init()
{
setLayout(new GridLayout(4,2));
l1=new Label("First Number : ");
add(l1);
t1=new TextField(10);
add(t1);
l2=new Label("Second Number : ");
add(l2);
t2=new TextField(10);
add(t2);
l3=new Label("Result : ");
add(l3);
t3=new TextField(10);
add(t3);
b1=new Button("Compare");
add(b1);
b2=new Button("Clear");
add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
int n1,n2;
n1=Integer.parseInt(t1.getText());
n2=Integer.parseInt(t2.getText());
if(n1>n2)
{
t3.setText("The first value is greater");
}
else
{
t3.setText("The second value is greater");
}
}
if(ae.getSource()==b2)
{
t1.setText("");
t2.setText("");
t3.setText("");
}
}
}

/*<applet code="Great.class" height=200 width=350></applet>*/
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code doesn't open a new window, so what could the user even be resizing?
 
Deepak Gavkar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:The code doesn't open a new window, so what could the user even be resizing?


Actually, But i want to disable resizing for the running applet cause when you try to resize it the components are misplaced and GUI is not good. I think you get it what i actually want to do.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I don't get it. Again:

The code doesn't open a new window, so what could the user even be resizing?


The last line with the applet tag suggests you're running this through appletviewer, which would be a scenario that you don't need to worry about.
 
Deepak Gavkar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Actually, I don't get it. Again:

The code doesn't open a new window, so what could the user even be resizing?


The last line with the applet tag suggests you're running this through appletviewer, which would be a scenario that you don't need to worry about.


Hmm..Thanks for replying buddy.. ....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic