• Post Reply Bookmark Topic Watch Topic
  • New Topic

Not able resize a Frame in AWT applet

 
Suman Mummaneni
Ranch Hand
Posts: 96
Android Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a problem with re-size of the AWT Applet  Frame when Frame.setResizable(false) is set and I want the frame to resize based on the component size that is present in side it. Since its using BorderLayout by default.
I see this problem only on RHEL 6.0 based machine not any other machines with Java 8.
Also please advise me on how to install Java on a RHEL 6 machine manually.

Steps to recreate:
--------------------
Increase the font size to a value >=20 and check if the screen would re-size.
Decrease the font size to it previous value i.e. 12 or 14.
Repeat above steps two are three times you will see the problem.

Here is the code. Please correct me if I missed some thing here. I have removed the Applet and made it as a normal application but I still see the issue.


 
Campbell Ritchie
Marshal
Posts: 52543
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using applets? Nobody has used them for years, and most browsers no longer support them.
Don't use AWT components; again nobody has used them for about fifteen years.

I would have thought that Java® came ready installed with RHEL. Run the following four commands at a terminal and tell us their outputs:-
which java
which javac
java -version
javac -version
 
Campbell Ritchie
Marshal
Posts: 52543
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why did you call that an applet? Where are you using applets?
 
Campbell Ritchie
Marshal
Posts: 52543
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you setting the size of your canvas? If you use screen width and screen height, won't you set it to fill the whole screen regardless?
 
Suman Mummaneni
Ranch Hand
Posts: 96
Android Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Applet was written very long time ago. I think 20 years back we are now seeing problem with it. With UI and Fonts. The actual application simulates a remote terminal, where you can get a remote session to a machine like Putty.

The canvas is re-sized based on the font size, there is menu that shows the fonts and the sizes. It will resize the canvas based on it. I am creating a new Image using this font and setting it to the canvas.

I think one suggestion is to move to Swing, I am not sure but I can try that and check if it solves my problems.

Here are the results for Java:
bash-4.1# which java
/usr/bin/java

bash-4.1# java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build pxa6480sr1fp10-20150711_01(SR1 FP10))
IBM J9 VM (build 2.8, JRE 1.8.0 Linux amd64-64 Compressed References 20150630_255633 (JIT enabled, AOT enabled)
J9VM - R28_jvm.28_20150630_1742_B255633
JIT  - tr.r14.java_20150625_95081.01
GC   - R28_jvm.28_20150630_1742_B255633_CMPRSS
J9CL - 20150630_255633)
JCL - 20150711_01 based on Oracle jdk8u51-b15

bash-4.1# javac -version
javac 1.8.0-internal
bash-4.1#

 
Campbell Ritchie
Marshal
Posts: 52543
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might do well to move to JavaFX; otherwise in two years you may find you have to migrate the app again.
I searched for the name of your Java installation, which is obviously 1.8, to see whether it was the recent update, but didn't find anything. I thought the IBM runtime was fully compliant with the JLS so it ought to do what you want.
The way I install Java on Fedora is like this:-
  • 1: Make a java folder somewhere and if I don't already have full access use chown to get access.
  • 2: Download the JDK as a tar.gz
  • 3: Unzip it into my java folder.
  • 4: Add the new directory beginning / and ending bin to the PATH in my ~/.bashrc file.
  • 5: I can delete the .tar.gz and the previous jdk directory if I wish.
  • I ran your code and it changed size when I changed the font, using
    java -version
    java version "1.8.0_92"
    Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
    Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
    The frame wouldn't resize; I looked up this method and it says frames default to being resizable.
     
    Suman Mummaneni
    Ranch Hand
    Posts: 96
    Android Java Mac
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    We are planning to move the application to JNLP based RIA then I think we would need to move it as Java FX app.
    I ran the code on several platforms and the re-size happens properly. I only see the issue on Linux specific RHEL 6.0. Ubuntu also worked fine. Not exactly sure what the problem is, we are using IBM JDK 1.8.

     
    Campbell Ritchie
    Marshal
    Posts: 52543
    119
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Well, I was on Feroda 24, which is related to RHEL, but isn't it weird that there should be a RH/Fedora problem like that.
    Sorry I can't help more.
     
    Suman Mummaneni
    Ranch Hand
    Posts: 96
    Android Java Mac
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for your help Campbell.
    I have raised a bug for this with IBM JDK internally. They say the Window event for size are not set properly when the font is changed.
    This issue is with JDK 6, 7 and 8. They are still working on this issue. Just an update I am using fluxbox as X11 window manager.
    Also found that Java 7 and 8 has issue with Font configuration, the standard way does not work on Linux. This bug is reported and not taken care till now, its expected to spill over to JDK 9 releases as well.
    FYI bug link.
     
    Campbell Ritchie
    Marshal
    Posts: 52543
    119
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    My pleasure, and sorry I wasn't more helpful. But I had the same problem using the Oracle JVM.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!