JTextArea displaying weird error message - java

I have checked all over internet looking for what may be causing this error... but I haven't been lucky. My code basically gets the text from a JTextField and a JComboBox and passes it to a JTextArea when the user presses a button. That's the code...
final JTextField quant = new JTextField(3);
final JTextArea list = new JTextArea(10,30);
list.setEditable(false);
JPanel entry = new JPanel();
entry.add(quant);
entry.add(optionProds);
JButton adiciona = new JButton("Adicionar");
entry.add(adiciona);
entry.add(list);
adiciona.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
list.setText(optionProds.getSelectedItem().toString() + "-" + quant);
System.out.print(list.getText());
}
});
finalAction.add(entry);
The problem is that when I press the button, the JTextArea won't display the name of the product and its amount, but the text below instead:
Gato-javax.swing.JTextField[,134,8,37x20,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource#2034094f,flags=296,maximumSize=,minimumSize=,preferredSize=,caretColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],disabledTextColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],editable=true,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],selectedTextColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],columns=3,columnWidth=11,command=,horizontalAlignment=LEADING]
What could be causing this?

use
list.setText(optionProds.getSelectedItem().toString() + "-" + quant.getText());
instead of
list.setText(optionProds.getSelectedItem().toString() + "-" + quant);
why do you print quant? quant is a jtextfiled .that's not a error .this is what you get when you print a jcomponent .when you print a jcomponent you get properties and values such as location,border,margin...etc. so you should print the text using getText() method

Related

how to combine joptionpane with combobox

i want my joptionpane can combine with combobox,and the combobox data is in database, how i managed that.
i've tried change but the red code always show
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String wel = sdf.format(cal1.getDate());
String NamaFile = "/report/harianMasuk.jasper";
HashMap hash = new HashMap();
String tak = JOptionPane.showOptionDialog(null,id.getSelectedIndex()-1,"Laporan Supplier",JOptionPane.QUESTION_MESSAGE);
try {
hash.put("til", wel);
hash.put("rul", tak);
runReportDefault(NamaFile, hash);
} catch (Exception e) {
JOptionPane.showMessageDialog(rootPane, e);
}
Read the section from the Swing tutorial on Getting User Input From a Dialog.
It demonstrates how to display a combo box in a JOptionPane.
Not exactly sure what you are trying to accomplish but it appears to be that you want to utilize a JComboBox within a JOptionPane dialog window. This ComboBox would be filled with specific data from your database. The User is to select from this ComboBox and your application continues processing based on that selection. If this is the case then you might want to try something like this:
String selectedItem = "";
int selectedItemIndex = -1;
/* Ensure dialog never hides behind anything (use if
the keyword 'this' can not be used or there is no
object to reference as parent for the dialog). */
JFrame iframe = new JFrame();
iframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
iframe.setAlwaysOnTop(true);
// ---------------------------------------------------
int btns = JOptionPane.OK_CANCEL_OPTION;
String dialogMessage = "<html>Select the desired item from the Drop-Down "
+ "list<br>you want to work with:<br><br></html>";
String dialogTitle = "Your Fav Items";
/* Up to you to gather what you want placed into the
JComboBox that will be displayed within the JOptionPane. */
String[] comboBoxItems = {"Your", "DB", "Items", "You", "Want", "To",
"Add", "To", "ComboBox"};
BorderLayout layout = new BorderLayout();
JPanel topPanel = new JPanel(layout);
JLabel label = new JLabel(dialogMessage);
topPanel.add(label, BorderLayout.NORTH);
JPanel centerPanel = new JPanel(new BorderLayout(5, 5));
JComboBox cb = new JComboBox();
cb.setModel(new DefaultComboBoxModel<>(comboBoxItems));
cb.setSelectedIndex(-1);
centerPanel.add(cb, BorderLayout.CENTER);
topPanel.add(centerPanel);
// Ensure a selection or Cancel (or dialog close)
while (selectedItemIndex < 0) {
int res = JOptionPane.showConfirmDialog(iframe, topPanel, dialogTitle, btns);
if (res == 2) {
selectedItem = "Selection Option Was Canceled!";
break;
}
selectedItemIndex = cb.getSelectedIndex();
if (res == JOptionPane.OK_OPTION) {
if (selectedItemIndex == -1) {
JOptionPane.showMessageDialog(iframe, "<html>You <b>must</b> "
+ "select something or select <font color=red><b>Cancel</b></font>.",
"Invalid Selection...", JOptionPane.WARNING_MESSAGE);
}
else {
selectedItem = cb.getSelectedItem().toString();
}
}
iframe.dispose();
}
JOptionPane.showMessageDialog(iframe, "<html>You selected the ComboBox item:"
+ "<br><br><b><font color=blue><center>" + selectedItem + "</center>"
+ "</font></b><br></html>", "Selected Item", JOptionPane.INFORMATION_MESSAGE);
iframe.dispose();
With the above code, the Input dialog that will be displayed would look something like this:
It is up to you to find the means to fill the comboBoxItems String Array used within the code above.

How to plus 2 JTextField numbers?

I want to add two numbers and put the result into a JTextFields (textboxes). Why doesn't this code work?
public class Window extends JFrame implements ActionListener {
private JButton plus;
private JLabel text;
private JTextField textbox1;
private JTextField textbox2;
public Okno(){
this.setLayout(new FlowLayout());
this.setBounds(400,400,400,400);
plus = new JButton("+");
text = new JLabel("");
plus.addActionListener(this);
textbox1 = new JTextField(" ");
textbox2 = new JTextField(" ");
this.add(text);
this.add(textbox1);
this.add(textbox2);
this.add(plus);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(plus)){
int result = Integer.valueOf(textbox1.getText()) + Integer.valueOf(textbox2.getText());
text.setText(Integer.toString(result)); //gtregergregergergreg
}
}
}
Thank you for your help.
It works, if you remove spaces while putting numbers to the text fields, otherwise you get NumberFormatException. By the way don't use spaces for aligning the text fields. You can use setColumns or different layout manager. Also you should validate input to be sure there are just numbers, if you want to add them together.
Delete spaces from:
textbox1 = new JTextField(" ");
textbox2 = new JTextField(" ");
cause while parsing to Integer it fails.
Set prefered size of textbox1 and textbox2:
textbox1 = new JTextField();
textbox1.setPreferredSize(new Dimension(20,20));
textbox2 = new JTextField();
textbox2.setPreferredSize(new Dimension(20,20));
Hope I helped :)

get values of Jtextfields when click OK in Dialog

My need is to display a tab in a JDialog (confirmDialog or inputDialog). The tab contains 2 JTextField per row. The display works fine :
but I don't know how to get the values of the JTextFields.
Here is the display code :
int size = model.getCheckedApplications().size();
// une ligne par application sélectionnée
layout = new GridLayout(size + 1, 3, 5, 5);
myPanel = new JPanel(layout);
myPanel.add(new JLabel("Application"));
myPanel.add(new JLabel("Version cadre"));
myPanel.add(new JLabel("Nouvelles natures"));
for (Application app : model.getCheckedApplications()) {
myPanel.add(new JLabel(app.getCode88()));
JTextField versionActuelleField = new JTextField(30);
versionActuelleField.setName("versionActuelle"
+ app.getCode88());
versionActuelleField.setText(app
.getVersionCadreActuelle());
JTextField nouvellesNaturesField = new JTextField(
30);
nouvellesNaturesField.setName("nouvellesNatures"
+ app.getCode88());
myPanel.add(versionActuelleField);
myPanel.add(nouvellesNaturesField);
}
result = JOptionPane.showConfirmDialog(null, myPanel,
"Valeurs de cette version",
JOptionPane.OK_CANCEL_OPTION);
Then I don't know how to get the values when the user clicks on the OK Button :
if (result == 0) { // The user clicks on the ok button
You need to add them to some list that you store, so you can get at them again. Since you are adding them in reference to an application, I would suggest a Map
private Map<Application, JTextField> nouvellesNaturesFields = new ArrayListMultimap<Application, JTextField>(); //Or Hashmap, if the key is unique
private Map<Application, JTextField> versionActuelleFields = new ArrayListMultiMap<Application, JTextField>();
public List<JTextField> getNouvellesNaturesFields() {
return nouvellesNaturesFields ;
}
public List<JTextField> getVersionActuelleFields () {
return versionActuelleFields ;
}
//class code
for (Application app : model.getCheckedApplications()) {
//Other code
JTextField nouvellesNaturesField = new JTextField(
30);
nouvellesNaturesField.setName("nouvellesNatures"
+ app.getCode88());
nouvellesNaturesFields.put(app, nouvellesNaturesField);
//Other code and same for your new nature fields
}
result = JOptionPane.showConfirmDialog(null, myPanel,
"Valeurs de cette version",
JOptionPane.OK_CANCEL_OPTION);
Then when the user clicks the confirm button, using the property accessor getNouvellesNaturesFields()or getVersionActuelleFields() you can iterate all the fields created, like so:
for (Map.Entry<Application, JTextField> entry: myMap.entries()) {
//Do something here
}
Or you could also get them via:
for (Application app : model.getCheckedApplications()) {
List<JTextField> data = myMap.get(app);
for(JTextField field : data) {
field.getText();
}
}
Since the key value probably won't be unique, I used an ArrayListMultiMap, but if it would be unique, then a HashMap should suffice
You assign the Jtextfield value to a string using the getText() method e.g below
String texfield = JTextField.getText();
Subsequently you use the String textfield wherever you want. And to get the right jtextfield you have to get text from the textfield you want for example you have four Jtexfield. Assuming they are JTextField1, JTextField2, JTextField3 and JTextField4. To get the value of JTextField3 you have
String texfield = JTextField3.getText();
The values should be in the JTextFields you created:
versionActuelleField
nouvellesNaturesField
Also, you might want to look at ParamDialog, which I implemented to be a generic solution to this question.
EDIT
Yes I see now that you are creating these JTextFields in a loop. So you need to create a Collection, I'd suggest a Map<String, JTextField> where you could map all of your application names to the matching JTextField, as well as iterate over the collection to get all application names / JTextFields.

Calling specific methods between classes

Help! I dont know much about java but im trying to create a small program where people can buy items and the stock should update depending on their purchase. I have 2 different classes but what im trying to do is that i want to get the amount of items the user purchases from one class and use that number to update the stock in another class - Here is the section of my code in which i am struggling with
Code for Purchasing Item
public class PurchaseItem extends JFrame implements ActionListener {
JTextField ItemNo = new JTextField(5); //Adds a text field named ItemNo
JTextField AmountNo = new JTextField(5); //Adds a text field named AmountNo
TextArea information = new TextArea(6, 40); //Adds a text area named Information
TextArea reciept = new TextArea (10,50); //Adds a text area named Reciept
JButton Check = new JButton("Check"); //Adds a button named Check
JButton Buy = new JButton("Buy"); //Adds a button named Buy
DecimalFormat pounds = new DecimalFormat("£#,##0.00"); //For output to display in decimal and pounds format
public PurchaseItem() { //PurchaseItem class
this.setLayout(new BorderLayout()); //Adds a new layout for PurchaseItem
JPanel top = new JPanel(); //JPanel is a a container for other components
top.setLayout(new FlowLayout(FlowLayout.CENTER)); //It is set to the center of the frame
JPanel bottom = new JPanel(); //JPanel is a a container for other components
bottom.setLayout(new FlowLayout(FlowLayout.CENTER)); //It is set to the center of the frame
bottom.add(Buy); //Insert the "Buy" JButton on the frame
this.add(bottom, BorderLayout.SOUTH); //Button goes at the bottom of the frame
setBounds(100, 100, 450, 250); //Sets the bounds of the frame
setTitle("Purchase Item"); //Sets the title of the frame
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //Default option to exit frame is through button and not X sign
top.add(new JLabel("Enter Item Key:")); //Add a new JLabel at the top of the frame
top.add(ItemNo); //Set the ItemNo Text Field at the top of the frame
top.add(new JLabel ("Enter Amount:")); //Add a new JLabel at the top of the frame
top.add(AmountNo); //Set the AmountNo Text Field at the top of the frame
top.add(Check); //Set the Check Button at the top of the frame
Buy.setText("Buy"); Buy.setVisible(true); //Makes the text of the Buy Button visible
Check.addActionListener(this); //Add an ActionListener to the Check Button
Buy.addActionListener(this); //Add an ActionListener to the Buy Button
add("North", top);
JPanel middle = new JPanel(); //JPanel is a a container for other components
middle.add(information); //Set the Information Text Area at the middle of the frame
add("Center", middle);
setResizable(false); //Makes the frame not resizeable
setVisible(true); //Makes the frame visible
}
#Override //Overrides the method of the PurchaseItem class to identify mistakes and typos
public void actionPerformed(ActionEvent e) { //actionPerformed class. This is called when the actionListener event happens
String ItemKey = ItemNo.getText(); //String for getting the user input from the ItemNo Text Field
String ItemAmount = AmountNo.getText(); //String for getting the user input from the AmountNo Text Field
String Name = StockData.getName(ItemKey); //String for getting the name of the item from StockData
int Amount = Integer.parseInt(ItemAmount); //Convert String ItemAmount into an Integer variable named Amount
int NewStock = StockData.getQuantity(ItemKey) - Amount; //Integer named NewStock. NewStock is the current stock(from StockData) minus the Amount
double Total = Amount * StockData.getPrice(ItemKey); //Double named Total. Total is the Amount multiplied by the price of the item(from StockData)
Calendar cal = Calendar.getInstance(); //Calendar named cal. getInstance is used to get the current time
SimpleDateFormat Date = new SimpleDateFormat("dd/MM/yyyy"); //SimpleDateFormat named Date. It is used to display the date
SimpleDateFormat Time = new SimpleDateFormat("HH:mm:ss"); //SimpleDateFormat named Time. It is used to display the time
if (Name == null){ //If the Name is invalid and has no return value
information.setText("There is no such item"); //Display the message on the Information Text Area
}
else if (Amount > StockData.getQuantity(ItemKey)) { //Else if the Amount(User Input) is more than the quantity of the item(from StockData)
information.setText("Sorry there is not enough stock available"); //Display the message on the Information Text Area
}
else { //Otherwise
information.setText(Name + " selected: " + Amount); //Add the Name and the Amount of the item on the Information Text Area
information.append("\nIndividual Unit Price: " + pounds.format(StockData.getPrice(ItemKey))); //On a new line add the individual price of the item on the Information Text Area in a pound format(£)
information.append("\nCurrent Stock Available: " + StockData.getQuantity(ItemKey)); //On a new line add the current quantity available according to StockData on the Information Text Area
information.append("\nNew Stock After Sale: " + NewStock); //On a new line add the NewStock on the Information Text Area
information.append("\n\nTotal: " + Amount + " Units" + " at " + pounds.format(StockData.getPrice(ItemKey)) + " each"); //On two new lines add the Amount plus the item price(from StockData). This becomes the Total
information.append("\n= " + pounds.format(Total)); //On a new line display the Total in a pounds format(£) on the Information Text Area
}
if (e.getSource() == Buy) { //If the user clicks the Buy Button
int response = JOptionPane.showConfirmDialog(null, "Buy " + Amount + " Units" + " for " + pounds.format(Total) + "?"); //Show a confirm dialog asking the user to confirm the purchase with a Yes, No, or Cancel option
if (response == JOptionPane.YES_OPTION) { //If the user clicks Yes on the confirm dialog
JFrame frame2 = new JFrame(); //Add a new JFrame called frame2
TextArea Reciept = new TextArea ("Receipt For Your Purchase", 20,40); //Add the Receipt Text Area onto frame2 and show the message
Reciept.append("\n\nTime: " + Time.format(cal.getTime())); Reciept.append("\nDate: " + Date.format(cal.getTime())); //On seperate lines add the Time and the Date (from Calendar)
Reciept.append("\n\nYou Have Purchased The Following Item(s): "); //Display the message
Reciept.append("\n\n" + Name + "\n" + Amount + " Units" + "\n" + pounds.format(StockData.getPrice(ItemKey)) + " each"); //On a line add the Name and Item Amount followed by the item price (from StockData) on a new line
Reciept.append("\n\n\n" + Amount + " Unit(s)" + " at " + pounds.format(StockData.getPrice(ItemKey)) + " each" + "\nTotal = " + pounds.format(Total)); //After 3 lines display the Item Amount and the item price on the same line. On a new line display the Total in a pounds format
Reciept.append("\n\n\nThank You For Your Purchase" + "\n\nGoodbye :)"); //Show a message on two seperate lines
frame2.pack(); frame2.setSize(375, 380); frame2.setLocation(250, 250); ;frame2.setTitle("Receipt"); //Sets the size, the location, and the title of frame2
frame2.setVisible(true); frame2.setResizable(false); //sets frame2 so that it is visible and not resizable
frame2.add(Reciept); //Display the Reciept Text Area on frame2
frame2.setLayout(new FlowLayout(FlowLayout.CENTER)); //It is set to the center of the frame
}else{ //Otherwise
if (response == JOptionPane.NO_OPTION){ //If the user clicks No or Cancel on the confirm dialog
//Do nothing
}
}
Code for Checking Stock
public class CheckStock extends JFrame implements ActionListener {
JTextField stockNo = new JTextField(7); //adds a text field for user input
JTextField AmountNo = new JTextField(5);
TextArea information = new TextArea(6, 40); //adds a text area for the output
JButton check = new JButton("Check Stock"); //adds a button with the text "Check Stock"
JButton Clear = new JButton();
DecimalFormat pounds = new DecimalFormat("£#,##0.00"); //for output to display in decimal and pound format
public CheckStock() { //"CheckStock" class
setLayout(new BorderLayout()); //adds a new frame for "CheckStock"
setBounds(100, 100, 450, 220); //sets the size and location of the frame
setTitle("Check Stock"); //sets the title of the frame
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //user has to click on "Exit" button instead of X sign
check.addActionListener(this); //adds an action listener for the "check" button so when clicked by user, "actionPerformed" class is called
JPanel top = new JPanel(); //JPanel is a a container for other components. It is used at the top of the frame
add("North", top);
top.add(new JLabel("Enter Item Key:")); //adds a label at the top of tne frame
top.add(stockNo); //adds the "stockNo" text field to the top of the frame
top.add(check); //adds the "check" button to the top of the frame
JPanel middle = new JPanel(); //JPanel is a a container for other components. It is used at the middle of the frame
add("Center", middle);
middle.add(information); //in the middle of the frame, add the "information" text area
setResizable(false); //frame is not resizable
setVisible(true); //frame is visible
}
public void actionPerformed(ActionEvent e) { //this code is fired once the user runs the ActionListener
String key = stockNo.getText(); //string named "key" for the stockNo
String name = StockData.getName(key); //string named "name" for the stockData
int Quantity = StockData.getQuantity(key);
int NewStock;
if (name == null) { //if there is no input in the text field
information.setText("Enter Item Key"); //display the message on the text area
}
else if (e.getSource() == check) {
StockData.getQuantity(key);
information.append( "" + StockData.getName(key));
information.append("\n New Stock: " + StockData.getQuantity(key)); //otherwise
information.setText(name); //display the name of the item
information.append("\nPrice: " + pounds.format(StockData.getPrice(key))); //display the price of the item using pound format
information.append("\nPrevious Stock: " + Quantity); //display the amount in stock for the item according to StockData
}
}
}
You didn't initialise the object Update: your line of code should be
PurchaseItem Update = new PurchaseItem();
(As another point I can't see any code that adds the JComponent you created (e.g. the buttons, the text fields,...) to the two frames of the respective classes or that displays the two frames; if it isn't included in your code be sure to add these pieces of code).
Finally, if you need a code that checks for changes in the value of Updated, here's the simplest (but not the only) technique you can use, creating a thread (see the Oracle documentation to know what are threads and how to use them):
int refreshTime = 1000; // Refresh time in milliseconds
boolean running = true; // Set it to false if you want to stop the thread
Runnable r = new Runnable({
#Override
public void run() {
while(running) {
Thread.sleep(refreshTime);
// Put here your code to update your frames or your variables
}
});

Writing actionListner to display form input on console upon confirmation

I am currently constructing a GUI which allows me to add new cruises to the system. I want to write an actionListner which once the user clicks on "ok" then the form input will be displayed as output on the console.
I currently have the following draft to complete this task:
ok = new JButton("Add Cruise");
ok.setToolTipText("To add the Cruise to the system");
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event){
int selected = typeList2.getSelectedIndex();
String tText = typeList2[selected];
Boolean addtheCruise = false;
addtheCruise = fleet.addCruise();
fleet.printCruise();
if (addtheCruise)
{
frame.setVisible(false);
}
else
{ // Report error, and allow form to be re-used
JOptionPane.showMessageDialog(frame,
"That Cruise already exists!", "Error",
JOptionPane.ERROR_MESSAGE);
}
}
});
buttonPanel.add(ok);
Here is the rest of the code to the Form input frame:
contentPane2 = new JPanel (new GridLayout(18, 1)); //row, col
nameInput = new JLabel ("Input Cruise Name:");
nameInput.setForeground(normalText);
contentPane2.add(nameInput);
Frame2.add(contentPane2);
Cruisename = new JTextField("",10);
contentPane2.add(Cruisename);
Frame2.add(contentPane2, BorderLayout.CENTER);
Frame2.setVisible(true);
confirmPanel = new JPanel ();
confirmPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
confirmPanel.setBorder(BorderFactory.createLineBorder(Color.PINK));
addItinerary = new JButton("Add Itinerary");
confirmPanel.add(Add);
confirmPanel.add(addItinerary );
Frame2.add(confirmPanel, BorderLayout.PAGE_END);
Frame2.setVisible(true);
contentPane2.add(Cruisename);
Frame2.add(contentPane2);
// add spacing between comboboxes
contentPane2.add(Box.createRigidArea(new Dimension(5,0)));
contentPane2.setBorder(BorderFactory.createLineBorder(Color.black));
//Label for start and end location jcombobox
CruiseMessage = new JLabel ("Enter Start and End Location of new Cruise:");
CruiseMessage.setForeground(normalText);
contentPane2.add(CruiseMessage);
Frame2.add(contentPane2);
/**
* creating start location JComboBox
*/
startL = new JComboBox();
final JComboBox typeList2;
final String[] typeStrings2 = {
"Select Start Location", "Tobermory","Oban", "Isle of Mull", "Isle of Harris",
"Lewis and Harris", "Stornoway", "Skye", "Portree"};
startL = new JComboBox(typeStrings2);
contentPane2.add(startL);
Frame2.add(contentPane2, BorderLayout.CENTER);
Frame2.setVisible(true);
// add spacing between comboboxes
contentPane2.add(Box.createRigidArea(new Dimension(5,0)));
/**
* creating end location JComboBox
*/
endL = new JComboBox();
final JComboBox typeList3;
final String[] typeStrings3 = {
"Select End Location", "Tobermory","Oban", "Isle of Mull", "Isle of Harris",
"Lewis and Harris", "Stornoway", "Skye", "Portree"};
endL = new JComboBox(typeStrings3);
contentPane2.add(endL);
Frame2.add(contentPane2, BorderLayout.CENTER);
Frame2.setVisible(true);
// add spacing between comboboxes
contentPane2.add(Box.createRigidArea(new Dimension(5,0)));
//Label for select ship jcombobox
selectShipM = new JLabel ("Select Ship to assign Cruise:");
selectShipM.setForeground(normalText);
contentPane2.add(selectShipM);
Frame2.add(contentPane2);
/**
* creating select ship JCombobox
* select ship to assign cruise
*/
selectShip = new JComboBox();
final JComboBox typeList4;
final String[] typeStrings4 = {
"Select Ship", "Dalton Princess", "Stafford Princess" };
selectShip = new JComboBox(typeStrings4);
contentPane2.add(selectShip);
Frame2.add(contentPane2, BorderLayout.CENTER);
Frame2.setVisible(true);
I need all form inputs from the code above to be displayed on the console upon completion.
Summary:
1. I have two ships in one fleet
2. To add new cruise, all fields (Name, start date, end date, ship) must be selected.
The Problem:
1. I keep coming up with errors when creating " fleet = new Fleet();" in my constructor. Even though I have declared it in my class.
2. In the draft code below, line 5 states "typeList2", however, I have two JComboBox's - two different type Strings for both drop down menu's (Shown in the rest of the code). How do I input both typeLists to the output rather than just one?
Thank you.

Categories

Resources