Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

declare a variable

Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to delcare variables but not construct them at this point in my code. This is what I have done:

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

public class AddHorseType extends JFrame implements ActionListener
JPanel horsePanel;
CardLayout horseLayout;
JTextField coatColorField;
JTextField ageField;
JTextField heightField;
JTextField horseIDField;
JTextField saddleField;
JTextField heavyBreedField;

JLabel coatColorLabel;
JLabel ageLabel;
JLabel heightLabel;
JLabel idLabel;
JLabel saddleLabel;
JLabel heavyhorseLabel;

JRadioButton saddleHorseRB;
JRadioButton heavyHorseRB;
JRadioButton americanSaddleRB;
JRadioButton englishSaddleRB;
JRadioButton draftRB;
JRadioButton harnessRB;

JButton addButton;
JButton clearButton;
JButton closeButton;

However, I think I am suppose to use the =new for each of these. I can't figure it out. I have tried several different ways:

Jpanel=new JPanel horsePanel; But I don't think this is right, either? Could someone please tell me how I declare, but not construct the variabel using the =new.
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

If you look at it long enough, it catches on.
    Bookmark Topic Watch Topic
  • New Topic