Saturday, June 14, 2008

um.. i need to open an applet from one of the buttons in a GUI i made.. and i have NO clue what im doin... please help.. i have tried a few things.. but any answers would be nice ^_^

Okay- so I m trying to remodel my room. I am going to buy carpet and lay it down and it s going to be a neutral berber. I have black furniture- black and brown accents- and bedding that is black- brown and beige. No headboard or footboard. Wood trim that s staying.

Would a dark brown like Mocha or Java look good on the wall? Go to ratemyspace.hgtv.com and type in Leah- it s the one asking for advie in Girl s room.

How do you change the font of a JLabel in a Java Applet when the user clicks the JButton?

import javax.swing.*;
import java.awt.*;
public class JChangeFont extends JApplet {
Container con = getContentPane();
JLabel greeting = new JLabel("Hello. Who are you?");
Font headlineFont = new Font("Helvetica"- Font.BOLD- 36);
JButton pressMe = new JButton("Press to change font");
public void init()
{

con.add(greeting);
con.add(pressMe);
pressMe = greeting.setFont(headlineFont);
con.setLayout(new FlowLayout());
}
}

It s not working

The error is- when i click on a video- the player sometimes goes black and displays "We re sorry- this video is no longer available". I have running firefox 2.something and have been using youtube on this browser for well over two years.

Starting a couple of days ago- some of the youtube videos I watch just began not working. It was around the time youtube bean using their new video player interface. I thought nothing of it at first- but after encountering video after video- and realizing I could view some videos- I realized that something was wrong. I cannot view most of the front page videos- so the videos cannot have been removed.

One solution I found was- if a video is not working- I add the fmt=18 code at the end of the URL (increasing the quality) but somehow making it work as well. However- this is a hassle- and does not work for everything. No idea how it works- only making me more confused.

Is it just me? Or is it flash/java/browser/etc. problems?

Missing libraries. DatabaseUtils class creates a load of methods for my connection (only including main ones)
public static void main(String[] args)
{
Connection connection = null;
try
{
if (args.length > 0)
{
connection = DatabaseUtils.connect(DRIVER- URL- USERNAME- PASSWORD);
DatabaseUtils utils = new DatabaseUtils(connection);

}
else
{
System.out.println("Usage: DatabaseUtils <sql query>");
}
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
close(connection);
}
}

public DatabaseUtils(Connection connection)
{
this.connection = connection;
}

public static Connection connect(String driver- String url- String username- String password) throws ClassNotFoundException- SQLException
{
Class.forName(driver);
return DriverManager.getConnection(url- username- password);
}
My personService class creates a connection and passes it to my personDAO class.
public PersonService(PersonInfo p)
{
Connection c = null;
personDao = new PersonDAO();

try
{

c = DatabaseUtils.connect(DRIVER- URL- USERNAME- PASSWORD);
c.setAutoCommit(false);
personDao.setConnection(c);
personDao.savePerson(p);
c.commit();
}
catch (Exception e)
{
DatabaseUtils.rollback(c);
e.printStackTrace();
}
finally
{
DatabaseUtils.close(c);
}
}
}
Now my personDAO class needs to accept this connection through the setConnection method- this is what i have done.
public class PersonDAO{

private Connection con;

public void setConnection(Connection dbc)
{
this.con = dbc;
}

public void savePerson(PersonInfo person)
{
try
{

String sql = "INSERT INTO Person(name- idNo- " +
"userName- passWord) VALUES (?-?-?-?) ";

// Create a Preparedstatement
PreparedStatement ps = con.prepareStatement(sql);

ps.setString(1- person.getName());
ps.setString(2- person.getIdNo());
ps.setString(3- person.getUsername());
ps.setString(4- person.getPassword());

ps.executeUpdate();
}

catch(Exception e)
{
System.out.println(e);
e.printStackTrace();
}

}

I am being returned with a NullPointerException- so obviously my connection object isnt being passed properly. Can you see any errors?
My stack trace if interested is
java.lang.NullPointerException
java.lang.NullPointerException
at PersonDAO.savePerson(PersonDAO.java:22)
RELATING TO PreparedStatement ps = con.prepareStatement(sql);

at Register.save(Register.java:196)
RELATING TO pDAO.savePerson(person);

I havnt included all of my libraries or variables in my code- plus you might see passes to other classes which i havnt placed on here. The problem i am having involves these 3 classes. DatabaseUtils should set all methods for a connection- PersonService should create a connection- and personDAO should accept a connection. Any help would seriously be greatful.
cheers
I am being recieved back con is null = true

i have loggerd in selected world quality etc and then this message comes

Java(TM) plug-in fatal error
several java virtual machines running in the same process caused an errpr.

and a black screen with a litle red cross in the top left corner.

No comments: