Question: Can someone please correct my initializeShips ( ) method it should loads ship data from ship class to an ArrayList called flotilla and uses the
Can someone please correct my initializeShips method it should loads ship data from ship class to an ArrayList called flotilla and uses the method call initializeShipsTiaRosasFleet.csv using scanner and using the method called: initializeShipsTiaRosasFleet.csv; could you also look at my initSelectPanel method im unable to get this to work. Could someone please fix and explain this. Thank you
import javax.swing.;
import java.awt.;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.;
import java.io;
public class ShipWindow extends JFrame
dimensions of the window
private int windwid ;
private int windhei ;
JComboBox selectShipBox;
ArrayList flotilla new ArrayList;
JTextField nameText, nationText,yearText, lenText, drafText, beamText;
String fileName TiaRosasFleet.csv;
File inFile new FilefileName;
public ShipWindow
this.setTitle "Shipping News ;
set size using private variables as argument
this.setSizewindwid,windhei;
this.setDefaultCloseOperationJFrameEXITONCLOSE;
initializeShipsTiaRosasFleet.csv
initialize flotilla list by opening csv file and pass it file name
of ship data
initInfoPanel create center zone;
initButtonPanel; mlect add actionlistners to buttons
insert all helper methods used to create and populate window application
init.SelectPanel;
this.setVisibletrue;
private void initializeShipsString fileName
File inFile new FilefileName;
try
Scanner inScan new ScannerinFile;
while inScanhasNext
Ship ship null;
String name inScan.next;
String nation inScan.next;
int year inScan.nextInt;
int length inScan.nextInt;
int draft inScan.nextInt;
int beam inScan.nextInt;
ship new Shipname nation, year, length, draft, beam;
forint i; ishipNames;
selectShipBox new JComboBox;
ImageIcon icon new ImageIconYachtbig.png;
int scalex ;
int scaley ;
JLabel iconLab new JLabel
public void PaintComponentGraphics g
Image img icon.getImage;new object campable of being scaled
gdrawImageimg scalex,scaley, this;
;
iconLab.setPreferredSizenew Dimensionscalex scaley;
iconLab.setIconicon;
JPanel northPan new JPanel;
northPan.addiconLab;
northPan.addlab;
this.addnorthPanBorderLayout.NORTH;
public static void mainString args
ShipWindow aw new ShipWindow;
class Ship
private String name; Ship name
private String nation; Nation of registry
private int yearBuilt; digit year built
private int length; Length of ship at mean draft
private int draft;
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
