JDBC & Applets(urgent)
Hi,
On my pc i have installed only JDK 1.1.6. Do i need to install some more plugins for my JDBC connection to work on my applet?Do i need to have the SDK?
Please reply
JDBC connection to work on my applet?How are you running the applet? How do you intend to run the applet?
If you are running in the AppletViewer then you have everything you need.
An applet to jdbc connection should never be used over the internet regardless of the connection type used. So if that is your intent I suggest you re-think the design.
Running 1.1.6 jdbc in a browser is significantly different than for 1.2. I am not sure what needs to be done. Either it is very easy or you need to write your own Security Manager.
Similar Messages
-
Hi,
I have created an application by using JDBC,now i would like to convert this application into applet and put it online. So i register a domain name, create a jar file for this application and use browser to load it. But so far from what i know, online features have to be done by using JSP,so is it possible to use JDBC to connect to database and do functions online?If not,it means i have to replace JDBC by JSP?
Thanks for any help.Hi
Please make note of some points:
1. You can very well create your application as an Applet and then connect to a database through JDBC.
2. If you think you can make use of the server resources properly you can go ahead with your applet. Otherwise you can switch to JSP, but you may not get any useful resources like Swing, JFC and other stuff through plain jsp, for all these you need an applet as a container for these.
The problems you are facing is because applets are not secure, you need to sign your applet so as to make use of the system resources available and the applet to interact with your client machines. when you create your jar file you have to sign it using the jarsigner bound to a security certificate installed. Through java you can create your own self signed certificate with the keytool option available in your jdk. Then you have to use the HTMLConverter and pass the HTML file containing the applet tags pointing to your class file, this will convert the applet into browser readable format. Then you are all set, open the applet through your browser and <b>BINGO</b> you are up and moving.
If you have any more doubts please feel free to ask me.
Thanks
Swaraj -
How to connect Applet to JDBC driver (urgent !!!)
Hi,
I had problems getting the applet connected to a database in the server using JDBC. When I run the applet in appletviewer I got the error msg :
"Exception occurred during event dispatching:
java.security.AccessControlException: access denied (java.lang.RuntimePermission
accessClassInPackage.sun.jdbc.odbc "
.....this error refers to the line in my source code:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Please help , thank you!Join this topic:
http://forum.java.sun.com/thread.jsp?forum=48&thread=178759 -
DOM parsing In Applet (URgent)
Is it possible to implement DOM parsing in Applet?
I am getting classnotfoundException .
I am giving the code below. pl read the code.
Applet.(parserapplet.java)
=========================
import java.io.*;
import java.awt.*;
import java.net.*;
import java.util.*;
import java.applet.*;
import com.security.*;
// for DOM parsing ....
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.w3c.dom.Document;
import org.w3c.dom.DOMException;
public class parserapplet extends Applet
public void init()
public void start()
try
if (Class.forName("com.ms.security.PolicyEngine") != null)
{ // required for IE
PolicyEngine.assertPermission( PermissionID.SYSTEM );
catch (Throwable cnfe)
System.out.println("Policy Engine Exception: " + cnfe);
try
String str = "<?xml
version=\"1.0\"?><html><body></body></html>";
ByteArrayInputStream bis = new
ByteArrayInputStream(str.getBytes());
System.out.println("After creating input stream");
BufferedInputStream bufIn = new BufferedInputStream(new
DataInputStream(bis));
parseXMLMessage (bufIn);
catch(Exception e){}
// Actual DOM parsing goes here.....
public void parseXMLMessage(InputStream xmlMessage)
Document document = null;
DocumentBuilder documentBuilder = null;
DocumentBuilderFactory documentBuilderFactory = null;
try
documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilder = documentBuilderFactory.newDocumentBuilder();
document = documentBuilder.parse(xmlMessage);
System.out.println("Document node: " + document);
catch(FactoryConfigurationError fce)
System.out.println("Exception Factory configuration error " + fce);
catch(ParserConfigurationException pce)
System.out.println("Exception Parser configuration Exception " pce);
catch(SAXException saxe)
System.out.println("Exception SAX error " + saxe);
catch(Exception e)
System.out.println("Exception " + e);
Html code:
=========
<html>
<body>
<APPLET code="parserapplet.class" archive = "xalan.jar" width=0
height=0
MAYSCRIPT>
<param name=cabbase value=MyApplet.cab>
</APPLET>
</body>
</html>
I have signed the Applet using signcode utility and i have put the
parserapplet.class in the MyApplet cab file and signed it. On invoking
the html file, it request for permission, and after clicking yes, the
applet loads.Fine.
No problem upto this stage.
But after loading of the applet the following exception is thrown in
Javaconsole.
Exception:
=========
com.ms.security.SecurityExceptionEx[Host]: cannot access file
C:\WINNT\Java\lib\jaxp.properties
at com/ms/security/permissions/FileIOPermission.check
at com/ms/security/PolicyEngine.deepCheck
at com/ms/security/PolicyEngine.checkPermission
at com/ms/security/StandardSecurityManager.chk
at com/ms/security/StandardSecurityManager.checkRead
at java/io/File.exists
at javax/xml/parsers/DocumentBuilderFactory.findFactory
at javax/xml/parsers/DocumentBuilderFactory.newInstance
at parserapplet.parseXMLMessage
at parserapplet.init
at com/ms/applet/AppletPanel.securedCall0
at com/ms/applet/AppletPanel.securedCall
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run
javax.xml.parsers.FactoryConfigurationError:
java.lang.ClassNotFoundException:
org/apache/crimson/jaxp/DocumentBuilderFactoryImpl
at javax/xml/parsers/DocumentBuilderFactory.newInstance
at parserapplet.parseXMLMessage
at parserapplet.init
at com/ms/applet/AppletPanel.securedCall0
at com/ms/applet/AppletPanel.securedCall
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run
I dont know which .jar file to archive (i tried xalan,crimson, jaxp
but which of no use). I was surprised why the security Exception is
thrown , when parsing.
I have not accessed the System files!( but it searches for
jaxp.properties file!). I think the jar file is not downloaded. How to
verify that it is downloaded in applet?
The above code is only for sample.
If anybody who knows how to correct it please mail me at:
"[email protected]" with corrected code. I want this very
urgently.
Help meeeeeeeeeeeeeeeeeeee!!!!!
Prasanna.Have you found the answer to this problem? I am having a similar problem when running the parser in an ActiveX Bean.
THanks -
ClassNotFoundException in applet-urgent
Hai
I am having an applet "tstapplet" whose class file is stored in a jar file and the applet is inside a package named test.
I wrote the following applet tag
<applet code="tstapplet.class" archive="../deploy/showj.jar">
</applet>
I am getting ClassNotFoundException ; tstapplet.class
What should I do Is the applet code wrong
Plz help urgent
tintuthilak<applet code="test.tstapplet" archive="../deploy/showj.jar">
</applet>
Try to open it with Firefox or Mozilla (you can be sure MSJVM does not try to open
the applet).
When it works convert the html page with [jdk.home]\bin\htmlconverter.exe -
Mysql-jdbc applet connection issue
I am developing a user interface for a mysql database. I am able to successfully access the db and execute queries through a java APPLICATION.
I need to do the same (access the db (mysql)) through a java APPLET. When I compile the applet it complies fine. When I try to run the applet I'm getting the following error message:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
I tied running the applet using appletviewer and through a web browser, same result. I can run the application from the same command prompt it works fine.
Please help.
Relevant info:
OS: Linux, Fedora4
Classpath: export set CLASSPATH=/home/xyz/Java/mysql-connector-java-5.0.5/:$CLASSPATH;
JDK: PATH=/usr/java/jdk1.6.0/bin
Program:
import java.sql.*;
public class b extends java.applet.Applet
int y = 0;
public void paint(java.awt.Graphics g)
y = y + 10;
Connection conn = null;
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/testdb?user=usr1234&password=xyzxyz";
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url);
System.out.println("Connected to the database.");
System.out.println(" ");
//*********BLOCK TO RETRIEVE RECORDS FROM TABLE*********
try{
Statement st = conn.createStatement();
ResultSet res = st.executeQuery("SELECT * FROM table1");
System.out.println("Name: " + "\t" + "Age: ");
while (res.next()) {
String s = res.getString("name");
int i = res.getInt("age");
System.out.println(s + "\t" + i);
catch (SQLException s){
y = y + 20;
g.drawString("******* s: "+s,50,y);
//*********END OF BLOCK TO RETRIEVE RECORDS FROM TABLE*********
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
y = y + 20;
g.drawString("******* e: "+e,50,y);
e.printStackTrace();
Thanks for the help in advance.
--MatFirst, accessing a database from an applet is a horrendous idea.
Having said that, did you add the mysql jar to the applet tag in the html page (in the archive property)? -
am trying to connect using JDBC using the foll line:
Class.forName("oracle.jdbc.driver.OracleDriver");
am getting runtime excep: classnot found
I ve added the directoties of foll files to classpath
classes.jar,classes111.zip files.
is there anything esle to be added?
But still am getting the error.
THIS IS V V V urgent..plsHi buddies..thank u so much for the suggestions.
Actually the DBA hadnt given the rights to set my classpath. thats the reason for the syntax error at the command promt when i sd set classpath. Then Mine is java 1.2 anyways i added the foelder that contains both 12 & 111.zip.
just have a doubt:
thomas, in the below whats the -cp for?
java -cp classes111.zip;myprogram.jar <mainclass>
is the command for setting tha classpath??? cos i usually do: set classpath=.;<other dir>
i think the . is to say append to already existing files. pls anyone correct me if am wrong. And whats the diff bet. that and
set classpath=%classpath%;<other dir> -
How to run Java JDBC-Applet in Internet Explorer Browser?
I developed an java application which uses JDBC thin client driver to fetch data from oracle 8i tables, applet to display some graphics.
I am able to compile to code in dos prompt.
Iam unable to run using Appletviewer and IE browser.
In IE browser it displays applet started in status bar but it displays nothing.
In appletviewer it gives
Warning : Can't read appletviewer properties file :c:\.....
java.security.AccessControlException......security expression specifying database host and port.
Environment : Oracle 9iDS release 2.0
Can anybody help me by providing the solution.http://java.sun.com/developer/technicalArticles/Security/applets/
- Saish -
JDBC -APPLET executing multiple SQL statements
Hello All,
Can I someone please help with this one.
I get the following error
java.sql.sqlException [Microsoft ODBC Manager] Invalid cursor State
when using
1. an ODBC datasource and connect using JDBC-ODBC
bridge.
2. Is it correct to use executeQuery & executeUpdate functions using the same connection and statement objects.
3. What is meant by the above error? This error occurs
while running the applet in Netscape
4. IE says can't class not found sun/jdbc/odbc
Expecting a useful reply.Dear Friend,
Invalid cursor state error occurs when you try to do something on a position of resultset which does not have any row in it. Example ,when you try to retrieve value from resultset when cursor is at beforefirst or afterlast. So you have to call next() so as to get value if the cursor is at beforefirst.
You can call any number of executexxx methods using a statement.
For free trial versions of JDBC Drivers visit www.Atinav.com -
Grunds�tzliche Fragen zu der Kombination JDBC, Applets und Datenbanken
Hallo zusammen
Nach dem ich mir jetzt die ganze Nacht um die Ohren geschlagen habe und hunderte Foreneintr�ge gelesen habe m�chte ich mal gerne die Meinung von euch hier im Forum h�ren wie Ihr zu der Kombination steht. Also meine Erkenntinsse von der letzten Nacht reichen von:
JA man kann Problemlos �ber JDBC auf eine Datenbank zugreifen;
Man kann eingeschr�nkt auf eine Datenbank zugreifen, wenn man sein Applet Signiert;
Es geht nur mit dem JDBC Treiber der Klasse 4;
Es geht auch mit dem JDBC Treiber der Klassen 1,2,3;
Man kann auf jeden immer auf die Datenbank zugreifen wenn die Datenbank und der Server sich den selben Rechner teilen;
Man kann generell nur �ber Signatur auf die Dantenbank zugreifen, egal ob auf dem selben Server oder nicht;
Es liegt an der HTML Datei ob der Zugriff gestattet ist oder nicht (Applet-Tag oder Object-Tag);
Man muss das ganze Projekt packen, damit es klappt.;
Es geht ohne dass das Projekt gepackt wird.;
Also ihr seht schon. Es scheint nicht ganz eindeutig zu sein, was alles ben�tigt wird und wie ein Funktionierendes Projekt auszusehen hat. Das macht mir die Sache jetzt nat�rlich nicht leichter, da ich nun ein Projekt habe, dass auf der Konsole einwandfrei l�uft, aber als Applet nicht mehr zu laden ist. Und ich hab so langsam wirklich jeden Beitrag, der irgendwann in irgendeinem Forum geschrieben wurde, den ich nach 10 Stunden gefunden habe ausprobiert. Nun hoffe ich, dass ich mit diesem Forumseintrag, in diesem Forum auf der Seite von quasi dem Entwickler von Java, endlich mal welche finde, denen es so geht wie mir und endlich mal eine L�sung bekommen, die Allgemein g�ltig ist und mit der neuesten momentan g�ltigen Software Funktioniert. Aus diesem Grunde habe ich auch die �berschrift recht Allgemein gehalten, damit man vielleicht auch eine allgemeine L�sung findet. ;-)
Gru� SSoft1980Hallo zusammen.
Ich habe mein Problem jetzt anderweitig gel�st, nachdem ich leider keine Antworten bekommen habe. Ich habe jetzt mit meinem Applset ein Servlet angesprochen, was meine Daten nun verwaltet. es funktioniert ganz gut ist aber leider auch sehr umst�ndlich da man st�ndig die Verbindung: Applet, Servlet, Datenbank, Servlet, Applet hat bei jeder anfrage. aber nun ja. Ich will ja keinen geschwindigkeitsrekord aufstellen :-)
Mal schauen ob ich mal mit nem anderen Problem dann noch mal auf euch zu komme.
Gru� SSoft -
Display DB SQL in APPLET (Urgent)
Hi,
I want de learn about How to display a Table in MS-SQL 7.0 in Applet.
Can you please give me web resources, where I can found informations.
Thanks in advance.
Samsomething like this for Access?
http://www.geocities.com/rmlchan/dba.html -
How to show a html page in a swing applet -- URGENT!!!
Hi All,
I'm trying to show a html page inside a swing applet... is it possible to do that?? if so is there any built-in classes available for that?? If anyone have some examples, plz help me with that....
Thanks,
Ragui havent tested.. but this should work. i am no expert on these either, just to give you an example.. :-)
JEditorPane ePane = new JEditorPane();
HTMLEditorKit html = new HTMLEditorKit();
ePane.setEditorKit(html);
HTMLDocument htmld = new HTMLDocument();
try{
URL url = new URL("http://hcs.harvard.edu/~undercon/");
InputStream ins = url.openStream();
ePane.setDocument(htmld);
html.read(ins,htmld, 0);
this.getContentPane().add(new JScrollPane(ePane),BorderLayout.CENTER);
catch(Exception e)
e.printStackTrace();
} -
Hello Everyone, im having a major problem with this applet.I am trying to create a Black Jack card game to play around.It is compiling with no errors however the applet doesnt seem to get initialised thus it is not possible to be viewed in the applet viewer. What im trying to achieve is being able to draw 2 cards in the deck. Ever since i tried to use the showBlackjackScore() method as well as the init()method things started to get serious.These methods implementations were taken from: http://nifty.stanford.edu/2004/EstellCardGame/code.html were the Card, Deck, Hand, Rank, and Suit classes are also implemented, and are used with this program. Would appreciate any help! Other than that, the Gui is of my own and is a really nice example for ideas in your future java programs.Thanks in Advance!
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.util.*;
public class BlackJackClient extends JApplet
private Deck cardDeck;
private BlackjackHand myHand;
private final int SIZE_OF_HAND = 2;
private final String directory = "cards/";
private JLabel[] handLbl = new JLabel[ SIZE_OF_HAND ];
private Container container;
private JPanel panel1,panel2,Flow,Opponent,Player;
private JPanel cardsTop,cardsBottom;
private JLabel Player_Status;
private JLabel top_card1,top_card2,top_card3,top_card4,top_card5;
private JLabel bottom_card1,bottom_card2,bottom_card3,bottom_card4,bottom_card5;
private TitledBorder opponent,player;
private TitledBorder Cr1,Cr2,Cr3,Cr4,Cr5;
private TitledBorder B1,B2,B3,B4,B5;
private JPanel box1,box2,box3,box4,box5,box6,box7,box8,box9,box10;
private JTextArea Messages;
private JButton Hit,Stand,JButton1;
private JLabel scoreLbl;
public BlackJackClient()//CONSTRUCTOR
container=getContentPane();
container.setLayout(new BoxLayout(container,BoxLayout.Y_AXIS));
scoreLbl.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
scoreLbl.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
getContentPane().add(scoreLbl);
scoreLbl.setForeground(java.awt.Color.black);
scoreLbl.setFont(new Font("Dialog", Font.BOLD, 64));
scoreLbl.setBounds(252,48,103,88);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++PANELS
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
Opponent=new JPanel();
Player=new JPanel();
cardsTop=new JPanel(new FlowLayout(FlowLayout.CENTER,10,15));
cardsBottom=new JPanel(new FlowLayout(FlowLayout.CENTER,10,15));
panel1=new JPanel();
panel2=new JPanel();
box1=new JPanel();
box2=new JPanel();
box3=new JPanel();
box4=new JPanel();
box5=new JPanel();
box6=new JPanel();
box7=new JPanel();
box8=new JPanel();
box9=new JPanel();
box10=new JPanel();
Flow=new JPanel(new FlowLayout(FlowLayout.RIGHT,3,0));
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JLabel label=new JLabel("Welcome To BlackJack 21",SwingConstants.CENTER);
label.setForeground(Color.white);
label.setFont(new Font("Futura",Font.BOLD,19));
panel1.add(label);
panel1.setBackground(Color.black);
Icon card1=new ImageIcon("Trapula/c1.png");
top_card1=new JLabel(card1);
Icon card2=new ImageIcon("Trapula/d1.png");
top_card2=new JLabel(card2);
Icon card3=new ImageIcon("Trapula/h1.png");
top_card3=new JLabel(card3);
Icon card4=new ImageIcon("Trapula/s1.png");
top_card4=new JLabel(card4);
Icon card5=new ImageIcon("Trapula/ck.png");
top_card5=new JLabel(card5);
box1.add(top_card1);
cardsTop.add(box1);
box2.add(top_card2);
cardsTop.add(box2);
box3.add(top_card3);
cardsTop.add(box3);
box4.add(top_card4);
cardsTop.add(box4);
box5.add(top_card5);
cardsTop.add(box5);
Cr1 = new TitledBorder(new LineBorder(Color.black,2), "");
box1.setBorder(Cr1);
box1.setBackground(Color.gray);
Cr2 = new TitledBorder(new LineBorder(Color.black,2), "");
box2.setBorder(Cr2);
box2.setBackground(Color.gray);
Cr3 = new TitledBorder(new LineBorder(Color.black,2), "");
box3.setBorder(Cr3);
box3.setBackground(Color.gray);
Cr4 = new TitledBorder(new LineBorder(Color.black,2), "");
box4.setBorder(Cr4);
box4.setBackground(Color.gray);
Cr5 = new TitledBorder(new LineBorder(Color.black,2), "");
box5.setBorder(Cr5);
box5.setBackground(Color.gray);
opponent=new TitledBorder(new LineBorder(Color.black,5),"Opponent");
Opponent.setBorder(opponent);
Opponent.add(cardsTop);
Opponent.setBackground(Color.green);
cardsTop.setBackground(Color.green);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Icon card6=new ImageIcon("Trapula/s4.png");
bottom_card1=new JLabel(card6);
Icon card7=new ImageIcon("Trapula/s5.png");
bottom_card2=new JLabel(card7);
Icon card8=new ImageIcon("Trapula/s6.png");
bottom_card3=new JLabel(card8);
Icon card9=new ImageIcon("Trapula/s7.png");
bottom_card4=new JLabel(card9);
Icon card10=new ImageIcon("Trapula/s8.png");
bottom_card5=new JLabel(card10);
box6.add(bottom_card1);
cardsBottom.add(box6);
box7.add(bottom_card2);
cardsBottom.add(box7);
box8.add(bottom_card3);
cardsBottom.add(box8);
box9.add(bottom_card4);
cardsBottom.add(box9);
box10.add(bottom_card5);
cardsBottom.add(box10);
B1=new TitledBorder(new LineBorder(Color.black,2), "");
box6.setBorder(B1);
box6.setBackground(Color.gray);
B2=new TitledBorder(new LineBorder(Color.black,2), "");
box7.setBorder(B2);
box7.setBackground(Color.gray);
B3=new TitledBorder(new LineBorder(Color.black,2), "");
box8.setBorder(B3);
box8.setBackground(Color.gray);
B4=new TitledBorder(new LineBorder(Color.black,2), "");
box9.setBorder(B4);
box9.setBackground(Color.gray);
B5=new TitledBorder(new LineBorder(Color.black,2), "");
box10.setBorder(B5);
box10.setBackground(Color.gray);
player=new TitledBorder(new LineBorder(Color.black,5),"Player");
player.setTitleColor(Color.black);
Player.setBorder(player);
JPanel Hand=new JPanel();
JButton1=new JButton("Draw Hand");
JButton1.setActionCommand("Draw a Hand");
JButton1.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent e)
{ Object object=e.getSource();
if(e.getSource()==object)
{ cardDeck.restoreDeck();
cardDeck.shuffle();
myHand.discardHand();
for ( int i = 0; i < SIZE_OF_HAND; i++ )
{ Card c = cardDeck.dealCard();
myHand.addCard( c );
handLbl.setIcon( c.getCardImage() );
handLbl[i].setText( c.toString() );
showBlackjackScore();
Hand.add(JButton1);
Hand.setBackground(Color.green);
cardsBottom.setBackground(Color.green);
Player.setBackground(Color.green);
Player.add(cardsBottom);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Messages=new JTextArea("----------------------------------------------------Messages-------------------------------------------------\n\n\n",10,42);
JScrollPane scroller=new JScrollPane(Messages);
Messages.setEditable(false);
Messages.setForeground(Color.white);
Messages.setBackground(Color.gray);
panel2.setBackground(Color.green);
panel2.add(scroller);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JButton Exit=new JButton("Exit");
Exit.setToolTipText("Disconnect");
Hit=new JButton("Hit");
Hit.setToolTipText("Ask another card?");
Stand=new JButton("Stand");
Stand.setToolTipText("Satisfied with your card/s?");
JLabel l1=new JLabel(" ");
JLabel l2=new JLabel(" ");
JLabel l3=new JLabel(" ");
JLabel l4=new JLabel(" ");
JLabel l5=new JLabel(" ");
Exit.addActionListener(new ActionListener()
{public void actionPerformed(ActionEvent e)
{System.out.println("Disconnected from BlackJack Thank you for Gambling!");
System.exit(0);
Hit.addActionListener(new ActionListener()
{public void actionPerformed(ActionEvent e)
{Messages.append("Hit Me!!\n");}
Stand.addActionListener(new ActionListener()
{public void actionPerformed(ActionEvent e)
{Messages.append("Stand\n");}
Flow.add(l1);
Flow.add(l2);
Flow.add(l3);
Flow.add(l4);
Flow.add(l5);
Flow.add(Exit);
Flow.add(Hit);
Flow.add(Stand);
Flow.setBackground(Color.green);
p.add(Flow);
//++++++++++++++++++++++++++++++++++++++++++++++++++++
container.add(panel1);
container.add(Opponent);
container.add(Player);
container.add(Hand);
container.add(panel2);
container.add(p);
}//end of Black Jack client constructor
public void init()
{ cardDeck = new Deck();
Iterator suitIterator = Suit.VALUES.iterator();
while ( suitIterator.hasNext() )
{ Suit suit = (Suit) suitIterator.next();
Iterator rankIterator = Rank.VALUES.iterator();
while ( rankIterator.hasNext() )
{ Rank rank = (Rank) rankIterator.next();
String imageFile = directory + Card.getFilename( suit, rank );
ImageIcon cardImage = new ImageIcon( getImage( getCodeBase(), imageFile ) );
Card card = new Card( suit, rank, cardImage );
cardDeck.addCard( card );
}//end of init
private void showBlackjackScore()
int score = myHand.evaluateHand();
if( score == 21 )
{ scoreLbl.setText( score + "!" );
scoreLbl.setForeground( Color.red );
else
{ scoreLbl.setText( "" + score );
scoreLbl.setForeground( Color.black );
}//end of showBlackjackScore
}//end of class Black Jack clientI might be wrong, but maybe the init() method isn't showing any GUI because you're not creating or adding any components there.
Rather than putting all the Swing code in your constructor, put it in a method that returns your top-level component, such as:
private Component createComponents() {
// blah
}Then, in your init() method, try something like:
public void init() {
try {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createComponents();
catch (Exception e) {
System.err.println("Applet could not be created succesfully");
e.printStackTrace();
}Do you get any error messages with your current program?
Message was edited by:
Djaunl -
Images in applet URGENT!!
Hi. how do i display an image on an applet or a frame without using swing? Any code sample will help. Thanx
-Raamtry adding an icon to a Label
-
In Java applet how do I set the size for a list.
<applet code="test.tstapplet" archive="../deploy/showj.jar">
</applet>
Try to open it with Firefox or Mozilla (you can be sure MSJVM does not try to open
the applet).
When it works convert the html page with [jdk.home]\bin\htmlconverter.exe
Maybe you are looking for
-
Azure File Storage - Creating a directory at the root level using REST
I have a Xamarin / iOS project, and looking to use Azure File Share as a back-end. With that in mind, I'm playing around with the REST API and have generally got things working with (a) Blobs and (b) Account-level access to Files. Specifically, I can
-
Firefox no longer gives me a list of my bookmarks. How do I get it back?
I have Firefox 3.6. When I opened Firefox through Google, I used to get a list of my bookmarks printed on the left of the page, and I used it all the time. All of a sudden the list disappeared and I sure do want it back. I am 84 years old so you have
-
Using C# to run PowerShell command to create VirtualDirectory fails
I can run these commands with no problem directly in PowerShell. But trying to get C# to run them, I receive errors. md d:\ftproot\vdir\test20140317A; New-WebVirtualDirectory -Site "[site]/[a virt directory]" -Name test20140317A -physicalPath d:\ftpr
-
Itunes is telling me i dont have internet when i try to update. help please
when i enter itunes everything works fine besides the option to update. i go to update my iphone 4 on to 4.2.9 and then it says not connected to the internet. Restoring even says not connected.
-
Reinstalled leopard and problems with iphone
Hi Iv plugged my iphone into my computer, the same one its always been synced with, when signed into the same account - only after reinstalling snow leopard from scratch.... I dont know what to press etc to get everything back to normal and allow me