• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do make the applet taller then it is wide?

 
erich brant
Ranch Hand
Posts: 246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I would Like to make the applet a vertical rectangle so
it is taller then it is wide.
When I reverse the html height and width
the buttons are to narrow.
here is all the code below
Also the appletviewer does not like this applet
( I get a claspath error I guess I should reinstall
the jdk ?)
I also get a class format error with netscape 4.7
But the HotJava Browser and IE 5 can run the applet !

//////////////////////////////

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.net.*;
public class BestFreeDownloads extends Applet implements ActionListener {
boolean badURL;
public void init() {
GridLayout layout = new GridLayout(4, 2, 10,10);
setLayout(layout);
Font font = new Font(" TimesRoman ", Font.PLAIN, 10);
setFont(font);

//=====================================
Button button = new Button(" Quake 3 Arena Demo");
button.setActionCommand("http://www.quake3arena.com ");
button.addActionListener(this);
add(button);
//=====================================

button = new Button(" Unreal Tournament Demo" );
button.setActionCommand(" http://www.unrealtournament.com");
button.addActionListener(this);
add(button);
//=====================================
button = new Button(" Soldier of Fortune Demo" );
button.setActionCommand(" http://www.ravensoft.com/sof.shtml " );
button.addActionListener(this);
add(button);

//=====================================

button = new Button(" Star Trek Elite Force demo ");
button.setActionCommand("http://www.ravensoft.com/eliteforce/ ");
button.addActionListener(this);
add(button);
//=====================================
button = new Button(" Quake 1 shareware ");
button.setActionCommand(" http://www.fileplanet.com/index.asp?section=105&file=6577 8.7 megs " );
button.addActionListener(this);
add(button);
//======================================
button = new Button(" Doom 1 shareware " );
button.setActionCommand("http://www.doomworld.com/files/shareware.shtml ");
button.addActionListener(this);
add(button);
//======================================
button = new Button(" Heretic 1 shareware");
button.setActionCommand("http://www2.ravensoft.com/source/heretic.zip ");
button.addActionListener(this);
add(button);
//======================================
button = new Button(" Heretic 2 demo " );
button.setActionCommand("http://www.hereticii.com/files.shtml ");
button.addActionListener(this);
add(button);

//========================================
button = new Button(" GameSpy " );
button.setActionCommand(" http://www.gamespy.com " );
button.addActionListener(this);
add(button);

//======================================

button = new Button( " GameSpy Arcade ");
button.setActionCommand(" http://www.gamespyarcade.com " );
button.addActionListener(this);
add(button);

//======================================
button = new Button(" Java xml jdom" );
button.setActionCommand(" http://www.jdom.org ");
button.addActionListener(this);
add(button);
//======================================

button = new Button(" Java JDK ");
button.setActionCommand(" http://www.javasoft.com ");
button.addActionListener(this);
add(button);
//======================================
button = new Button(" Java Enterprise");
button.setActionCommand("http://java.sun.com/j2ee ");
button.addActionListener(this);
add(button);
//======================================
button = new Button(" Thinking in Java " );
button.setActionCommand("http://www.bruceeckel.com ");
button.addActionListener(this);
add(button);
//=======================================
button = new Button(" Java Enterprise \n Blueprints \n & Platform Specs ");
button.setActionCommand("http://java.sun.com/j2ee/download.html " );
button.addActionListener(this);
add(button);
//=======================================
button = new Button(" Advanced Java \n programming book" );
button.setActionCommand("http://developer.java.sun.com/developer/onlineTraining/Programming/JDCBook/index.html ");
button.addActionListener(this);
add(button);
//=======================================

button = new Button(" Mandrake Linux ");
button.setActionCommand(" http://www.mandrake.com ");
button.addActionListener(this);
add(button);
//=======================================
button = new Button(" Apache webserver ");
button.setActionCommand(" http://www.apache.org" );
button.addActionListener(this);
add(button);
//=========================================

button = new Button(" Download StarOffice ");
button.setActionCommand(" http://www.sun.com/staroffice " );
button.addActionListener(this);
add(button);
//==========================================
button = new Button( " Netscape ");
button.setActionCommand(" http://www.netscape.net" );
button.addActionListener(this);
add(button);
//==========================================
button = new Button(" How to's and \n tutorials on linux" );
button.setActionCommand(" http://www.linuxdoc.org" );
button.addActionListener(this);
add(button);
//===========================================
button = new Button(" Firewall zonealarm ");
button.setActionCommand(" http://www.zonealarm.com ");
button.addActionListener(this);
add(button);
//=============================================

button = new Button(" MusicMatch");
button.setActionCommand(" http://www.musicmatch.com " );
button.addActionListener(this);
add(button);
//=============================================

button = new Button(" Winzip ");
button.setActionCommand(" http://www.winzip.com");
button.addActionListener(this);
add(button);
//============================================

badURL = false;
}
public void paint(Graphics g) {
if (badURL)
g.drawString("Bad URL!" , 90, 160);
}
public void actionPerformed( ActionEvent event) {
String pageName = event.getActionCommand();
try {
URL url = new URL(pageName);
AppletContext context = getAppletContext();

context.showDocument(url);
}
catch( MalformedURLException e) {
badURL = true;
repaint();
}
}
}
///////////////////////////////////
<html>
<title>Best Free downloads on the Internet Applet</title>
<h1>Best Free downloads on the Web Applet</h1>
<applet code = " BestFreeDownloads.class" width = 1600 height = 200>

</applet>
</html>

 
erich brant
Ranch Hand
Posts: 246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also How do I make a new line within the applets buttons?
\n \r etc.... does not work because it is not a string but
a name of a button!
 
Stephanie Grasson
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Erich,
This is a very nice applet you've written!
To get rid of the class format error with Netscape and the appletviewer problem, just make the following change to your html file:

to

It's a simple typo to have that extra space between the quotation mark and the name of your class file, but I guess Netscape and appletviewer are picky that way.
Also, you say you want to make the applet appear taller than it is wide, but you do not specify the number of rows and columns you need. I noticed in your code the following line:

which doesn't really provide for as many buttons as you declare. Changing it to

makes for a pretty nice layout of 12 rows with two buttons each.
Also, if you change the width and height in the html file to
width = 500 height = 800,
everything lines up pretty well under your title and the applet is definitely taller than it is wide. If this isn't exactly what you had in mind, all you need to do is play around with the GridLayout definition (changing the number of rows and columns to suit your needs) and doing the same with the width and height in the html file.
Anyway, thanks for posting. I hope this helps.
Stephanie

[This message has been edited by Stephanie Grasson (edited October 31, 2000).]
 
erich brant
Ranch Hand
Posts: 246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am going to try your tips now!
also with netscape 6 beta x , is java by default
get downloaded with netscape 6? Because that will help
make java more popular for applets which almost died out.
I am also not sure if IE 5.5 has java support
I do not want to download it because ms does not
let you have 2 versions of ie on the same computer.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic