Help with converting an applet into an application
Here is a set of code which can work perfectly fine as an applet. But I have problem converting it into an application. Any help? I get some null pointer exception. Thanks alot.
//File Name: Radar.java
//Author: Saad Ayub
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Flash extends Thread{
private DrawA dA;
private int x;
private int xCor[];
private int yCor[];
private int i;
private int dir;
private Image im;
private Graphics buff;
public Flash(DrawA dA, Image im, Graphics buff){
this.dA = dA;
this.im = im;
this.buff = buff;
xCor = new int[451];
yCor = new int[451];
dir = 10;
}//end of Flash constructor
public void run(){
for(x = 75, i = 0; x <= 525; x++, i++){
xCor[i] = x - 300;
for(i = 0; i <= 450; i++){
yCor[i] = (int)Math.sqrt(62500 - (xCor[i] * xCor));
yCor[i] = 300 - yCor[i];
for(x = 0; x <= 450; x++){
xCor[x]+=300;
i = 0;
while(true){
try{
Thread.sleep(35);
catch(Exception e){}
dA.repaint();
i += dir;
if(i < 0 || i > 450){
dir = -dir;
i += dir;
}//end of if
}//end of while
}//end of run
public void draw(Graphics g){
int green = 255;
buff.setColor(Color.black);
buff.fillRect(0, 0, 600, 330);
buff.setColor(new Color(0, 70, 0));
buff.fillArc(50, 50, 500, 500, 25, 130);
buff.setColor(Color.green);
if(i > 450)
return;
if(xCor[i] != 0 && yCor[i] != 0)
buff.drawLine(xCor[i], yCor[i], 300, 300);
if(dir > 0){
for(int j = i; j > (i - 100); j--){
if(j >= 0 && j <= 450){
green -= 2;
buff.setColor(new Color(0, green, 0));
buff.drawLine(xCor[j], yCor[j], 300, 300);
}//end of if
}//end of for
}//end of if
else{
for(int j = i; j < (i + 100); j++){
if(j >= 0 && j <= 450){
green -= 2;
buff.setColor(new Color(0, green, 0));
buff.drawLine(xCor[j], yCor[j], 300, 300);
}// end of if
}//end of for
}//end of else
buff.setColor(Color.green);
buff.drawArc(112, 112, 375, 375, 25, 130);
buff.drawArc(174, 174, 250, 250, 25, 130);
buff.drawArc(238, 238, 125, 125, 25, 130);
buff.drawLine(300, 300, 300, 50);
g.drawImage(im, 0, 0, null);
}//end of draw
}//end of flash class
class DrawA extends Panel{
private Flash fl;
private Image im;
private Graphics buff;
public DrawA(Image im){
this.im = im;
buff = im.getGraphics();
fl = new Flash(this, im, buff);
fl.start();
// setBackground(Color.black);
public void paint(Graphics g){
fl.draw(g);
public void update(Graphics g){
paint(g);
public class Radar extends Applet{
public DrawA dA;
private JLabel display;
public Radar()
display = new JLabel("display");
public void init(){
dA = new DrawA(createImage(600, 330));
setLayout(new BorderLayout());
add(dA, BorderLayout.CENTER);
add(display, BorderLayout.EAST);
public void stop(){
destroy();
Edited by: bozovilla on Oct 20, 2008 8:32 AM
Start out by letting this thread die out...
and repost saying that you forgot to use code tags and describe sufficiently what your problem is--things like the actual error message and where it happens.
Similar Messages
-
Converting an Applet into an Application
I think I understand the basics of converting an Applet into an Application but Iam unsure on how you would go about passing the parameters that are normally stored in the HTML tag into the application.
Basically you'll need to provide your own getParameter
method. It's easy with a java.util.HashTable -- the
parameter name as the key.that means that i would have to go back and change the old code, correct? -
I need help with the Quote applet.
Hey all,
I need help with the Quote applet. I downloaded it and encoded it in the following html code:
<html>
<head>
<title>Part 2</title>
</head>
<body>
<applet codebase="/demo/quote/classes" code="/demo/quote/JavaQuote.class"
width="300" height="125" >
<param name="bgcolor" value="ffffff">
<param name="bheight" value="10">
<param name="bwidth" value="10">
<param name="delay" value="1000">
<param name="fontname" value="TimesRoman">
<param name="fontsize" value="14">
<param name="link" value="http://java.sun.com/events/jibe/index.html">
<param name="number" value="3">
<param name="quote0" value="Living next to you is in some ways like sleeping with an elephant. No matter how friendly and even-tempered is the beast, one is affected by every twitch and grunt.|- Pierre Elliot Trudeau|000000|ffffff|7">
<param name="quote1" value="Simplicity is key. Our customers need no special technology to enjoy our services. Because of Java, just about the entire world can come to PlayStar.|- PlayStar Corporation|000000|ffffff|7">
<param name="quote2" value="The ubiquity of the Internet is virtually wasted without a platform which allows applications to utilize the reach of Internet to write ubiquitous applications! That's where Java comes into the picture for us.|- NetAccent|000000|ffffff|7">
<param name="space" value="20">
</applet>
</body>
</html>When I previewed it in Netscape Navigator, a box with a red X appeared, and this appeared in the console when I opened it:
load: class /demo/quote/JavaQuote.class not found.
java.lang.ClassNotFoundException: .demo.quote.JavaQuote.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: \demo\quote\JavaQuote\class.class (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 10 more
Exception in thread "Thread-4" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)What went wrong? and how can I make it run correct?
Thanks,
Nathan PinnoJavaQuote.class is not where your HTML says it is. That is at the relative URL "/demo/quote/".
-
Help with converting a Nero file
I have previously converted a dvd insert designed with Nero into a pdf using adobe acrobat in order to send to someone else. When I tried to do the same thing today with a new Nero designed insert the conversion wouldn't work. The message said adobe didn't support the program that created the file. Any ideas?
thanks for your response.
When I create a dvd insert or cd label etc using Nero the file extension is nct - nero cover template. The printer wants the file as a pdf as he can't open Nero files. I have version 9.3 of acrobat.
Date: Mon, 18 Jan 2010 21:43:47 -0700
From: [email protected]
To: [email protected]
Subject: help with converting a Nero file
Nero is simply a CD/DVD burning application and should have no effect on the type of files that will eventually be on the CD/DVD.
What type of files are you trying to convert and exactly how are you trying to convert them? Plus, it would help to know the version of Acrobat you are using.
> -
Help with publish an applet on the web
I have a few java programs I would like to share with family and friends. I recently learned to convert my applications to Applets, now I am looking to post these on my blog. I know how to embed the applet into an html, and did successfully in my PC. However, when trying to do the same online, I run into problems:
-Cannot find a server where to upload the applet. Google doesn't seem to do it, and I tried some others without luck.
-I upload the .class files of my applet to box.net, and copy the URL. In the html of my blog, I use the <applet code = "someURL", but the applet fails since it is unable to find any other class.
I know that applets are common throughout the web, and that it should be within the reach of an individual programmer like myself (with no budget). If someone who has published an applet could give a short summary of the process, I would much appreciate.
Specifically, I am looking for:
Which file hosting service did you use?
Did you upload as a jar file, or the .class files individually as I did?
Did you have to pay for the service?
Thank you>
I have a few java programs I would like to share with family and friends. >Perhaps launching the programs using [Java Web Start|http://java.sun.com/javase/technologies/desktop/javawebstart/index.jsp] (JWS) will fulfil the requirement. A launch using JWS is generally simpler than embedding an applet in HTML. (Note that JWS can launch both (J)Frame and (J)Applet based apps., though a frame works/looks slightly better).
JWS can launch apps., from a link in a web page..
As an aside. If you do not intend to use JWS please state that, and explain why. This is much easier to explain for JWS launch.
>
..I recently learned to convert my applications to Applets, now I am looking to post these on my blog. I know how to embed the applet into an html, and did successfully in my PC. However, when trying to do the same online, I run into problems:
-Cannot find a server where to upload the applet. Google doesn't seem to do it, and I tried some others without luck.>Google can certainly host JWS apps., check out some of the examples [by Dr John Matthews|http://sites.google.com/site/drjohnbmatthews/], one example of note is the [alpha-composite demo|http://sites.google.com/site/drjohnbmatthews/composite].
OTOH, I do not know if his site is 'free' or 'paid'. Perhaps Google's free sites limit what you can upload.
>
-I upload the .class files of my applet to box.net, and copy the URL. In the html of my blog, I use the <applet code = "someURL", but the applet fails since it is unable to find any other class. >..hmm. Very insufficient detail there. What speaks volumes instead is if you link to the broken applet page.
But I will comment this. The code attribute should not be any URL. It should be the 'fully qualified class name'. If the applet is trying to get classes from another site, it would do that by specifying a codebase.
>
I know that applets are common throughout the web, and that it should be within the reach of an individual programmer like myself (with no budget). If someone who has published an applet could give a short summary of the process, I would much appreciate.>If you can find a place to host the applet itself, but want the HTML elsewhere, try this experiment..
I have a demo applet at my site, explained/linked in [http://pscode.org/test/docload/|http://pscode.org/test/docload/]. It uses the applet at [http://pscode.org/test/docload/docload.jar|http://pscode.org/test/docload/docload.jar]. The test is to try and load that applet at your site.
So try this in your HTML.
<APPLET
CODE="org.pscode.eg.docload.DocumentLoader"
ARCHIVE="docload.jar"
CODEBASE="http://pscode.org/test/docload/"
WIDTH="600"
HEIGHT="500"
ALT="<P>This applet requires Java to be enabled! Check the browser options or see your SysAdmin.">
<P>This page requires Java! Get it free from <A HREF='http://www.java.com/'>www.java.com</A>.</P>
</APPLET>(That is actually the copy/pasted applet element from the applet page at my site, but with the codebase changed.)
>
Did you upload as a jar file, or the .class files individually as I did?>Rarely I use loose class files with applets, but it can be a hassle if they are in packages. It might be that cross-site access requires archives, but JWS certainly requires archives. -
Help with converting FLAC to ALAC while retaining metadata and cover art
Hi,
I've decided to embark on the long trek to convert my 18k+ FLAC music library into ALAC. I've decided on ALAC for mainly 2 reasons: iTunes/iPhone/iMac/Sonos compatibility and my desire to keep with a lossless format.
My library is pretty eclectic; I have quite a bit of classical music along with many other genres. I have spent quite a bit of time maintaining the correct tag information; I do not want to lose any of this info that I've painstakingly added to my library over the years. The tags that I use on my FLAC files are:
Filename
Title
Artist
Album
Album Artist
Disc Number
Disc Count
Compilation
Comment
Year
Genre
Track
Composer
Orchestra
Conductor
Performer
Length
Modified
Path
I want to be especially sure that I maintain the data in Composer, Orchestra, Performer and Conductor in my migration to ALAC. I also want to include my CD art in each track (many of which I had to scan since some of my CD's are not available for sale). The CD covers are stored in a "folder.jpg" file in the path of each CD's contents. I would really like the automated conversion process to pick up each "folder.jpg" and embed it in the appropriate tracks.
I have a license for dbPowerAmp, so I can do the conversion on the Windows side if need be (I have BootCamp set up and use Fusion), but I would prefer to do everything in Mac.
I am hoping that some of you good folks will offer up comments about the feasibility of this endeavor, and advise me on possible tools to use, paths to take, pitfalls to watch out for, etc.
Thank you for your time.
MikeI finally got done with the conversion. It took 2 weeks running XLD of 24x7, but at last it's over with.
I first used iTunes "download missing album art" to start the process. It populated about 50% of my collection, but I found that many of the album art was wrong. For instance, with collections (various artists) it populated the album art from the first track; with others, it put in the wrong album cover for the right CD. These were mostly because iTunes would get a contemporary cover, where my cover was from an older pressing of the disk.
I purchased a program called TuneUp which has helped with my missing album artwork, and also with correcting typos. But even with using TuneUp, I probably have a couple of weeks worth of work left to do.
Then comes the renaming of the Classical music tracks.
Mike -
Converting an applet into a frame
hello.
this is james mcfadden. I am developing a 2-player BlackJack card game in java. how do i convert the following 2 pieces of code from an applet into a frame?
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Blackjack extends Applet implements ActionListener,Runnable{
private Deck deck; //The deck...
private Hand player_hand;//player hand
private Hand dealer_hand;//dealer hand.
private Button bHit=new Button("Hit");
private Button bStay=new Button("Stay");
private Button bRestart=new Button("New Game");
//lets do some double buffering.
Image offIm=null;
Graphics offGraphics=null;
Dimension offDimension=null;
Image[] card_images = new Image[52];
private boolean cards_loaded = false;
private int current_card_loading = 0;
String message; //print a message...
int width; //The width of the applet
int height; //The height of the applet
int card_width = -1;
int card_padding = -1; //How much should we pad the cards by..?
private int games=-1; //How many games have been played?
public void init() {
Thread card_loader = new Thread(this);
card_loader.start();
public void newGame(){
bHit.setEnabled(true);
bStay.setEnabled(false);
player_hand = new Hand(); //Create new hands...
dealer_hand = new Hand();
//shuffle the deck.
deck.shuffleCards();
games++;
public void hit(){
bStay.setEnabled(true);
player_hand.addCard(deck.dealCard());
if(player_hand.getValue() > 21){
message = "You loose! (score:"+player_hand.getValue()+")";
//disable the hit and stay buttons...
bHit.setEnabled(false);
bStay.setEnabled(false);
return;
message = "Score: "+player_hand.getValue();
public void stay(){
while(dealer_hand.getValue() < 17){
dealer_hand.addCard(deck.dealCard());
if(dealer_hand.getValue() <= 21 && player_hand.getValue() < dealer_hand.getValue())
message = "You loose! (" + player_hand.getValue()+
" - "+dealer_hand.getValue()+")";
}else if (player_hand.getValue() == dealer_hand.getValue())
message = "You draw! (" + player_hand.getValue()+")";
}else {
message = "You win! (" + player_hand.getValue()+
" - "+dealer_hand.getValue()+")";
bHit.setEnabled(false);
bStay.setEnabled(false);
public void actionPerformed(ActionEvent e) {
if(e.getSource() == bRestart)
newGame();
}else if (e.getSource() == bHit)
hit();
}else if (e.getSource() == bStay)
stay();
repaint();
public void paint(Graphics g) {
update(g);
public void update(Graphics g) {
//lets sord out double buffering
if(offGraphics==null){
offIm=createImage(getSize().width,getSize().height);
offGraphics=offIm.getGraphics();
if(!cards_loaded){
//display a message saying we're loading the cards...
offGraphics.setFont(new Font("Arial",Font.PLAIN,14));
offGraphics.setColor(new Color(171,205,239));
offGraphics.fillRect(0,0,getSize().width,getSize().height);
offGraphics.setColor(Color.black);
offGraphics.drawString("Loading cards... ",5,20);
offGraphics.drawRect(15,40, 102 ,10);
offGraphics.drawRect(13,38, 106 ,14);
offGraphics.setColor(new Color(171,205,239));
offGraphics.fillRect(0,0,150,35);
offGraphics.setColor(Color.black);
offGraphics.fillRect(15,40, (current_card_loading)*2 ,10);
offGraphics.drawString("Loading card: "+current_card_loading+1,15,20);
}else{
Image currentCard;
while(card_width == -1)
card_width = deck.getCard(0).getImage().getWidth(this);
if(card_padding == -1)
card_padding = (width - (card_width * 2) - 4) / 4;
//clear the background...
offGraphics.setColor(Color.blue);
offGraphics.fillRect(0,0,width,height);
offGraphics.setColor(Color.black);
offGraphics.fillRect(1,1,width-2,height-2);
offGraphics.setColor(Color.white);
offGraphics.drawString("PLAYER:",card_padding,40);
offGraphics.drawString("DEALER:",(width/2) + card_padding,40);
offGraphics.drawString(message,5,height - 20);
if(games > 0)
offGraphics.drawString(games + " game(s) played...",5,height - 10);
//Draw the players hand...
for(int i=0;i<player_hand.getCardCount();i++){
currentCard = player_hand.getCards().getImage();
offGraphics.drawImage(currentCard, card_padding, 70+(20*(i-1)), this);
//now draw the dealers hand...
for(int i=0;i<dealer_hand.getCardCount();i++){
currentCard = dealer_hand.getCards()[i].getImage();
offGraphics.drawImage(currentCard, (width/2 ) + card_padding, 70+(20*(i-1)), this);
//draw buffered image.
g.drawImage(offIm,0,0,this);
public void run(){
MediaTracker t=new MediaTracker(this);
System.out.println("Applet getting cards...");
for(current_card_loading=0; current_card_loading < 52; current_card_loading++){
//try{
card_images[current_card_loading] = getImage(getCodeBase(),
"cards/" + (current_card_loading+1) + ".gif");
if(card_images[current_card_loading] == null){
System.out.println("Null card... ["+current_card_loading+"]");
}else{
t.addImage(card_images[current_card_loading],0);
try{
t.waitForID(0);
}catch(InterruptedException e){
System.err.println("Interrupted waiting for images..>");
//lets show our new status.
repaint();
//create the deck object now
deck = new Deck(this,card_images); //Create a new deck object.
card_width = deck.getCard(0).getImage().getWidth(this);
bHit.addActionListener(this);
bStay.addActionListener(this);
bRestart.addActionListener(this);
bHit.setEnabled(false);
bStay.setEnabled(false);
width = getSize().width;
height = getSize().height;
this.add(bHit);
this.add(bStay);
this.add(bRestart);
player_hand = new Hand(); //Create the hands...
dealer_hand = new Hand();
//make sure that the buttons appear properly.
this.validate();
message = "";
cards_loaded = true;
System.out.println("End of thread...");
repaint();
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.io.*;
class Deck {
Card[] cards = new Card[52];
int currCard;
public Deck(Blackjack myApplet,Image[] card_images) {
// These are the (initial) values of all the cards
int[] values = {11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10,
11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10,
11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10,
11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10};
// Make all the cards, getting the images individually
for (int i=0; i<52; i++) {
// Image image = myApplet.getImage(myApplet.getCodeBase(), "cards/" + (i+1) + ".gif");
cards[i] = new Card(card_images, values[i]);
// Shuffle the cards.
shuffleCards();
public void shuffleCards(){
Card temp;
//loop through each card in the deck and swap it with some random card.
for (int i=0; i<52; i++) {
int rand = (int)(Math.random()*52);
temp = cards[51-i];//take the current card...
cards[51-i] = cards[rand];//and swap it with some random card...
cards[rand] = temp;
//now, reset the currentCard to deal...
currCard = 0;
public Card dealCard() {
Card card = cards[currCard];
currCard++;
return card;
public Card getCard(int i) {
return cards[i];thanks for the advice.
i've done what you suggested. but when i went try to compile the 2 programs i get error messages (shown below along with the modified code). do you know what are causing these error messages?
import java.awt.*;
import java.awt.event.*;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Blackjack extends JFrame implements ActionListener,MouseListener{
private Deck deck; //The deck...
private Hand player_hand;//player hand
private Hand dealer_hand;//dealer hand.
//private Button bHit=new Button("Hit");
JButton bHit=new JButton("Hit");
//private Button bStay=new Button("Stay");
JButton bStay=new JButton("Stay");
//private Button bRestart=new Button("New Game");
JButton bRestart=new JButton("New Game");
//lets do some double buffering.
Image offIm=null;
Graphics offGraphics=null;
Dimension offDimension=null;
Image[] card_images = new Image[52];
private boolean cards_loaded = false;
private int current_card_loading = 0;
String message; //print a message...
int width; //The width of the applet
int height; //The height of the applet
int card_width = -1;
int card_padding = -1; //How much should we pad the cards by..?
private int games=-1; //How many games have been played?
public static void main(String[] args){
Blackjack bj =new Blackjack();
bj.pack();
bj.setVisible(true);
public Blackjack(){
Thread card_loader = new Thread(this);
card_loader.start();
bHit.addMouseListener(this);
bHit.addActionListener(this);
//bHit.addMouseMotionListener(this);
add(bHit);
bStay.addMouseListener(this);
bStay.addActionListener(this);
//bStay.addMouseMotionListener(this);
add(bStay);
bRestart.addMouseListener(this);
bRestart.addActionListener(this);
//bRestart.addMouseMotionListener(this);
add(bRestart);
JFrame frame=new JFrame("BlackJack");
frame.setSize(400,200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(this);
frame.pack();
frame.setVisible(true);
public void newGame(){
bHit.setEnabled(true);
bStay.setEnabled(false);
player_hand = new Hand(); //Create new hands...
dealer_hand = new Hand();
//shuffle the deck.
deck.shuffleCards();
games++;
public void hit(){
bStay.setEnabled(true);
player_hand.addCard(deck.dealCard());
if(player_hand.getValue() > 21){
message = "You loose! (score:"+player_hand.getValue()+")";
//disable the hit and stay buttons...
bHit.setEnabled(false);
bStay.setEnabled(false);
return;
message = "Score: "+player_hand.getValue();
public void stay(){
while(dealer_hand.getValue() < 17){
dealer_hand.addCard(deck.dealCard());
if(dealer_hand.getValue() <= 21 && player_hand.getValue() < dealer_hand.getValue()){
message = "You loose! (" + player_hand.getValue()+" - "+dealer_hand.getValue()+")";
else if (player_hand.getValue() == dealer_hand.getValue()){
message = "You draw! (" + player_hand.getValue()+")";
else{
message = "You win! (" + player_hand.getValue()+" - "+dealer_hand.getValue()+")";
bHit.setEnabled(false);
bStay.setEnabled(false);
public void actionPerformed(ActionEvent e){
if(e.getSource() == bRestart){
newGame();
else if (e.getSource() == bHit){
hit();
else if (e.getSource() == bStay){
stay();
repaint();
public void paint(Graphics g){
update(g);
public void update(Graphics g){
//lets sord out double buffering
if(offGraphics==null){
offIm=createImage(getSize().width,getSize().height);
offGraphics=offIm.getGraphics();
if(!cards_loaded){
//display a message saying we're loading the cards...
offGraphics.setFont(new Font("Arial",Font.PLAIN,14));
offGraphics.setColor(new Color(171,205,239));
offGraphics.fillRect(0,0,getSize().width,getSize().height);
offGraphics.setColor(Color.black);
offGraphics.drawString("Loading cards... ",5,20);
offGraphics.drawRect(15,40, 102 ,10);
offGraphics.drawRect(13,38, 106 ,14);
offGraphics.setColor(new Color(171,205,239));
offGraphics.fillRect(0,0,150,35);
offGraphics.setColor(Color.black);
offGraphics.fillRect(15,40, (current_card_loading)*2 ,10);
offGraphics.drawString("Loading card: "+current_card_loading+1,15,20);
else{
Image currentCard;
while(card_width == -1){
card_width = deck.getCard(0).getImage().getWidth(this);
if(card_padding == -1){
card_padding = (width - (card_width * 2) - 4) / 4;
//clear the background...
offGraphics.setColor(Color.blue);
offGraphics.fillRect(0,0,width,height);
offGraphics.setColor(Color.black);
offGraphics.fillRect(1,1,width-2,height-2);
offGraphics.setColor(Color.white);
offGraphics.drawString("PLAYER:",card_padding,40);
offGraphics.drawString("DEALER:",(width/2) + card_padding,40);
offGraphics.drawString(message,5,height - 20);
if(games > 0){
offGraphics.drawString(games + " game(s) played...",5,height - 10);
//Draw the players hand...
for(int i=0;i<player_hand.getCardCount();i++){
currentCard = player_hand.getCards().getImage();
offGraphics.drawImage(currentCard, card_padding, 70+(20*(i-1)), this);
//now draw the dealers hand...
for(int i=0;i<dealer_hand.getCardCount();i++){
currentCard = dealer_hand.getCards()[i].getImage();
offGraphics.drawImage(currentCard, (width/2 ) + card_padding, 70+(20*(i-1)), this);
//draw buffered image.
g.drawImage(offIm,0,0,this);
public void run(){
MediaTracker t=new MediaTracker(this);
System.out.println("Frame getting cards...");
for(current_card_loading=0; current_card_loading < 52; current_card_loading++){
//try{
card_images[current_card_loading] = getImage(getCodeBase(),"cards/" + (current_card_loading+1) + ".gif");
if(card_images[current_card_loading] == null){
System.out.println("Null card... ["+current_card_loading+"]");
else{
t.addImage(card_images[current_card_loading],0);
try{
t.waitForID(0);
catch(InterruptedException e){
System.err.println("Interrupted waiting for images..>");
//lets show our new status.
repaint();
//create the deck object now
deck = new Deck(this,card_images); //Create a new deck object.
card_width = deck.getCard(0).getImage().getWidth(this);
bHit.addActionListener(this);
bStay.addActionListener(this);
bRestart.addActionListener(this);
bHit.setEnabled(false);
bStay.setEnabled(false);
width = getSize().width;
height = getSize().height;
this.add(bHit);
this.add(bStay);
this.add(bRestart);
player_hand = new Hand(); //Create the hands...
dealer_hand = new Hand();
//make sure that the buttons appear properly.
this.validate();
message = "";
cards_loaded = true;
System.out.println("End of thread...");
repaint();
----jGRASP exec: javac -g X:\NETPROG\Assignment2\Blackjack.java
Blackjack.java:7: Blackjack is not abstract and does not override abstract method mouseExited(java.awt.event.MouseEvent) in java.awt.event.MouseListener
public class Blackjack extends JFrame /*Applet*/ implements ActionListener,MouseListener/*,Runnable*/{
^
Blackjack.java:53: cannot find symbol
symbol : constructor Thread(Blackjack)
location: class java.lang.Thread
Thread card_loader = new Thread(this);
^
Blackjack.java:209: cannot find symbol
symbol : method getCodeBase()
location: class Blackjack
card_images[current_card_loading] = getImage(getCodeBase(),"cards/" + (current_card_loading+1) + ".gif");
^
3 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
import java.awt.*;
import javax.swing.JFrame;
import java.net.*;
import java.io.*;
class Deck {
Card[] cards = new Card[52];
int currCard;
public Deck(/*Blackjack myApplet*/Blackjack myFrame,Image[] card_images) {
// These are the (initial) values of all the cards
int[] values = {11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10,
11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10,
11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10,
11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10};
// Make all the cards, getting the images individually
for (int i=0; i<52; i++) {
cards[i] = new Card(card_images, values[i]);
// Shuffle the cards.
shuffleCards();
public void shuffleCards(){
Card temp;
//loop through each card in the deck and swap it with some random card.
for (int i=0; i<52; i++) {
int rand = (int)(Math.random()*52);
temp = cards[51-i];//take the current card...
cards[51-i] = cards[rand];//and swap it with some random card...
cards[rand] = temp;
//now, reset the currentCard to deal...
currCard = 0;
public Card dealCard() {
Card card = cards[currCard];
currCard++;
return card;
public Card getCard(int i) {
return cards[i];
----jGRASP exec: javac -g X:\NETPROG\Assignment2\Deck.java
Blackjack.java:6: Blackjack is not abstract and does not override abstract method mouseExited(java.awt.event.MouseEvent) in java.awt.event.MouseListener
public class Blackjack extends JFrame implements ActionListener,MouseListener{
^
Blackjack.java:45: cannot find symbol
symbol : constructor Thread(Blackjack)
location: class java.lang.Thread
Thread card_loader = new Thread(this);
^
Blackjack.java:201: cannot find symbol
symbol : method getCodeBase()
location: class Blackjack
card_images[current_card_loading] = getImage(getCodeBase(),"cards/" + (current_card_loading+1) + ".gif");
^
3 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete. -
Help with Converting an Access query
Hello:
First time poster and would appreciate some help in converting this Access query into T-SQL so I can use in a Stored Procedure. I don't need help in resolving the syntax for the variables as parameter in the second query, but stuck in writing the first query
in T-SQL . I assume I need some type of nested query with a left join to another query in T-SQL.
How do I convert this from Access into MS-SQL
SELECT TBL_MONTH.L_Month, TBL_MONTH.L_MonthName
FROM TBL_MONTH LEFT JOIN qry_MonthCheck ON TBL_MONTH.L_Month = qry_MonthCheck.L_Month
WHERE (((qry_MonthCheck.L_Month) Is Null));
qryMonthCheck in Access is defined as
SELECT TBL_MONTH.L_Month, TBL_SIGNOFF.SO_YEAR, TBL_SIGNOFF.SO_USER, TBL_SIGNOFF.SO_LOCATION
FROM TBL_MONTH RIGHT JOIN TBL_SIGNOFF ON TBL_MONTH.L_Month = TBL_SIGNOFF.SO_MONTH
WHERE (((TBL_SIGNOFF.SO_YEAR)=[forms]![frm_signoff]![cboyear]) AND ((TBL_SIGNOFF.SO_LOCATION)=[Tempvars]![tmpVarUserLOC]));It is very much up to personal taste. For tables I use no prefix at all. Or suffix. I prefer plural: categories, products, etc. For junction tables, I drop the plural in the first entity, for instance productcategories. As for the case, many people prefer
initial uppercase, while I go for lowercase only. But initial uppercase has its points, particularly in documentation. I am a staunch advocate of using case-sensitive collation for metadata. I don't see any point in mixing productcategories, Productcategories,
ProductCategories etc. That can only cause confusion.
As for either entities, I don't use views much, and I don't have any prefix for these either. In fact, several views I've been involved used to be tables once upon a time.
If you want to add a marker to the object name, I recommend using a suffix. It is much easier to find objects in the version control system and other browser, when not everything is cluttered on the same letter. For instance, I typically add _sp at the end
of stored procedure names.
Erland Sommarskog, SQL Server MVP, [email protected] -
Need help with turning multiple rows into a single row
Hello.
I've come across a situation that is somewhat beyond my knowledge base. I could use a little help with figuring this out.
My situation:
I am attempting to do some reporting from a JIRA database. What I am doing is getting the dates and times for specific step points of a ticket. This is resulting in many rows per ticket. What I need to do is return one row per ticket with a calculation of time between each step. But one issue is that if a ticket is re-opened, I want to ignore all data beyond the first close date. Also, not all tickets are in a closed state. I am attaching code and a sample list of the results. If I am not quite clear, please ask for information and I will attempt to provide more. The database is 10.2.0.4
select jiraissue.id, pkey, reporter, summary
,changegroup.created change_dt
,dbms_lob.substr(changeitem.newstring,15,1) change_type
,row_number() OVER ( PARTITION BY jiraissue.id ORDER BY changegroup.created ASC ) AS order_row
from jiraissue
,changeitem, changegroup
,(select * from customfieldvalue where customfield = 10591 and stringvalue = 'Support') phaseinfo
where jiraissue.project = 10110
and jiraissue.issuetype = 51
and dbms_lob.substr(changeitem.newstring,15,1) in ('Blocked','Closed','Testing','Open')
and phaseinfo.issue = jiraissue.id
and changeitem.groupid = changegroup.id
and changegroup.issueid = jiraissue.id
order by jiraissue.id,change_dt
Results:
1 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2008-07-16 9:30:38 AM Open 1
2 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2008-07-16 11:37:02 AM Testing 2
3 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-06-08 9:14:52 AM Closed 3
4 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:37 AM Open 4
5 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:42 AM Open 5
6 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:50 AM Testing 6
7 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:53 AM Closed 7
8 23234 QCS-208 System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role 2008-10-03 10:26:21 AM Open 1
9 23234 QCS-208 System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role 2008-11-17 9:39:39 AM Testing 2
10 23234 QCS-208 System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role 2011-02-02 6:18:02 AM Closed 3
11 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2008-09-29 2:44:54 PM Open 1
12 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2010-05-29 4:47:37 PM Blocked 2
13 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2011-02-02 6:14:57 AM Open 3
14 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2011-02-02 6:15:32 AM Testing 4
15 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2011-02-02 6:15:47 AM Closed 5Hi,
Welcome to the forum!
StblJmpr wrote:
... I am attempting to do some reporting from a JIRA database. What is a JIRA database?
I am attaching code and a sample list of the results. If I am not quite clear, please ask for information and I will attempt to provide more. Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and the results you want from that data.
Simplify the problem as much as possible. For example, if the part you don't know how to do only involves 2 tables, then jsut post a question involving those 2 tables. So you might just post this much data:
CREATE TABLE changegroup
( issueid NUMBER
, created DATE
, id NUMBER
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2008-07-16 09:30:38 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2008-07-16 11:37:02 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-06-08 09:14:52 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:37 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:42 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:50 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:53 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
INSERT INTO changegroup (issueid, created, id) VALUES (23234, TO_DATE ('2008-10-03 10:26:21 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (23234, TO_DATE ('2008-11-17 09:39:39 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (23234, TO_DATE ('2011-02-02 06:18:02 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2008-09-29 02:44:54 PM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2010-05-29 04:47:37 PM', 'YYYY-MM-DD HH:MI:SS AM'), 30);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2011-02-02 06:14:57 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2011-02-02 06:15:32 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2011-02-02 06:15:47 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
CREATE TABLE changeitem
( groupid NUMBER
, newstring VARCHAR2 (10)
INSERT INTO changeitem (groupid, newstring) VALUES (10, 'Open');
INSERT INTO changeitem (groupid, newstring) VALUES (20, 'Testing');
INSERT INTO changeitem (groupid, newstring) VALUES (30, 'Blocked');
INSERT INTO changeitem (groupid, newstring) VALUES (90, 'Closed');Then post the results you want to get from that data, like this:
ISSUEID HISTORY
21191 Open (0) >> Testing (692) >> Closed
23234 Open (45) >> Testing (807) >> Closed
23977 Open (607) >> Blocked (249) >> Open (0) >> Testing (0) >> ClosedExplain how you get those results from that data. For example:
"The output contains one row per issueid. The HISTORY coloumn shows the different states that the issue went through, in order by created, starting with the earliest one and continuing up until the first 'Closed' state, if there is one. Take the first row, issueid=21191, for example. It started as 'Open' on July 16, 2008, then, on the same day (that is, 0 days later) changed to 'Testing', and then, on June 8, 2010, (692 days later), it became 'Closed'. That same issue opened again later, on September 2, 2010, but I don't want to see any activity after the first 'Closed'."
The database is 10.2.0.4That's very important. Always post your version, like you did.
Here's one way to get those results from that data:
WITH got_order_row AS
SELECT cg.issueid
, LEAD (cg.created) OVER ( PARTITION BY cg.issueid
ORDER BY cg.created
- cg.created AS days_in_stage
, ROW_NUMBER () OVER ( PARTITION BY cg.issueid
ORDER BY cg.created
) AS order_row
, ci.newstring AS change_type
FROM changegroup cg
JOIN changeitem ci ON cg.id = ci.groupid
WHERE ci.newstring IN ( 'Blocked'
, 'Closed'
, 'Testing'
, 'Open'
-- AND ... -- any other filtering goes here
SELECT issueid
, SUBSTR ( SYS_CONNECT_BY_PATH ( change_type || CASE
WHEN CONNECT_BY_ISLEAF = 0
THEN ' ('
|| ROUND (days_in_stage)
|| ')'
END
, ' >> '
, 5
) AS history
FROM got_order_row
WHERE CONNECT_BY_ISLEAF = 1
START WITH order_row = 1
CONNECT BY order_row = PRIOR order_row + 1
AND issueid = PRIOR issueid
AND PRIOR change_type != 'Closed'
ORDER BY issueid
;Combining data from several rows into one big delimited VARCHAR2 column on one row is call String Aggregation .
I hope this answers your question, but I guessed at so many things, I won't be surprised if it doesn't. If that's the case, point out where this is wrong, post what the results should be in those places, and explain how you get those results. Post new data, if necessary. -
Please help with the message I am receving on startup ""You can't open the application NovamediaDiskSupressor because PowerPC applications are no longer supported."
I have read some of the replies in the Apple Support Communities, but as I am no techie, I would have no idea how I would implement that solution.
Please help with what I need to type, how, where, etc.
Many thanks
AppleSueIn HunterCreekI am afraid there is no solution.
PowerPC refers to the processing chip used by Apple before they transferred to Intel chips. They are very different, and applications written only for PPC Macs cannot work on a Mac running Lion.
You could contact the developers to see if they have an updated version in the pipeline. -
Need HELP with Stick Figure Applet
I need help with this java program for college....we need to make a applet which displays a stick figure or some type of person using appleviewer..please can someone help me......
email: [email protected]import java.awt.*;
import java.applet.*;
public class StickMan extends Applet {
public void init() {
public void paint(Graphics g) {
g.drawOval(....);
g.drawLine(....);
g.drawLine(....);
g.drawLine(....);
g.drawLine(....); -
Please Help with Converting PDF document to Word Document
I have downloaded our PDF document to be converted to a word document --- it did not work correctly--we need help with this
Scott Munsen
Abbott House -- Mitchell, SDGood day Scott,
I received your document via our File Conversion Issue form. The root of the problem you're facing is the quality of the scan. I'm not sure if you were starting with a poor quality hard-copy or simply low DPI settings on your scanner, but the reason the results you received were so different than the PDF was the quality of the input.
If you're hard copy looks clearer than the PDF file you created, I would suggest increasing the resolution settings on your scanner.
Please let me know if you have any questions.
Kind regards,
David -
Help With converting px to em...
So, I thought that I would have a go at converting a site from all px to em to help with accessibility and using browser zoom. I wish I'd never started!
This is how I approached it.
1) Set my font to 100%
2) Change all font sizes to em
3) Feel smug
4) Notice that after a couple of ramps up on the zoom the layout goes pear-shaped
5) Change all width/height dimensions to em
6) Change all padding/margin dimensions to em
7) Feel a little tearful
8) Realise I don't have a back-up style sheet
9) Re-draw WWW domination plan
10) Start to make a little progress
11) Try out the negative zoom
12) See that screw my layout - don't understand it
14) Add some min-width/min-height rules
12) Feel a little tearful...
13) Came here to be with friends
I worked out I think, that using flexible units in a fixed environment is going to cause problems.
I'm having trouble with layout more than text-size. I think the only thing that will cause me grief with text-size is with nested element and the way that em is inherited but, the site is quite straight forward, apart from a few floated elements.
I thnk my main problems are with the layout: Images, background images and how to approach the whold width/height thing.
Martin
PS I won't be at my PC for a while so, if you respond and I don't come back to you, it's not because I'm not interested. I'm too ashamed and confused to post a live page!Hi Martin
The one thing that confuses people when converting from px to em units is that they think px is a fixed size and em's are flexible, which unfortunately is not true, and just to confuse things even more Microsoft even treat px's as a relative size, (this is actually correct if you look at the css1 spec).
The best advice I can offer is to start with the layout when converting to em's and worry about the font etc. later, because as they say a pixel is relative.
PZ -
Help with converting array of sentences in to array of words.
Hi! I'm having a problem with converting an array of sentences (about 50) into 1000 separate words into an word array. No use of tokenizers, classes (pre-made) just clear proggramming.
Thanks in advance!Until you come up with a question, check these out:
http://java.sun.com/docs/books/tutorial/
http://java.sun.com/learning/new2java/index.html
http://javaalmanac.com
http://www.jguru.com
http://www.javaranch.com
Bruce Eckel's Thinking in Java
Joshua Bloch's Effective Java
Bert Bates and Kathy Sierra's Head First Java -
Help with converting hex to date and time
Hi!
I am using snmp4j libraries to walk the mib tree. The system date is getting returned in 11 hexadecimal octets. I require help in converting it to date and time. I looked up the RFC convention of what each octets represent. Require help with conversion.
Eg: 07:db:06:0a:29:1d:00:2b:05:1e
Thanks,Octets Contents Range
1-2 year 0..65536
3 month 1..12
4 day 1..31
5 hour 0..23
6 minutes 0..59
7 seconds 0..60
(use 60 for leap-second)
8 deci-seconds 0..9
9 direction from UTC '+' / '-'
10 hours from UTC 0..13
11 minutes from UTC 0..59
For example I just took the time an hour ago it came out as
07:db:06:13:12:11:1a:00:2b:05:1e
I have to convert this as a date long value to send it.
Do I have to write an utility of my own to do it?
Maybe you are looking for
-
K8NGM2-FID w/6150 nvidia video no signal thru DVI
I just bought my Viewsonic 20" wide display LCD monitor. I am getting a "no Signal" message when I try to connect to the DVI. Regular analog works great in fact everything works great ecept the DVI adapter. Any suggestions? MY build AMD Athalon x64 X
-
I tried to change the metadata date. It changed the date on my photo, but when I checked the box that said "also change my original file", it gave me this error message. Unable to change original file. Aperture was not able to adjust the date and t
-
When I set up my web page, I'm pretty sure I had set it up so that people could view my photos, but would be unable to downloads the photos from my site. Recently though, it seems that this has changed. How do I prevent this from happening?
-
Can I use thunderbolt display to play xboxone?
Can I use thunderbolt display to play xboxone? I just do not want to buy another TV, thanks .
-
Why can't I create property nodes for item in STRICT typedef cluster?
I've tried this in LV7.0/WIN2k and LV 7.1/OSX - both versions work the same. I have a TYPEDEF consisting of a cluster of items A, B, and C. I have a front-panel instance of this typedef. Under certain conditions, I want to disable and gray Item C, be