User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 456,610 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,507 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 641 | Replies: 3 | Solved
Reply
Join Date: Nov 2007
Posts: 3
Reputation: #1Basser is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
#1Basser #1Basser is offline Offline
Newbie Poster

Help Need Help with JFrame

  #1  
Nov 6th, 2007
I am new to java and having issues.
package components;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/* FrameDemo.java requires no other files. */
public class ContactApp
{
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI()
{
//Create and set up the window.
JFrame frame = new JFrame("FrameDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JLabel emptyLabel = new JLabel("");
emptyLabel.setPreferredSize(new Dimension(175, 100));
frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);

//Display the window.
frame.pack();
frame.setVisible(true);
}

public static void main(String[] args)
{
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
createAndShowGUI();
}
});
}
}

I am using this code as an example but when I try to view it all I get is a blank screen. Can someone tell me what to write in my notepad to view the applet. I have this now

<html>
<head>
<title>Dice Game Canvas</title>
</head>
<body>
<h1 align=center>Contact Application</h1>
<center>
<applet name="ContactApp"
code="ContactApp.class"
width=400
height=150>
</applet>
</center>
</body>
</html>

I don't know if this is correct if any one can help. Thank you.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Posts: 3
Reputation: reubenraj is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
reubenraj reubenraj is offline Offline
Newbie Poster

Troubleshooting Re: Need Help with JFrame

  #2  
Nov 6th, 2007
Hi friend,
Instantiate ContactApp class with an object, make CreateAndShowGUI() method public and call it from run() method. That should solve your problem. Use Netbeans 5.0 and older versions for building better java applicaitons.
Last edited by reubenraj : Nov 6th, 2007 at 11:05 pm.
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 3,090
Reputation: Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold 
Rep Power: 15
Solved Threads: 307
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Posting Sensei

Re: Need Help with JFrame

  #3  
Nov 7th, 2007
Originally Posted by #1Basser View Post
I am new to java and having issues...

I am using this code as an example but when I try to view it all I get is a blank screen. Can someone tell me what to write in my notepad to view the applet. I have this now

<html>
<head>
<title>Dice Game Canvas</title>
</head>
<body>
<h1 align=center>Contact Application</h1>
<center>
<applet name="ContactApp"
code="ContactApp.class"
width=400
height=150>
</applet>
</center>
</body>
</html>

I don't know if this is correct if any one can help. Thank you.

Your code is not an applet - it is a standalone frame demo class. You need to code it as an applet if you wish to use it as one:
http://java.sun.com/docs/books/tutor...let/index.html
Reply With Quote  
Join Date: Nov 2007
Posts: 3
Reputation: #1Basser is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
#1Basser #1Basser is offline Offline
Newbie Poster

Re: Need Help with JFrame

  #4  
Nov 7th, 2007
Thank you for the help I have figured that out now but thank still
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 7:15 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC