Question: Can someone please add the code to my inItSelectPanel ( ) method that selects the data within my record within my data to display.Using this
Can someone please add the code to my inItSelectPanel method that selects the data within my record within my data to display.Using this psuedocode Extract the ship name from selected item of the options from the pull down list REPEAT for each ship in the ship list where full data is stored. IF ship name is the same as the selected ship name fill all textfields with the information the ship exit REPEAT END IF END REPEAT. It should display the information of the ship based off of what ship name the user has selected. All ships have the same attributes. This is in a submethod within a class. I already have an an ArrayList of Ship objects and JTextFields to display ship information.
Code so far:
public class ShipWindow extends JFrame
dimensions of the window
private int windwid ;
private int windhei ;
JComboBox selectShipBox;
ArrayList flotilla new ArrayList;
private JTextField nameText, nationText,yearText, lenText, draftText, beamText;
private JButton clearButton, quitButton, addShipButton;
String fileName TiaRosasFleet.csv;
File inFile new FilefileName;
private void initSelectPanel
int fontSize ;
Font bigFont new FontArial fontSize ;
JLabel lab new JLabelSelect a Ship";
lab.setFontbigFont;
selectShipBox new JComboBox;
selectShipBox.addItemListenernew ItemListener
public void itemStateChangedItemEvent ie
String selectedShip String iegetItem;
call helper method
forShip ship: flotilla
ifshipgetNameequalsselectedShip
nameText.setTextshipgetName;
nationText.setTextshipgetNation;
yearText.setTextIntegertoStringshipgetYearBuilt;
lenText.setTextDoubletoStringshipgetLength;
draftText.setTextDoubletoStringshipgetDraft;
beamText.setTextDoubletoStringshipgetBeam;
System.out.printlnSelected ship: selectedShip;
;
String shipNames Green Acres Afloat","Sputnik",
"Her Majesty's Glory",
"Sulaco","Nostromos","Flying Dutchmen","Enterprize","Black Pearl",
PT"Titanic","IronSides","Nautilus","El Vaquero","Machu Picchu",
"Folgers Best";
selectShipBox.setModelnew javax.swing.DefaultComboBoxModelshipNames;
selectShipBox new JComboBoxshipNames;
ImageIcon icon new ImageIconYachtbig.png;
int scalex ;
int scaley ;
JLabel iconLab new JLabel
public void PaintComponentGraphics g
Image img icon.getImage;
gdrawImageimg scalex,scaley, this;
;
iconLab.setPreferredSizenew Dimensionscalex scaley;
iconLab.setIconicon;
JPanel northPan new JPanel;
northPan.addiconLab;
northPan.addlab;
northPan.addselectShipBox;
this.addnorthPanBorderLayout.NORTH;
Green Acres Afloat, USA,
Sputnik, Russia,
Her Majesty's Glory, UK
Sulaco, USA,
Nost romos, USA,
Flying Dutchmen, Tortuga,
Enterprize, USSF,
Black Pearl, Barbados,
PT USN,
Titanic, UK
IronSides, USA,
Nautilus, no flag,
E Vaquero, Argentina,
Machu Picchu Skiff, Peru,
Folgers Best, Columbia,
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
