Bodybuilding.com Forums
Go Back   Bodybuilding.com Forums > More General Categories > Misc.

Save Up To 50% Off Retail Store Supplement Prices In The Bodybuilding.com Store!

Reply
 
Thread Tools Rate Thread Display Modes
Old 04-15-2007, 05:12 AM   #1
Need4Advice
Banned
 
Need4Advice's Avatar
 
Join Date: Sep 2006
Age: 24
Stats: 6'0", 210 lbs
Posts: 2,336
BodyBlog Entries: 0
BodyPoints: 8357
Rep Power: 0
Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)
Visit Need4Advice's BodySpace
Red face Need help with Java!!! (Please Help) I romance inside of you!

Okay, before somebody tries to tell me to do a CardLayout, no that is not the issue here. First I will take a screenshot.



Now here is the code for that! What parts dont i really need for that? I mean its a long code. I want when u press the enter button for anew blank screen to appear.

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

public class nGame extends JFrame
{

private JTextField jTextField1;
private JButton jButton1;
private JPanel contentPane;


public nGame()
{
super();
initializeComponent();

this.setVisible(true);
}

private void initializeComponent()
{
jTextField1 = new JTextField();
jButton1 = new JButton();
contentPane = (JPanel)this.getContentPane();

jTextField1.setText("Enter Username");
jTextField1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField1_actionPerformed(e);
}

});

jButton1.setText("ENTER");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton1_actionPerformed(e);
}

});

contentPane.setLayout(null);
addComponent(contentPane, jTextField1, 175,110,112,22);
addComponent(contentPane, jButton1, 295,105,83,28);

this.setTitle("nGame - extends JFrame");
this.setLocation(new Point(81, 39));
this.setSize(new Dimension(479, 300));
}

private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}

private void jTextField1_actionPerformed(ActionEvent e)
{
System.out.println("\njTextField1_actionPerformed( ActionEvent e) called.");

}

private void jButton1_actionPerformed(ActionEvent e)
{
System.out.println("\njButton1_actionPerformed(Act ionEvent e) called.");
}
Need4Advice is offline   Reply With Quote
Old 04-15-2007, 05:14 AM   #2
Mourning Tide
Registered User
 
Mourning Tide's Avatar
 
Join Date: Mar 2007
Location: Australia
Age: 18
Stats: 6'1", 187 lbs
Posts: 6,143
BodyBlog Entries: 0
BodyPoints: 15384
Rep Power: 842
Mourning Tide has a reputation beyond repute. Best rank possible! (+100000)Mourning Tide has a reputation beyond repute. Best rank possible! (+100000)Mourning Tide has a reputation beyond repute. Best rank possible! (+100000)Mourning Tide has a reputation beyond repute. Best rank possible! (+100000)Mourning Tide has a reputation beyond repute. Best rank possible! (+100000)Mourning Tide has a reputation beyond repute. Best rank possible! (+100000)Mourning Tide has a reputation beyond repute. Best rank possible! (+100000)Mourning Tide has a reputation beyond repute. Best rank possible! (+100000)Mourning Tide has a reputation beyond repute. Best rank possible! (+100000)Mourning Tide has a reputation beyond repute. Best rank possible! (+100000)Mourning Tide has a reputation beyond repute. Best rank possible! (+100000)
Visit Mourning Tide's BodySpace
Holy crap WTF does that all mean - you might wanna join and ask a computer forum, not a bodybuilding one lol
Mourning Tide is offline   Reply With Quote
Old 04-15-2007, 05:21 AM   #3
Need4Advice
Banned
 
Need4Advice's Avatar
 
Join Date: Sep 2006
Age: 24
Stats: 6'0", 210 lbs
Posts: 2,336
BodyBlog Entries: 0
BodyPoints: 8357
Rep Power: 0
Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)
Visit Need4Advice's BodySpace
i know some of the guys here are pretty good at java
Need4Advice is offline   Reply With Quote
Old 04-15-2007, 05:29 AM   #4
BlueEyedAngeLuv
Registered User
 
BlueEyedAngeLuv's Avatar
 
Join Date: Mar 2007
Age: 30
Posts: 211
BodyBlog Entries: 0
BodyPoints: 3397
Rep Power: 0
BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)
Visit BlueEyedAngeLuv's BodySpace
you dont need the actionlistener stuff for the textfield since you dont care about when events happen there

you only care about the actionlistener for the button since your desired behavior is based on when the user clicks the button

theres not much else thats not needed
BlueEyedAngeLuv is offline   Reply With Quote
Old 04-15-2007, 05:35 AM   #5
BlueEyedAngeLuv
Registered User
 
BlueEyedAngeLuv's Avatar
 
Join Date: Mar 2007
Age: 30
Posts: 211
BodyBlog Entries: 0
BodyPoints: 3397
Rep Power: 0
BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)
Visit BlueEyedAngeLuv's BodySpace
Quote:
Originally Posted by Mourning Tide View Post
Holy crap WTF does that all mean - you might wanna join and ask a computer forum, not a bodybuilding one lol
lol i cant believe im gonna explain all this

ok these three lines below import certain libraries of code that have already been written. the java.awt classes are for the windowing code that draws the window in the gui. the event stuff underneath is for tracking events like when a user clicks something so you can do certain other things. the javax.swing is other gui code that has already been written so you just include it in your code and then can create objects of those types to do things that you dont have to write new code for

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






this makes a class called nGame so basically you can create nGame objects whenever/wherever you want and they behave this certain way. an object has certain values/private variables and certain methods you can call on it to make it do stuff


public class nGame extends JFrame
{




these are the three things you see in the image, the text field the button you click and the pane behind them

private JTextField jTextField1;
private JButton jButton1;
private JPanel contentPane;




much of the rest is action listener and action performed code to track when a user does something on these objects like click them or type text into them. then you can have the code basically listen for these events and then you can call other code to make it behave a certain way when a user does something

hope this helps


public nGame()
{
super();
initializeComponent();

this.setVisible(true);
}

private void initializeComponent()
{
jTextField1 = new JTextField();
jButton1 = new JButton();
contentPane = (JPanel)this.getContentPane();

jTextField1.setText("Enter Username");
jTextField1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField1_actionPerformed(e);
}

});

jButton1.setText("ENTER");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton1_actionPerformed(e);
}

});

contentPane.setLayout(null);
addComponent(contentPane, jTextField1, 175,110,112,22);
addComponent(contentPane, jButton1, 295,105,83,28);

this.setTitle("nGame - extends JFrame");
this.setLocation(new Point(81, 39));
this.setSize(new Dimension(479, 300));
}

private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}

private void jTextField1_actionPerformed(ActionEvent e)
{
System.out.println("\njTextField1_actionPerformed( ActionEvent e) called.");

}

private void jButton1_actionPerformed(ActionEvent e)
{
System.out.println("\njButton1_actionPerformed(Act ionEvent e) called.");
}
BlueEyedAngeLuv is offline   Reply With Quote
Old 04-15-2007, 06:07 AM   #6
manlet
Banned
 
manlet's Avatar
 
Join Date: Feb 2007
Age: 25
Stats: 5'5", 140 lbs
Posts: 854
BodyBlog Entries: 0
BodyPoints: 6540
Rep Power: 0
manlet has a reputation beyond repute. Best rank possible! (+100000)manlet has a reputation beyond repute. Best rank possible! (+100000)manlet has a reputation beyond repute. Best rank possible! (+100000)manlet has a reputation beyond repute. Best rank possible! (+100000)manlet has a reputation beyond repute. Best rank possible! (+100000)manlet has a reputation beyond repute. Best rank possible! (+100000)manlet has a reputation beyond repute. Best rank possible! (+100000)manlet has a reputation beyond repute. Best rank possible! (+100000)manlet has a reputation beyond repute. Best rank possible! (+100000)manlet has a reputation beyond repute. Best rank possible! (+100000)manlet has a reputation beyond repute. Best rank possible! (+100000)
Visit manlet's BodySpace
Even if I knew how to help you, I wouldn't, cuz I don't want you to romance inside of me.
manlet is offline   Reply With Quote
Old 04-15-2007, 12:22 PM   #7
Need4Advice
Banned
 
Need4Advice's Avatar
 
Join Date: Sep 2006
Age: 24
Stats: 6'0", 210 lbs
Posts: 2,336
BodyBlog Entries: 0
BodyPoints: 8357
Rep Power: 0
Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)
Visit Need4Advice's BodySpace
Quote:
Originally Posted by manlet View Post
Even if I knew how to help you, I wouldn't, cuz I don't want you to romance inside of me.
lol
Need4Advice is offline   Reply With Quote
Old 04-15-2007, 05:11 PM   #8
Need4Advice
Banned
 
Need4Advice's Avatar
 
Join Date: Sep 2006
Age: 24
Stats: 6'0", 210 lbs
Posts: 2,336
BodyBlog Entries: 0
BodyPoints: 8357
Rep Power: 0
Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)
Visit Need4Advice's BodySpace
hey guys how i make so when i click the JButton it goes to a new screen

here is the code:

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

public class nGame extends JFrame
{

private JTextField jTextField1;
private JButton jButton1;
private JPanel contentPane;


public nGame()
{
super();
initializeComponent();

this.setVisible(true);
}

private void initializeComponent()
{
jTextField1 = new JTextField();
jButton1 = new JButton();
contentPane = (JPanel)this.getContentPane();

jTextField1.setText("Enter Username");

jButton1.setText("ENTER");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton1_actionPerformed(e);
}

});

contentPane.setLayout(null);
addComponent(contentPane, jTextField1, 175,110,112,22);
addComponent(contentPane, jButton1, 295,105,83,28);

this.setTitle("Guess The Box");
this.setLocation(new Point(81, 39));
this.setSize(new Dimension(479, 300));
}

private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}

private void jButton1_actionPerformed(ActionEvent e)
{
System.out.println("\njButton1_actionPerformed(Act ionEvent e) called.");
}
Need4Advice is offline   Reply With Quote
Old 04-15-2007, 05:15 PM   #9
BlueEyedAngeLuv
Registered User
 
BlueEyedAngeLuv's Avatar
 
Join Date: Mar 2007
Age: 30
Posts: 211
BodyBlog Entries: 0
BodyPoints: 3397
Rep Power: 0
BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)BlueEyedAngeLuv is the lowest scum of the boards. (Worst Rank)
Visit BlueEyedAngeLuv's BodySpace
Quote:
Originally Posted by Need4Advice View Post
hey guys how i make so when i click the JButton it goes to a new screen

here is the code:

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

public class nGame extends JFrame
{

private JTextField jTextField1;
private JButton jButton1;
private JPanel contentPane;


public nGame()
{
super();
initializeComponent();

this.setVisible(true);
}

private void initializeComponent()
{
jTextField1 = new JTextField();
jButton1 = new JButton();
contentPane = (JPanel)this.getContentPane();

jTextField1.setText("Enter Username");

jButton1.setText("ENTER");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton1_actionPerformed(e);
}

});

contentPane.setLayout(null);
addComponent(contentPane, jTextField1, 175,110,112,22);
addComponent(contentPane, jButton1, 295,105,83,28);

this.setTitle("Guess The Box");
this.setLocation(new Point(81, 39));
this.setSize(new Dimension(479, 300));
}

private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}

private void jButton1_actionPerformed(ActionEvent e)
{
System.out.println("\njButton1_actionPerformed(Act ionEvent e) called.");
}


Go f2ck yourself dude I spent 5 minutes typing out two long responses helping you out and i didnt get a rep or even just thanks in return
BlueEyedAngeLuv is offline   Reply With Quote
Old 04-16-2007, 12:22 AM   #10
Need4Advice
Banned
 
Need4Advice's Avatar
 
Join Date: Sep 2006
Age: 24
Stats: 6'0", 210 lbs
Posts: 2,336
BodyBlog Entries: 0
BodyPoints: 8357
Rep Power: 0
Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)Need4Advice has a reputation beyond repute. Best rank possible! (+100000)
Visit Need4Advice's BodySpace
Quote:
Originally Posted by BlueEyedAngeLuv View Post
Go f2ck yourself dude I spent 5 minutes typing out two long responses helping you out and i didnt get a rep or even just thanks in return
well im sorry bud. I cant rep, im in red.
Need4Advice is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Member Login

Sign in for more FREE features and tools!

Username or
Email Address:
Password:
Remember Me


New to Bodybuilding.com?
Sign Up Now It's FREE!




All times are GMT -7. The time now is 07:15 AM. Archive