Soooooo Who wants to do my homework for me?
#1
Troll
Thread Starter
iTrader: (6)
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
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
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
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.
#5
Troll
Thread Starter
iTrader: (6)
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:
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
#6
Troll
Thread Starter
iTrader: (6)
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
#8
Troll
Thread Starter
iTrader: (6)
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
It worked just fine with one ****ing file for the summary button so why the gay do i need two files... piece of **** java
#10
Troll
Thread Starter
iTrader: (6)
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
#12
Troll
Thread Starter
iTrader: (6)
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*
*hopes that pisses someone off enough to find the problem*