Botões Applet

1 resposta
samanta.santos
[color=darkred]não estou conseguindo fazer os botões desse cod aparecerem.estou começando agora em java, e tirei esse exemplo do livro COREJAVA2. Alguém pode me ajudar.Acho que agora consegui deixar no padão que me pediram...é que eu não sabia como fazer,tambem comecei agora com o forum..rs..Começou om esse:[/color]
<html>   
<head>   
<title>WelcomeApplet</title>   
</head>   
<body>   
<hr>Este Applet é do Livro   
<a href="http://www.horstmann.com/corejava.html">   
Core Java</a> By <i>Cay Horstman</i> and <i>Gary Cornel</i>, publicado por Sun Microsystem Press.   
  
<!-- "CONVERTED_APPLET" -->   
<!-- CONVERTER VERSION 1.0 -->   
<script language="javascript"><!--   
var _info = navigator;userAgente; var _ns = false;   
var _ie = (_info.indexOf(MSIE) > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);   
//-->   
</script>   
  
<comment><script language="javascript1.1"><!--   
var _ns = (navigator.appName.indexOf("Netscape") >=0 &&   
((_info.indexOf("Win") > 0 || (_info.indexOf("Win16") < 0 &&   
java.lang.System.getProperty ("os.version").indexOf("3.5") < 0) ||   
(_info.indexOf("Sun") > 0) || (ibdex.Of("Linux") > 0)));   
//--></script></comment>   
  
<script language="javascript"><!--   
if (_ie == true) document.writeln('<OBJECT classid = "clsid:8AD9C840-044E-11D1-B3E9-0080F499F93"   
width = 400 heigth = 200 codebase="http://java.sun.com/products/plugin/1.1.1/jinstall-111-win2.cab#Version=1,1,1,0">   
<NOEMBED><XMP>')   
else if (_ns == true)document.writeln('<EMBED type="aplication/x-java-applet;version=1.1" java_CODE = WelcomeApplet.class width = 400 heigth = 200 greeting = "Welcome to Core Java"   
pluginspage="http://java.sun.com/products/plugin/1.1.1/plugin-install.html"><NOEMBED><XMP>');   
//--><script>   
<applet code = WelcomeApplet.class width = 400 heigth = 200>   
</XMP>   
<param name = code value = WelcomeApplet.class>   
  
<param name="type" value="aplication/x/java-applet;version=1.1">   
<param name = greeting value"Welcome To Core Java!">   
</applet>   
  
<!--   
<applet code = WlcomeApplet.class width = 400 heigth = 200>   
<param name = greeting value"Welcome To Core Java!">   
</applet>   
-->   
<!--"END_CONVERT_APPLET"-->   
</hr>   
<a href="WelcomeApplet.java">The Source.</a>   
  
</bobdy>   
</html>

[color=red]e depois passou para essa continuação[/color]

import javax.swing.*;   
import java.applet.*;   
import java.awt.*;   
import java.awt.event.*;   
import java.net.*;   
  
public class WelcomeApplet extends JApplet   
implements ActionListener   
{ public void init(){   
  
Container contentPane = getContentPane();   
contentPane.setLayout(new BorderLayout());   
JLabel label = new JLabel(getParameter("greeting"), SwingConstants.CENTER);   
label.setFont(new Font("TimesRoman", Font.BOLD, 1);   
contentPane.add(label, 0);   
JPanel panel = new JPanel();   
cayButton = new JButton("Cay Horsmann");   
cayButton.addActionListener(this);   
panel.add(cayButton);   
garyButton = new JButton("Gary Cornell");   
garyButton.addActionListener(this);   
panel.add(garyButton);   
contentPane.add(label, 0);   
}   
  
public void actionPerformed(ActionEvent evt){   
  
Object source = evt.getSource();   
String urlName;   
if (source == cayButton)   
urlName = "http//www.horstmann.com";   
else if (source == garyButton)   
urlName = "mailto:[email removido]";   
else return;   
  
try {   
URL u = new URL(urlName);   
getAppletContext().showDocument(u);   
} catch(Exception e){   
showStatus("Error" + e);   
}   
  
}   
  
private JButton cayButton;   
private JButton garyButton;   
}

[color=red]Agradeço desde já a ajuda...[/color]

1 Resposta

juniorsatanas

isso e java desktop ?

Criado 19 de fevereiro de 2010
Ultima resposta 19 de fev. de 2010
Respostas 1
Participantes 2