Hi all, I have a slight problem with a java applet of mine. I play a video game that tracks realm and world ranks and I'm making this applet to put on my site to display current standings.
My main problem is currently in the testing of this applet. Once I get everything the way it's working, I'll start to set variables to ranks instead of just using predefined numbers; however, my labels are hidden from my background. Is there another way I can set the background and have the labels show in front of the background? I recall in a previous java class this was possible but I don't remember how.
I'll paste my main applet code below to show you the problem:
*Ignore the URL reader. This is where I get my data from*
import java.util.*;
import javax.swing.JApplet;
import java.io.*;
import java.net.*;
import java.awt.*;
import javax.swing.ImageIcon;
import javax.swing.*;
import javax.swing.BoxLayout;
public class Ranks extends JApplet{
//Declare varibles
private String address;
private JLabel guildLogo, worldRankLabel, realmRankLabel, realmRankPos, worldRankPos;
public void init(){
setLayout(new FlowLayout());
//contentsY.setLayout(new BoxLayout(contentsY, BoxLayout.Y_AXIS));
JLabel blank1 = new JLabel(" ");
guildLogo = new JLabel(new ImageIcon("FD_logo.png"));
JLabel blank2 = new JLabel(" ");
realmRankLabel = new JLabel("Realm Rank:");
JLabel blank3 = new JLabel(" ");
realmRankPos= new JLabel("4");
worldRankLabel = new JLabel("World Rank:");
JLabel blank4 = new JLabel(" ");
worldRankPos= new JLabel("3000");
//Set label fonts and text positions
add(blank1);
add(guildLogo);
add(blank2);
add(realmRankLabel);
add(blank3);
add(realmRankPos);
add(worldRankLabel);
add(blank4);
add(worldRankPos);
setSize(new Dimension(170, 150));
}
public void Run() throws IOException{
URL url = new URL("http://www.wowprogress.com/guild/us/elune/From+Dust/json_rank");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;
String data = null;
// Set data = to the only line in the input stream from the URL
data = (inputLine = in.readLine());
}
public void paint(Graphics g){
getContentPane().setBackground(Color.WHITE);
}
}
Thank you in advance for any help!