Java...again. :(

QuaunautQuaunaut The longest seven days in history... Join Date: 2003-03-21 Member: 14759Members, Constellation, Reinforced - Shadow
edited May 2005 in Off-Topic
<div class="IPBDescription">I know, I know, I suck</div> Okay. All I'm wanting to do is launch one window from another window. How would I go about doing this?

I know(obviously) how to launch it, now its just how to launch one window from another. As is I'm getting this error:

<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->--------------------Configuration: cargame - JDK version 1.5.0_02 <Default> - <Default>--------------------
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\rpg\rpg\cargame\src\Cargame.java:486: cannot find symbol
symbol  : method setDefaultCloseOperation(int)
location: class Cargame.hiredriverwindow
                       heh.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                          ^
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\rpg\rpg\cargame\src\Cargame.java:487: cannot find symbol
symbol  : method setSize(int,int)
location: class Cargame.hiredriverwindow
                       heh.setSize(1024, 768);
                          ^
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\rpg\rpg\cargame\src\Cargame.java:488: cannot find symbol
symbol  : method setVisible(boolean)
location: class Cargame.hiredriverwindow
                       heh.setVisible(true);
                          ^
3 errors

Process completed.
<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->

So take that as you will. If you need the actual code, here ya go(skip past this if you already know the answer). And ignore my mass amount of spacers o.o

<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class car{
String name;

int enginelevel;
int exhaustlevel;
int tirelevel;
int suspensionlevel;
int drivetrainlevel;
int weightlevel;
int rigiditylevel;

int acceleration = (exhaustlevel + tirelevel + drivetrainlevel + weightlevel)/4;
int maxspeed = (enginelevel + exhaustlevel + drivetrainlevel)/3;
int handling = (tirelevel + suspensionlevel + weightlevel + rigiditylevel)/4;

int carrarity = (acceleration+maxspeed+handling)/3;

car(){  
}

car(int e, int x, int t, int s, int d, int w, int r, String n){
 enginelevel = e;
 exhaustlevel = x;
 tirelevel = t;
 suspensionlevel = s;
 drivetrainlevel = d;
 weightlevel = w;
 rigiditylevel = r;
 name = n;
}
}

class driver {
String name;

int level;
int fatigue;

driver(){
}

driver(int l, int f, String n){
 level = l;
 fatigue = f;
 name = n;
}
}

public class Cargame extends JFrame{


int gametime = 52;
int currentime = 0;
int money = 20000;

driver none = new driver(0,0,"No Driver");
driver x = new driver(0,0,"No Driver");
driver y = new driver(0,0,"No Driver");
driver z = new driver(0,0,"No Driver");

driver alexfong = new driver(1,1,"Alex Fong");
driver billfenton = new driver(1,1,"Bill Fenton");
driver ericklomp = new driver(1,1,"Eric Klomp");
driver jakemays = new driver(10, 10,"Jake Mays");
driver corywilliams = new driver(1,1,"Cory Williams");
driver ricaagular = new driver(1,1,"Rica Aguilar");
driver colehansen = new driver(1,1,"Cole Hansen");
driver stephenscambler = new driver(1,1,"Stephen Scambler");
driver victorgutierrez = new driver(-10,10,"Victor Gutierrez");
driver chuvang = new driver(-5,5, "Chu Vang");
driver scottnonyurbusiness = new driver(1,1,"****");
driver carlosvargas = new driver(1,1,"Vargas");

int schoolprice = 500;
int engineupgradeprice = 250;
int exhaustupgradeprice = 800;
int tiresupgradeprice = 800;
int suspensionupgradeprice = 900;
int drivetrain = 400;
int weightupgradeprice = 1200;
int rigidityupgradeprice = 7000;

int mustangprice = 25500;
int nsxprice = 89000;
int celicaprice = 18500;
int rsxprice = 25000;
int corollaprice = 22300;
int nineelevenprice = 54300;
int bugprice = 19200;
int astonmartindb9price = 152000;
int astonmartinv12price = 235000;
int audittprice = 33500;
int bentlygtprice = 156000;
int bmw3seriesprice = 32000;
int bmw6seriesprice = 70000;
int cobaltprice = 15300;
int corvetteprice = 54000;
int montecarloprice = 25000;
int crossfireprice = 32000;
int crossfiresrtprice = 45000;
int sebringprice = 23200;
int dodgestratusprice = 21700;
int tiburonprice = 19200;
int hondaaccordprice = 23600;
int g35price = 33500;
int minicooperprice = 17000;
int eclipseprice = 21400;
int nissan350zprice = 32000;
int saturnionprice = 22300;

//engine, exhaust, tire, suspension, drivetrain, weight, rigidity
car nocar = new car          (0,0,0,0,0,0,0, "No Car");
car carx = new car           (0,0,0,0,0,0,0, "No Car");
car cary = new car           (0,0,0,0,0,0,0, "No Car");
car carz = new car           (0,0,0,0,0,0,0, "No Car");

car mustang = new car        (6,4,3,4,4,2,3, "Mustang");
car nsx = new car            (5,5,2,3,4,6,2, "Nsx");
car celica = new car         (7,5,4,4,5,6,7, "Celica");
car rsx = new car            (6,4,4,5,3,5,7, "RSX");
car corolla = new car        (4,3,4,3,7,4,8, "Corolla");
car nineeleven = new car     (4,3,6,6,8,2,2, "Porsche 911");
car bug = new car            (5,3,3,5,5,7,7, "VW Bug");
car astonmartindb9 = new car (7,4,4,3,6,4,2, "Aston Martin DB9");
car astonmartinv12 = new car (3,6,2,4,6,4,5, "Aston Martin V12");
car auditt = new car         (4,5,6,4,7,5,3, "Audi TT");
car bentlygt = new car       (5,4,3,5,4,4,5, "Bently GT");
car bmw3series = new car     (2,4,4,3,6,4,3, "BMW 3 Series");
car bmw6series = new car     (5,3,4,3,5,6,4, "BMW 6 Series");
car cobalt = new car         (4,3,2,5,4,5,4, "Cobalt");
car corvette = new car       (7,5,4,3,3,5,4, "Corvette");
car montecarlo = new car     (5,4,5,6,5,6,3, "Monte Carlo");
car crossfire = new car      (5,5,4,5,3,4,4, "Crossfire");
car crossfiresrt = new car   (7,3,4,3,4,5,2, "Crossfire SRT Edition");
car sebring = new car        (2,4,6,4,3,6,3, "Sebring");
car dodgestratus = new car   (2,5,4,5,4,4,3, "Stratus");
car tiburon = new car        (5,5,2,3,3,6,2, "Tiburon");
car hondaaccord = new car    (4,3,4,5,4,6,3, "Accord");
car g35 = new car            (6,5,3,3,2,1,2, "Infiniti G35");
car minicooper = new car     (3,3,4,5,3,3,7, "Mini Cooper");
car eclipse = new car        (4,2,6,7,5,4,6, "Eclipse");
car nissan350z = new car     (6,4,4,6,2,4,2, "Nissan 350z");
car saturnion = new car      (4,3,4,3,2,7,6, "Ion");



private GridBagLayout createLayout;
private GridBagConstraints createConstraints;

private JLabel title;

//Spacers
private JLabel onespace;
private JLabel onespace1;
private JLabel onespace2;
private JLabel onespace3;
private JLabel onespace4;
private JLabel onespace5;
private JLabel onespace6;
private JLabel onespace7;
private JLabel onespace8;
private JLabel onespace9;
private JLabel onespace10;
private JLabel onespace11;
private JLabel onespace12;

private JLabel menuspace;
private JLabel menuspace1;
private JLabel menuspace2;
private JLabel menuspace3;
private JLabel menuspace4;
private JLabel menuspace5;
private JLabel menuspace6;
private JLabel menuspace7;
private JLabel menuspace8;

private JLabel smallspace;
private JLabel smallspace1;
private JLabel smallspace2;
private JLabel smallspace3;
private JLabel smallspace4;
private JLabel smallspace5;
private JLabel smallspace6;
private JLabel smallspace7;
private JLabel smallspace8;

private JLabel mediumspace;
private JLabel mediumspace1;
private JLabel mediumspace2;
private JLabel mediumspace3;
private JLabel mediumspace4;
private JLabel mediumspace5;
private JLabel mediumspace6;
private JLabel mediumspace7;
private JLabel mediumspace8;

private JLabel longspace;
private JLabel longspace1;
private JLabel longspace2;
private JLabel longspace3;
private JLabel longspace4;
private JLabel longspace5;
private JLabel longspace6;
private JLabel longspace7;
private JLabel longspace8;

private JButton driverx;
private JButton drivery;
private JButton driverz;

private JButton buynewcar;
private JButton hirenewdriver;

private JButton nextweek;

private JButton Upgradecarx;
private JButton Upgradecary;
private JButton Upgradecarz;

private JTextField moneyfield;

private JTextField driverxlevelfield;
private JTextField driverxfatiguefield;

private JTextField driverylevelfield;
private JTextField driveryfatiguefield;

private JTextField driverzlevelfield;
private JTextField driverzfatiguefield;

private JTextField carxrarity;
private JTextField accelerationfieldx;
private JTextField maxspeedfieldx;
private JTextField handlingfieldx;

private JTextField caryrarity;
private JTextField accelerationfieldy;
private JTextField maxspeedfieldy;
private JTextField handlingfieldy;

private JTextField carzrarity;
private JTextField accelerationfieldz;
private JTextField maxspeedfieldz;
private JTextField handlingfieldz;

public Cargame(){
 super("RTMS: Racing Team Management Sim");
 
 createLayout = new GridBagLayout();
 setLayout(createLayout);
 createConstraints = new GridBagConstraints();
 
 title = new JLabel("Main Menu");
 
 onespace = new JLabel(" ");
 onespace1 = new JLabel(" ");
 onespace2 = new JLabel(" ");
 onespace3 = new JLabel(" ");
 onespace4 = new JLabel(" ");
 onespace5 = new JLabel(" ");
 onespace6 = new JLabel(" ");
 onespace7 = new JLabel(" ");
 onespace8 = new JLabel(" ");
 onespace9 = new JLabel(" ");
 onespace10 = new JLabel(" ");
 onespace11 = new JLabel(" ");
 onespace12 = new JLabel(" ");
 
 menuspace = new JLabel("                     ");
 menuspace1 = new JLabel("                   ");
 menuspace2 = new JLabel("                   ");
 menuspace3 = new JLabel("                   ");
 menuspace4 = new JLabel("                   ");
 menuspace5 = new JLabel("                   ");
 menuspace6 = new JLabel("                   ");
 menuspace7 = new JLabel("                   ");
 menuspace8 = new JLabel("                   ");
 
 smallspace = new JLabel("   ");
 smallspace1 = new JLabel("   ");
 smallspace2 = new JLabel("   ");
 smallspace3 = new JLabel("   ");
 smallspace4 = new JLabel("   ");
 smallspace5 = new JLabel("   ");
 smallspace6 = new JLabel("   ");
 smallspace7 = new JLabel("   ");
 smallspace8 = new JLabel("   ");
 
 mediumspace = new JLabel("     ");
 mediumspace1 = new JLabel("     ");
 mediumspace2 = new JLabel("     ");
 mediumspace3 = new JLabel("     ");
 mediumspace4 = new JLabel("     ");
 mediumspace5 = new JLabel("     ");
 mediumspace6 = new JLabel("     ");
 mediumspace7 = new JLabel("     ");
 mediumspace8 = new JLabel("     ");
 
 longspace = new JLabel("          ");
 longspace1 = new JLabel("          ");
 longspace2 = new JLabel("          ");
 longspace3 = new JLabel("          ");
 longspace4 = new JLabel("          ");
 longspace5 = new JLabel("          ");
 longspace6 = new JLabel("          ");
 longspace7 = new JLabel("          ");
 longspace8 = new JLabel("          ");
 
 driverx = new JButton(x.name);
 drivery = new JButton(y.name);
 driverz = new JButton(z.name);
 
 buynewcar = new JButton("Buy a Car");
 hirenewdriver = new JButton("Hire a New Driver");
 
 nextweek = new JButton("Do This Week's Race");
 
 Upgradecarx = new JButton("Upgrade "+carx.name);
 Upgradecary = new JButton("Upgrade "+cary.name);
 Upgradecarz = new JButton("Upgrade "+carz.name);
 
 moneyfield = new JTextField("$"+money,5);
 moneyfield.setEditable(false);
 
 driverxlevelfield = new JTextField(""+x.level, 2);
 driverxlevelfield.setEditable(false);
 driverxfatiguefield = new JTextField(""+x.fatigue, 2);
 driverxfatiguefield.setEditable(false);
 
 driverylevelfield = new JTextField(""+y.level,2);
 driverylevelfield.setEditable(false);
 driveryfatiguefield = new JTextField(""+y.fatigue,2);
 driveryfatiguefield.setEditable(false);
 
 
 driverzlevelfield = new JTextField(""+z.level,2);
 driverzlevelfield.setEditable(false);
 driverzfatiguefield = new JTextField(""+z.fatigue,2);
 driverzfatiguefield.setEditable(false);

 carxrarity = new JTextField(""+carx.carrarity,2);
 carxrarity.setEditable(false);
 accelerationfieldx = new JTextField(""+carx.acceleration,2);
 accelerationfieldx.setEditable(false);
 maxspeedfieldx = new JTextField(""+carx.maxspeed,2);
 maxspeedfieldx.setEditable(false);
 handlingfieldx = new JTextField(""+carx.handling,2);
 handlingfieldx.setEditable(false);
 
 caryrarity = new JTextField(""+cary.carrarity,2);
 caryrarity.setEditable(false);
 accelerationfieldy = new JTextField(""+cary.acceleration,2);
 accelerationfieldy.setEditable(false);
 maxspeedfieldy = new JTextField(""+cary.maxspeed,2);
 maxspeedfieldy.setEditable(false);
 handlingfieldy = new JTextField(""+cary.handling,2);
 handlingfieldy.setEditable(false);
 
 carzrarity = new JTextField(""+carz.carrarity,2);
 carzrarity.setEditable(false);
 accelerationfieldz = new JTextField(""+carz.acceleration,2);
 accelerationfieldz.setEditable(false);
 maxspeedfieldz = new JTextField(""+carz.maxspeed,2);
 maxspeedfieldz.setEditable(false);
 handlingfieldz = new JTextField(""+carz.handling,2);
 handlingfieldz.setEditable(false);
 
 if(x.name==none.name){
  driverx.setEnabled(false);
 }
 if(y.name==none.name){
  drivery.setEnabled(false);
 }
 if(z.name==none.name){
  driverz.setEnabled(false);
 }
 
 if(carx.name==nocar.name){
  Upgradecarx.setEnabled(false);
 }
 if(cary.name==nocar.name){
  Upgradecary.setEnabled(false);
 }
 if(carz.name==nocar.name){
  Upgradecarz.setEnabled(false);
 }
 
 createConstraints.fill=GridBagConstraints.BOTH;
 addComponent(title,              2, 1, 1, 1);
 addComponent(moneyfield,         6, 1, 1, 1);
 
 addComponent(onespace,           0, 2, 1, 1);
 addComponent(menuspace,          4, 2, 1, 1);
 
 addComponent(hirenewdriver,      0, 3, 1, 1);
 addComponent(longspace,          1, 3, 1, 1);
 addComponent(driverx,            2, 3, 2, 1);
 addComponent(drivery,            4, 3, 2, 1);
 addComponent(driverz,            6, 3, 2, 1);
 
 addComponent(driverxlevelfield,  2, 4, 1, 1);
 addComponent(driverxfatiguefield,3, 4, 1, 1);
 addComponent(driverylevelfield,  4, 4, 1, 1);
 addComponent(driveryfatiguefield,5, 4, 1, 1);
 addComponent(driverzlevelfield,  6, 4, 1, 1);
 addComponent(driverzfatiguefield,7, 4, 1, 1);
 
 addComponent(onespace1,          0, 5, 1, 1);
 
 addComponent(buynewcar,          0, 6, 1, 1);
 addComponent(longspace1,         1, 6, 1, 1);
 addComponent(Upgradecarx,        2, 6, 2, 1);
 addComponent(Upgradecary,        4, 6, 2, 1);
 addComponent(Upgradecarz,        6, 6, 2, 1);
 
 addComponent(carxrarity,         2, 7, 2, 1);
 addComponent(caryrarity,         4, 7, 2, 1);
 addComponent(carzrarity,         6, 7, 2, 1);
 
 addComponent(nextweek,           8, 8, 1, 1);
 
 HireNewDriver handler1 = new HireNewDriver();
 hirenewdriver.addActionListener(handler1);
 
 DriverX handler2 = new DriverX();
 driverx.addActionListener(handler1);
 
 DriverY handler3 = new DriverY();
 drivery.addActionListener(handler1);
 
 DriverZ handler4 = new DriverZ();
 driverz.addActionListener(handler1);
 
 BuyNewCar handler5 = new BuyNewCar();
 buynewcar.addActionListener(handler5);
 
 UpgradeCarX handler6 = new UpgradeCarX();
 Upgradecarx.addActionListener(handler6);
 
 UpgradeCarY handler7 = new UpgradeCarY();
 Upgradecary.addActionListener(handler7);
 
 UpgradeCarZ handler8 = new UpgradeCarZ();
 Upgradecarz.addActionListener(handler8);
 
 NextWeek handler9 = new NextWeek();
 nextweek.addActionListener(handler9);
 
 
}

 class hiredriverwindow {
  private GridBagLayout createLayout;
  private GridBagConstraints createConstraints;
 
  private JLabel drivertitle;
 
  private JLabel onespace;
  private JLabel onespace1;
  private JLabel onespace2;
  private JLabel onespace3;
  private JLabel onespace4;
  private JLabel onespace5;
  private JLabel onespace6;
  private JLabel onespace7;
  private JLabel onespace8;
 
  JButton alex;
  JButton bill;
  JButton jake;
  JButton cory;
  JButton rica;
  JButton cole;
  JButton stephen;
  JButton victor;
  JButton chu;
  JButton scott;
  JButton carlos;
 
  void runHireDriver(){
   hiredriverwindow heh = new hiredriverwindow();
  heh.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  heh.setSize(1024, 768);
  heh.setVisible(true);
  }
 
  public hiredriverwindow(){
 
 
  createLayout = new GridBagLayout();
  setLayout(createLayout);
  createConstraints = new GridBagConstraints();
 
  drivertitle = new JLabel("Hire a New Driver");
 
  onespace = new JLabel(" ");
  onespace1 = new JLabel(" ");
  onespace2 = new JLabel(" ");
  onespace3 = new JLabel(" ");
  onespace4 = new JLabel(" ");
  onespace5 = new JLabel(" ");
  onespace6 = new JLabel(" ");
  onespace7 = new JLabel(" ");
  onespace8 = new JLabel(" ");
 
  alex = new JButton("Alex Fong");
  bill = new JButton("Bill Fenton");
  jake = new JButton("Jake Mays");
  cory = new JButton("Rica Aguilar");
  rica = new JButton("Rica Aguilar");
  cole = new JButton("Cole Hansen");
  stephen = new JButton("Stephen Scambler");
  victor = new JButton("Chu Vang");
  scott = new JButton("Scott");
  carlos = new JButton("Carlos Vargas");
 
  createConstraints.fill=GridBagConstraints.BOTH;
  addComponent(title,     2, 0, 1, 1);
  addComponent(onespace,  0, 1, 1, 1);
  addComponent(alex,      0, 2, 1, 1);
  addComponent(bill,      1, 2, 1, 1);
  addComponent(jake,      2, 2, 1, 1);
  addComponent(cory,      3, 2, 1, 1);
  addComponent(cole,      4, 2, 1, 1);
  addComponent(stephen,   5, 2, 1, 1);
  addComponent(victor,    6, 2, 1, 1);
  addComponent(scott,     7, 2, 1, 1);
  addComponent(carlos,    8, 2, 1, 1);
 
  }
  private void addComponent(Component component, int column, int row, int width, int height){
 createConstraints.gridx = column;
 createConstraints.gridy = row;
 createConstraints.gridwidth = width;
 createConstraints.gridheight = height;
 createLayout.setConstraints(component, createConstraints);
 add(component);
 }
 
 }
 
 class HireNewDriver implements ActionListener{
  public void actionPerformed(ActionEvent event){
 
  }
 }
 
  class DriverX implements ActionListener{
  public void actionPerformed(ActionEvent event){
  }
 }
 
  class DriverY implements ActionListener{
  public void actionPerformed(ActionEvent event){
  }
 }
 
  class DriverZ implements ActionListener{
  public void actionPerformed(ActionEvent event){
  }
 }
 
  class BuyNewCar implements ActionListener{
  public void actionPerformed(ActionEvent event){
  }
 }
 
  class UpgradeCarX implements ActionListener{
  public void actionPerformed(ActionEvent event){
  }
 }
 
  class UpgradeCarY implements ActionListener{
  public void actionPerformed(ActionEvent event){
  }
 }
 
  class UpgradeCarZ implements ActionListener{
  public void actionPerformed(ActionEvent event){
  }
 }
 
  class NextWeek implements ActionListener{
  public void actionPerformed(ActionEvent event){
  }
 }
 
 

private void addComponent(Component component, int column, int row, int width, int height){
 createConstraints.gridx = column;
 createConstraints.gridy = row;
 createConstraints.gridwidth = width;
 createConstraints.gridheight = height;
 createLayout.setConstraints(component, createConstraints);
 add(component);
}

public static void main(String args[]){
 Cargame cargame = new Cargame();
 cargame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 cargame.setSize(1024, 768);
 cargame.setVisible(true);
}
}<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->

Comments

  • Vahn_PaktuVahn_Paktu Join Date: 2002-10-28 Member: 1666Members, Constellation
    <!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->class hiredriverwindow {
     private GridBagLayout createLayout;
     private GridBagConstraints createConstraints;

     private JLabel drivertitle;

     private JLabel onespace;
     private JLabel onespace1;
     private JLabel onespace2;
     private JLabel onespace3;
     private JLabel onespace4;
     private JLabel onespace5;
     private JLabel onespace6;
     private JLabel onespace7;
     private JLabel onespace8;

     JButton alex;
     JButton bill;
     JButton jake;
     JButton cory;
     JButton rica;
     JButton cole;
     JButton stephen;
     JButton victor;
     JButton chu;
     JButton scott;
     JButton carlos;

     void runHireDriver(){
      [I]hiredriverwindow heh = new hiredriverwindow();[/I]
     heh.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     heh.setSize(1024, 768);
     heh.setVisible(true);
     }<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->

    It's been a while since I programmed in Java so if I am wrong forgive me.

    Since runHireDriver is in the class of hiredriverwindow, should it be able to create a new instance of the class it is in? That seems to be a loop.

    Also it seems that the compiler can't find the method setDefaultCloseOperation(int) in the hiredriverwindow class. Do you need hiredriverwindow to extend something because you don't have it written there?
  • QuaunautQuaunaut The longest seven days in history... Join Date: 2003-03-21 Member: 14759Members, Constellation, Reinforced - Shadow
    Wow. Simply extending it basically fixed it. GG booksnotexplaininganything.

    But for some odd reason, this new frame that is opened has both it's frame, and the original frame, combined into one.
  • ZelZel Join Date: 2003-01-27 Member: 12861Members
    thats because you made a new frame. the code is doing exactly as its told!

    and please learn to read errors <!--emo&:p--><img src='http://www.unknownworlds.com/forums/html/emoticons/tounge.gif' border='0' style='vertical-align:middle' alt='tounge.gif' /><!--endemo--> the exception said right there that it cant find the method so-and-so within the class so-and-so

    means the class doesnt ahve the method. fine, give it the method by having it extend a superclass JFrame.

    and argh! why are there so many global variables?! you only need globals for things that will be referenced by the whole program, otherwise the frames shouldnt care what the name of every two-spacer label is!!
  • QuaunautQuaunaut The longest seven days in history... Join Date: 2003-03-21 Member: 14759Members, Constellation, Reinforced - Shadow
    Don't get mad: Educate. Realize I'm learning this from a class, and the teacher is barely a few days ahead of us.
  • HibameHibame Join Date: 2003-11-16 Member: 22974Members, Reinforced - Shadow
    If the teacher is only a few days ahead of you, you might wanna read ahead a few days and out smart him by asking questions he doesnt know the answers too =P <!--emo&::nerdy::--><img src='http://www.unknownworlds.com/forums/html/emoticons/nerd-fix.gif' border='0' style='vertical-align:middle' alt='nerd-fix.gif' /><!--endemo-->
  • QuaunautQuaunaut The longest seven days in history... Join Date: 2003-03-21 Member: 14759Members, Constellation, Reinforced - Shadow
    <!--QuoteBegin-Hibame+May 13 2005, 10:28 AM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (Hibame @ May 13 2005, 10:28 AM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> If the teacher is only a few days ahead of you, you might wanna read ahead a few days and out smart him by asking questions he doesnt know the answers too =P <!--emo&::nerdy::--><img src='http://www.unknownworlds.com/forums/html/emoticons/nerd-fix.gif' border='0' style='vertical-align:middle' alt='nerd-fix.gif' /><!--endemo--> <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd-->
    You talk as if I haven't done this already numerous times XD

    <3

    I've read the entirety of the two books we've done. <!--emo&:(--><img src='http://www.unknownworlds.com/forums/html/emoticons/sad-fix.gif' border='0' style='vertical-align:middle' alt='sad-fix.gif' /><!--endemo-->
  • MintmanMintman Join Date: 2003-05-30 Member: 16866Members
    Out of interest, why do you have the price of the cars seperate to the Car class? It is much better from an OOP viewpoint to include it in the class. Also it is standard practice to name classes with a capital letter at the start to distinguish them from primitive types. Therefore, the class should be called Car not car.

    I haven't done much with Swing so couldn't help you with your problem, but that's a couple of things that I came up with whilst skimming through your code. Good luck with your learning!
  • SnidelySnidely Join Date: 2003-02-04 Member: 13098Members
    edited May 2005
    I can't let you waste so much time on those spacers. Sorry.

    Have a gander at <a href='http://java.sun.com/docs/books/tutorial/uiswing/layout/spring.html' target='_blank'>SpringLayout</a>. It lets you place components in relation to other components. Much better than most of the layouts.

    Could you also post what the exercise is? I get an idea from the code, obviously, but it would be nice to know the exact problem.
  • QuaunautQuaunaut The longest seven days in history... Join Date: 2003-03-21 Member: 14759Members, Constellation, Reinforced - Shadow
    edited May 2005
    <!--QuoteBegin-Mintman+May 14 2005, 03:51 AM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (Mintman @ May 14 2005, 03:51 AM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> Out of interest, why do you have the price of the cars seperate to the Car class? It is much better from an OOP viewpoint to include it in the class. Also it is standard practice to name classes with a capital letter at the start to distinguish them from primitive types. Therefore, the class should be called Car not car.

    I haven't done much with Swing so couldn't help you with your problem, but that's a couple of things that I came up with whilst skimming through your code. Good luck with your learning! <!--QuoteEnd--></td></tr></table><div class='postcolor'><!--QuoteEEnd-->
    Ah, yeah. I haven't 'cleaned' the problem up yet. That was actually the first thing I did in the program- didn't even have the thought at the time to make a 'car' class until the next day! <!--emo&:D--><img src='http://www.unknownworlds.com/forums/html/emoticons/biggrin-fix.gif' border='0' style='vertical-align:middle' alt='biggrin-fix.gif' /><!--endemo-->

    Snidely: Looks interesting. Thanks for the linkage o.o

    Its not a excercise: Its the end-year project. Yeah, pretty basic class, eh?
Sign In or Register to comment.