Soooooo Who wants to do my homework for me?

Thread Tools
 
Search this Thread
 
Old 09-15-2006, 02:11 PM
  #1  
Troll
Thread Starter
iTrader: (6)
 
GT35 STI's Avatar
 
Join Date: Jan 2006
Location: In SoggyNoodles Low Rise Pants
Posts: 15,877
Car Info: 2008 Legacy Spec-B
Soooooo Who wants to do my homework for me?

Been working on this damn program all day long, and the assignment was to take the program(that I got working at the time) then take the "summary" button and make the portion of it into it's own .java file it's already 4 .java files long



kk lets see who knows..

Original code

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

public class JPanelDemo extends JFrame
{

	VacationPanel vp = new VacationPanel();
	MoviePanel mp = new MoviePanel();
	PasswordPanel pp = new PasswordPanel();


	
	JPanel summaryPanel = new JPanel();
	JButton summaryButton = new JButton("Summary");
	
	JLabel vacationLabel = new JLabel();
	JLabel movieLabel = new JLabel();
	JLabel passwordLabel = new JLabel();
	
	JButton colorButton = new JButton("Color?");
	Color buttonsColor = new Color(0.75f, 0.75f, 0.75f);
	
	public JPanelDemo()
	{
		Container canvas = getContentPane();
		canvas.setLayout( new BorderLayout() );
		
		canvas.add(vp, BorderLayout.WEST);
		canvas.add(mp, BorderLayout.NORTH);
		canvas.add(pp, BorderLayout.EAST);
		
		canvas.add(colorButton, BorderLayout.CENTER);
		
		//someone pressed the color button
		colorButton.addActionListener( new ActionListener()
		{
			public void actionPerformed( ActionEvent ae)
			{
				buttonsColor = JColorChooser.showDialog(null, "Pick a color for this button", buttonsColor);
				colorButton.setBackground(buttonsColor);
			}
		});
		
		fixUpSummaryPanel();
		canvas.add(summaryPanel, BorderLayout.SOUTH);
		this.setSize(500,250);
		this.setTitle("JPanelDemo Program");
		this.show();
	}
	
	public void fixUpSummaryPanel()
	{
		summaryPanel.setLayout( new FlowLayout() );
		summaryPanel.add(summaryButton);
		summaryPanel.add(vacationLabel);
		summaryPanel.add(movieLabel);
		summaryPanel.add(passwordLabel);
		
		summaryButton.addActionListener( new ActionListener()
		{
			public void actionPerformed( ActionEvent ae)
			{
				vacationLabel.setText(vp.getVacationChoice() );
				movieLabel.setText( mp.getMovieChoice() );
				passwordLabel.setText( pp.getPassword() );
				summaryButton.setBackground(buttonsColor);
			}
		});
		
	}


public static void main( String args[] )
	{
		JPanelDemo app = new JPanelDemo();
		app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

}
Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class MoviePanel extends JPanel
{
	JComboBox movieBox;
	String movieTypes[] = {"comedy", "romance", "scary", "mystery", "sci-fi" };
	String movieComments[] = {"very funny", "kiss kiss", "Ohhh!!!!", "who dun it", "bold new world"};
	JLabel pickLabel = new JLabel ("Movie Type?");
	JLabel responseLabel = new JLabel ("very funny");
	
	int choice;
	
	public MoviePanel()
	{
		setLayout( new FlowLayout() );
		
		movieBox = new JComboBox(movieTypes);
		
		add(pickLabel);
		add(movieBox);
		add(responseLabel);
		
		movieBox.addItemListener( new ItemListener()
		{
			public void itemStateChanged( ItemEvent ie)
			{
				choice = movieBox.getSelectedIndex();
				responseLabel.setText(movieComments[choice] );
			}
		});
		
		
	}
	
	public String getMovieChoice(){return movieTypes[choice] ; }
}
Code:
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;

public class PasswordPanel extends JPanel
{

	JPasswordField passwordField = new JPasswordField();
	JLabel label = new JLabel("Enter your password");
	char password[] = new char[15];
	String strPassword;
	
	public PasswordPanel()
	{
		setLayout( new BorderLayout() );
		
		add(label, BorderLayout.CENTER);
		add(passwordField, BorderLayout.SOUTH);
		
		
		passwordField.addActionListener( new ActionListener()
		{
			public void actionPerformed( ActionEvent ae)
			{
				password = passwordField.getPassword();
				strPassword = String.valueOf(password);
			}
		});
	}
	public String getPassword() {return strPassword ;}
}
Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class VacationPanel extends JPanel
{
	JRadioButton beachButton = new JRadioButton("The beach");
	JRadioButton skiButton = new JRadioButton("Moutain resort");
	JRadioButton shipButton = new JRadioButton("Ocean Cruise");
	
	JLabel vacationLabel = new JLabel("Pick a vacation Locale" ) ;
	JLabel responseLabel = new JLabel("Oh I love the beach.");
	
	ButtonGroup group = new ButtonGroup();
	
	String vacationChoice = "The beach";
	
	
	public VacationPanel()
	{
		group.add(beachButton);
		group.add(skiButton);
		group.add(shipButton);
		
		setLayout( new GridLayout( 5, 1) );
		
  		add(vacationLabel);
		add(beachButton);
		add(skiButton);
		add(shipButton);
		add(responseLabel);
		
		beachButton.setSelected(true);
		
		
		beachButton.addActionListener( new ActionListener ()
		{
			public void actionPerformed(ActionEvent ae)
			{
				responseLabel.setText("Oh I love the beach.");
				vacationChoice = "The beach";
			}
});	
	
	
		skiButton.addActionListener( new ActionListener ()
		{
			public void actionPerformed(ActionEvent ae)
			{
				responseLabel.setText("The skiing is great!");
				vacationChoice = "Mountains";
			}
});
	shipButton.addActionListener( new ActionListener ()
		{
			public void actionPerformed(ActionEvent ae)
			{
				responseLabel.setText("Eat ice cream on the ship.");
				vacationChoice = "Cruise ship";
			}
});
	
}	
	public String getVacationChoice() { return vacationChoice; }
}

and the above code worked as is! So I only had to edit to files to get the summary thingey on it's "own .java file" like the assignment wants

Edited portions

Code:
//File: SummaryButton


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



public class SummaryButton extends JPanel
{

	VacationPanel vp = new VacationPanel();
	MoviePanel mp = new MoviePanel();
	PasswordPanel pp = new PasswordPanel();
	JPanelDemo jp = new JPanelDemo();
	
	JLabel vacationLabel = new JLabel();
	JLabel movieLabel = new JLabel();
	JLabel passwordLabel = new JLabel();
	JButton JPanelDemo = new JButton();
	

	public SummaryButton()
	{
		JPanelDemo.addActionListener( new ActionListener()
		{
			public void actionPerformed( ActionEvent ae)
			{
				vacationLabel.setText(vp.getVacationChoice() );
				movieLabel.setText( mp.getMovieChoice() );
				passwordLabel.setText( pp.getPassword() );
			//	JPanelDemo.setBackground( jp.getbuttonsColor() );
			}
		});
		
	}

}
Code:
JPanelDemo extends JFrame
{

	VacationPanel vp = new VacationPanel();
	MoviePanel mp = new MoviePanel();
	PasswordPanel pp = new PasswordPanel();
	SummaryButton sb = new SummaryButton();


	
	JLabel vacationLabel = new JLabel();
	JLabel movieLabel = new JLabel();
	JLabel passwordLabel = new JLabel();
		
	JPanel summaryPanel = new JPanel();
	JButton SummaryButton = new JButton("Summary");
		
			
	JButton colorButton = new JButton("Color?");
	Color buttonsColor = new Color(0.75f, 0.75f, 0.75f);
	
	public JPanelDemo()
	{
		Container canvas = getContentPane();
		canvas.setLayout( new BorderLayout() );
		
		canvas.add(vp, BorderLayout.WEST);
		canvas.add(mp, BorderLayout.NORTH);
		canvas.add(pp, BorderLayout.EAST);
		
		canvas.add(colorButton, BorderLayout.CENTER);
	//	canvas.add(summaryPanel, BorderLayout.SOUTH);
		
		//someone pressed the color button
		colorButton.addActionListener( new ActionListener()
		{
			public void actionPerformed( ActionEvent ae)
			{
				buttonsColor = JColorChooser.showDialog(null, "Pick a color for this button", buttonsColor);
				colorButton.setBackground(buttonsColor);
			}
		});
		
		fixUpSummaryPanel();
		canvas.add(SummaryButton, BorderLayout.SOUTH);
		this.setSize(500,250);
		this.setTitle("JPanelDemo Program");
		this.show();
	}
	
	public void fixUpSummaryPanel()
	{
		summaryPanel.setLayout( new FlowLayout() );
		summaryPanel.add(vacationLabel);
		summaryPanel.add(movieLabel);
		summaryPanel.add(passwordLabel);		
		summaryPanel.add(SummaryButton);
	
	}

public static void main( String args[] )
	{
		JPanelDemo app = new JPanelDemo();
		app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}


}



When I run the program it just locks up... seems like the program is having trouble bringing up the GUI!!

Lets see who can decipher the problem

Last edited by GT35 STI; 09-15-2006 at 02:18 PM.
GT35 STI is offline  
Old 09-15-2006, 02:16 PM
  #2  
Token Toyota Mod
iTrader: (50)
 
soggynoodles's Avatar
 
Join Date: Jun 2004
Location: Palo Alto, CA
Posts: 52,306
Car Info: Something german
i do not.

oh and DO YOUR OWN WORK!! SLACKER!!
soggynoodles is offline  
Old 09-15-2006, 02:17 PM
  #3  
VIP Member
iTrader: (3)
 
Nick Koan's Avatar
 
Join Date: Feb 2003
Location: The BLC
Posts: 17,466
Car Info: Legacy GT
Java sucks. Use C#

Oh, and I don't look at code unless someone pays me to :hinthint:
Nick Koan is offline  
Old 09-15-2006, 02:18 PM
  #4  
VIP Member
iTrader: (7)
 
nachomc's Avatar
 
Join Date: Jun 2003
Location: Funtown
Posts: 25,095
Car Info: A limousine with a chauffer
So wait, you're saying Java is locking up? Are you sure it's not being just REALLY, REALLY slow? You know, like usual..
nachomc is offline  
Old 09-15-2006, 02:19 PM
  #5  
Troll
Thread Starter
iTrader: (6)
 
GT35 STI's Avatar
 
Join Date: Jan 2006
Location: In SoggyNoodles Low Rise Pants
Posts: 15,877
Car Info: 2008 Legacy Spec-B
Originally Posted by nKoan
Java sucks. Use C#

Oh, and I don't look at code unless someone pays me to :hinthint:

it's a class


and soggy :eadia:

I have been working on this **** all day long, and i know it's some stupid ****ing problem that I just can't see, because when you compile it... it doesn't error, but when you run it... it just locks up
GT35 STI is offline  
Old 09-15-2006, 02:19 PM
  #6  
Troll
Thread Starter
iTrader: (6)
 
GT35 STI's Avatar
 
Join Date: Jan 2006
Location: In SoggyNoodles Low Rise Pants
Posts: 15,877
Car Info: 2008 Legacy Spec-B
Originally Posted by sonicsuby
So wait, you're saying Java is locking up? Are you sure it's not being just REALLY, REALLY slow? You know, like usual..

ya The program errors out(when you run it) like it runs outa memory or something
GT35 STI is offline  
Old 09-15-2006, 02:21 PM
  #7  
VIP Member
iTrader: (7)
 
nachomc's Avatar
 
Join Date: Jun 2003
Location: Funtown
Posts: 25,095
Car Info: A limousine with a chauffer
:rotfl: at thread title
nachomc is offline  
Old 09-15-2006, 02:24 PM
  #8  
Troll
Thread Starter
iTrader: (6)
 
GT35 STI's Avatar
 
Join Date: Jan 2006
Location: In SoggyNoodles Low Rise Pants
Posts: 15,877
Car Info: 2008 Legacy Spec-B
Right now i would punch someone if the face without thinking twice about it... This **** ****ing gay *** program is pissing me the **** off LOL


It worked just fine with one ****ing file for the summary button so why the gay do i need two files... piece of **** java
GT35 STI is offline  
Old 09-15-2006, 02:25 PM
  #9  
VIP Member
iTrader: (4)
 
newyorkreload's Avatar
 
Join Date: Dec 2004
Location: 500mi North of Montana. Enjoying free health care.
Posts: 6,781
Car Info: Bugeyed Autowagon
I'm glad all I have to do is look at pics of dead people for my homework.
newyorkreload is offline  
Old 09-15-2006, 02:29 PM
  #10  
Troll
Thread Starter
iTrader: (6)
 
GT35 STI's Avatar
 
Join Date: Jan 2006
Location: In SoggyNoodles Low Rise Pants
Posts: 15,877
Car Info: 2008 Legacy Spec-B
Originally Posted by newyorkreload
I'm glad all I have to do is look at pics of dead people for my homework.

I might be giving your some new pics to look at shortly... I'm thinking a rampage right now might be in store
GT35 STI is offline  
Old 09-15-2006, 02:39 PM
  #11  
Token Toyota Mod
iTrader: (50)
 
soggynoodles's Avatar
 
Join Date: Jun 2004
Location: Palo Alto, CA
Posts: 52,306
Car Info: Something german
haha nice title change.

oh and google is your friend.
soggynoodles is offline  
Old 09-15-2006, 02:47 PM
  #12  
Troll
Thread Starter
iTrader: (6)
 
GT35 STI's Avatar
 
Join Date: Jan 2006
Location: In SoggyNoodles Low Rise Pants
Posts: 15,877
Car Info: 2008 Legacy Spec-B
I'll google when I get home... I guess my l337 programming skillz are far superior then you guys!! since no one can fix it!!




*hopes that pisses someone off enough to find the problem*
GT35 STI is offline  
Old 09-15-2006, 02:48 PM
  #13  
VIP Member
iTrader: (3)
 
Nick Koan's Avatar
 
Join Date: Feb 2003
Location: The BLC
Posts: 17,466
Car Info: Legacy GT
Nice try.

Looking through java code is more painful then my current task, so you're screwed
Nick Koan is offline  
Old 09-15-2006, 02:58 PM
  #14  
Token Toyota Mod
iTrader: (50)
 
soggynoodles's Avatar
 
Join Date: Jun 2004
Location: Palo Alto, CA
Posts: 52,306
Car Info: Something german
Maybe this place might have answers.

soggynoodles is offline  
Old 09-15-2006, 03:06 PM
  #15  
Registered User
 
ovscooby's Avatar
 
Join Date: Jun 2005
Location: Orangevale, CA
Posts: 65
Car Info: 2011WRX
Try this for a start. The SummaryButton is in a separate class with nothing fancy done. That you'll have to do yourself. Hope this helps.
Attached Files
File Type: zip
Stuff.zip (2.7 KB, 3 views)
ovscooby is offline  


Quick Reply: Soooooo Who wants to do my homework for me?



All times are GMT -7. The time now is 02:23 PM.