import javax.swing.JFrame;
import java.awt.*;
import java.awt.event.*;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.UIManager;
 
public class GUINew extends JDialog implements ActionListener
{
    public static void main (String [] args)       
  {
	protected JButton ok;
	protected JButton cancel;
	protected ButtonGroup type;
	protected JTextField bid;
	protected JTextField name;
	
	int theBid;
	String theName;
	String theType;
	
	public GUINew(String sTitle, JFrame owner) {
		super (owner, sTitle, true);
		setLooknFeel();
		bid = new JTextField(4);
		name = new JTextField(14);
		ok = new JButton("Hire Boat!");
		ok.addActionListener(this);
		cancel = new JButton("Cancel");
		cancel.addActionListener(this);
		
		type = new ButtonGroup();
		// create each radio button, specifying its label
		JRadioButton pedal = new JRadioButton("Pedal boat");
		JRadioButton rowing = new JRadioButton("Rowing boat");
		// set a String to associate with each button
		// will use this when the radio button is selected
		pedal.setActionCommand("Pedal boat");
		rowing.setActionCommand("Rowing boat");
		type.add(pedal);
		type.add(rowing);
		
		JPanel top = new JPanel();
		top.add(pedal);
		top.add(rowing);
	        getContentPane().add("North", top);
	
		JPanel center = new JPanel();
		center.add(new JLabel("Enter Boat ID:"));
		center.add(bid);
		center.add(new JLabel("Enter Name/Colour:"));
		center.add(name);
		getContentPane().add("Center", center);
		
		JPanel bottom = new JPanel();
		bottom.add(ok);
		bottom.add(cancel);
		getContentPane().add("South", bottom);
		
		pack();
	}
	
	public int getBid() { return theBid; }
	public String getName() { return theName; }
	public String getType() { return theType; }
	
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == ok)
		{
			theType = type.getSelection().getActionCommand();
		    // use the entered data
		    theBid = Integer.parseInt(bid.getText());
            theName = name.getText();
		}
		else if (e.getSource() == cancel) {
		    this.dispose(); //will release memory
			this.setVisible(false); //will hide the window
		} 
		dispose();
	}
	
	// windows look and feel settings
	protected void setLooknFeel() 
        {
        String lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
        try 
        {
            UIManager.setLookAndFeel(lookAndFeel);
        }
        catch (Exception e) 
        {
            e.printStackTrace();
        }
      }
    }
}

Error message java:17: illegal start of expression
protected JButton ok;
^

How do i get rid of this error message i have tried to get rid of the protected but more errors occure
and also how do i get the above prgram to work of this program

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

public class Hire extends JDialog implements ActionListener
{
public stimatic void main (String [] args) 
{
protected JButton ok;
protected JButton cancel;
protected JTextField bid;
protected JTextField name;
protected JTextField time;
protected BoatHireCompany theBoat;

public Hire(String sTitle, JFrame owner) {
super (owner, sTitle, true);
setLayout(new FlowLayout());
setSize(350,200);
add (new JLabel("Enter Boat ID:"));
bid = new JTextField(20);
add (bid);
add (new JLabel("Enter Customer Name:"));
name = new JTextField(20);
add (name);
add (new JLabel("Enter Current Time:"));
time = new JTextField(20);
add (time);
ok = new JButton("Hire Boat!");
ok.addActionListener(this);
add(ok);
cancel = new JButton("Cancel");
cancel.addActionListener(this); 
add(cancel);
}
public BoatHireCompany getBoat()
{
return theBoat;
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == ok) {
theBoat = new BoatHireCompany(bid.getText(), name.getText(), time.getText());
}
else if (e.getSource() == cancel) {
// data entry cancelled
theBoat = null;
} 
dispose();
}
}

that's not a "debugging problem", it's a "failure to learn the language syntax problem".

You don't use access modifiers inside methods.

what do you mean

He means don't declare your variables (if they have an access modifier like protected) in a method. Declare them outside of it.

public class GUINew extends JDialog implements ActionListener
{

	protected JButton ok;
	protected JButton cancel;
	protected ButtonGroup type;
	protected JTextField bid;
	protected JTextField name;
    

     public static void main (String [] args)       
  {

I have changed thing aroun as suggested but i cant get my GIU screen to work when i compile it it runs but it dosent display any thing for both the GUI and the HireGUI

import javax.swing.JFrame;
import java.awt.*;
import java.awt.event.*;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.UIManager;
 
public class GUINew extends JDialog implements ActionListener
{
    
	protected JButton ok;
	protected JButton cancel;
	protected ButtonGroup type;
	protected JTextField bid;
	protected JTextField name;
	
    public static void main (String [] args)       
  {
  }
      public GUINew(String sTitle, JFrame owner) 
        {
		super (owner, sTitle, true);
		setLooknFeel();
		bid = new JTextField(4);
		name = new JTextField(14);
		ok = new JButton("Hire Boat!");
		ok.addActionListener(this);
		cancel = new JButton("Cancel");
		cancel.addActionListener(this);
		
		type = new ButtonGroup();
		// create each radio button, specifying its label
		JRadioButton pedal = new JRadioButton("Pedal boat");
		JRadioButton rowing = new JRadioButton("Rowing boat");
		// set a String to associate with each button
		// will use this when the radio button is selected
		pedal.setActionCommand("Pedal boat");
		rowing.setActionCommand("Rowing boat");
		type.add(pedal);
		type.add(rowing);
		
		JPanel top = new JPanel();
		top.add(pedal);
		top.add(rowing);
	        getContentPane().add("North", top);
	
		JPanel center = new JPanel();
		center.add(new JLabel("Enter Boat ID:"));
		center.add(bid);
		center.add(new JLabel("Enter Name/Colour:"));
		center.add(name);
		getContentPane().add("Center", center);
		
		JPanel bottom = new JPanel();
		bottom.add(ok);
		bottom.add(cancel);
		getContentPane().add("South", bottom);
		
		pack();
	}
	
	public int getBid() {int theBid = 0; return theBid; }
	public String getName() {String theName = null; return theName; }
	public String getType() {String theType = null; return theType; }
	
	public void actionPerformed(ActionEvent e) {
        String theType;
        int theBid;
        String theName;
		if (e.getSource() == ok)
		{
			theType = type.getSelection().getActionCommand();
		    // use the entered data
		    theBid = Integer.parseInt(bid.getText());
                   theName = name.getText();
		}
		else if (e.getSource() == cancel) {
		    this.dispose(); //will release memory
			this.setVisible(false); //will hide the window
		} 
		dispose();
	}
	
	// windows look and feel settings
	protected void setLooknFeel() 
        {
        String lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
        try 
        {
            UIManager.setLookAndFeel(lookAndFeel);
        }
        catch (Exception e) 
        {
            e.printStackTrace();
        }
      }
    }

Hire.java

import javax.swing.JFrame;
import java.awt.*;
import java.awt.event.*;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.UIManager;
 
public class GUINew extends JDialog implements ActionListener
{
    
	protected JButton ok;
	protected JButton cancel;
	protected ButtonGroup type;
	protected JTextField bid;
	protected JTextField name;
	
    public static void main (String [] args)       
  {
  }
      public GUINew(String sTitle, JFrame owner) 
        {
		super (owner, sTitle, true);
		setLooknFeel();
		bid = new JTextField(4);
		name = new JTextField(14);
		ok = new JButton("Hire Boat!");
		ok.addActionListener(this);
		cancel = new JButton("Cancel");
		cancel.addActionListener(this);
		
		type = new ButtonGroup();
		// create each radio button, specifying its label
		JRadioButton pedal = new JRadioButton("Pedal boat");
		JRadioButton rowing = new JRadioButton("Rowing boat");
		// set a String to associate with each button
		// will use this when the radio button is selected
		pedal.setActionCommand("Pedal boat");
		rowing.setActionCommand("Rowing boat");
		type.add(pedal);
		type.add(rowing);
		
		JPanel top = new JPanel();
		top.add(pedal);
		top.add(rowing);
	        getContentPane().add("North", top);
	
		JPanel center = new JPanel();
		center.add(new JLabel("Enter Boat ID:"));
		center.add(bid);
		center.add(new JLabel("Enter Name/Colour:"));
		center.add(name);
		getContentPane().add("Center", center);
		
		JPanel bottom = new JPanel();
		bottom.add(ok);
		bottom.add(cancel);
		getContentPane().add("South", bottom);
		
		pack();
	}
	
	public int getBid() {int theBid = 0; return theBid; }
	public String getName() {String theName = null; return theName; }
	public String getType() {String theType = null; return theType; }
	
	public void actionPerformed(ActionEvent e) {
        String theType;
        int theBid;
        String theName;
		if (e.getSource() == ok)
		{
			theType = type.getSelection().getActionCommand();
		    // use the entered data
		    theBid = Integer.parseInt(bid.getText());
                   theName = name.getText();
		}
		else if (e.getSource() == cancel) {
		    this.dispose(); //will release memory
			this.setVisible(false); //will hide the window
		} 
		dispose();
	}
	
	// windows look and feel settings
	protected void setLooknFeel() 
        {
        String lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
        try 
        {
            UIManager.setLookAndFeel(lookAndFeel);
        }
        catch (Exception e) 
        {
            e.printStackTrace();
        }
      }
    }

Main.java

import boattest.Boat;
import java.util.*;
import java.io.*;
 
public class Main 
{	
	public static void main(String[] args) 
        {
	        String name = null;
                int id = 0;
        
		//scanner keyboard
		Scanner kybd = new Scanner(System.in);
		
		// create company
		BoatHireCompany octagon = new BoatHireCompany("octagon", 10);
		
		Boat titanic = new PedalBoat("Titanic", 11);
		Boat red = new RowingBoat("Red", 22);
		Boat green = new RowingBoat("Green", 33);
                {
		// add to company
		octagon.addBoat(new RowingBoat(name, id));
                octagon.addBoat(new PedalBoat(name, id));
               }
                               
      }
}

can you help me plz

once you instantiate your gui class you must use its setVisible() and pass in true.

i set the setVisible()and passed it as true it still didnt work is there any way to get the main.java to have control over the GUI so the all interact with one another

You must instantiate GUINew from your main class.

But the below in your main class's main method.

GUINew window= new GUINew("My Gui Window", new JFrame());
window.setVisible(true);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.