// InventoryGUI.java
//Using the JLabel class to display Inventory program
import java.awt.*; // specifies how components are arranged
import javax.swing.*; //see if the asterisk loads all that stuff.
import java.text.DecimalFormat; //decimalFormat loaded just in case it needs it to display properly
public class InventoryGUI extends JFrame //get parent class JFrame and use for new class InventoryGUI
{
private static final int WIDTH = 600;
private static final int HEIGHT = 150;
private JLabel itemNameL, quantityOnHandL, itemPriceL, productIdL, yearL, welcome1L, welcome2L, itemValueL, totalInvValueL,
restockingFeeL;// Declare Labels to be used in GUI
private JTextField itemNameTF, quantityOnHandTF, itemPriceTF, productIdTF, itemValueTF, totalInvValueTF,
yearTF, restockingFeeTF; // Declare TextFields to be used in GUI
public InventoryGUI() //InventoryGUI constructor adds JLabels and JTextFields to JFrame
{
itemNameL = new JLabel( "Name" );
quantityOnHandL = new JLabel( "Quantity on Hand" );
itemPriceL = new JLabel( "Price per item" );
productIdL = new JLabel( "Product ID" );
itemValueL = new JLabel( "Value of all Same Items" );
totalInvValueL = new JLabel( "Value of All Items" );
yearL = new JLabel( "Year" );
restockingFeeL = new JLabel( "Restocking Fee" );
itemNameTF = new JTextField( 30 );
quantityOnHandTF = new JTextField( 3 );
itemPriceTF = new JTextField( 10 );
productIdTF = new JTextField( 5 );
itemValueTF = new JTextField( 10 );
totalInvValueTF = new JTextField( 12 );
yearTF = new JTextField( 10 );
restockingFeeTF = new JTextField( 8 );
setTitle( "Sample Title: Mike's Inventory" );
Container pane = getContentPane();
pane.setLayout( new FlowLayout() );
pane.add( itemNameL );
pane.add( itemNameTF );
pane.add( quantityOnHandL );
pane.add( quantityOnHandTF );
pane.add( itemPriceL );
pane.add( itemPriceTF );
pane.add( productIdL );
pane.add( productIdTF );
pane.add( itemValueL );
pane.add( itemValueTF );
pane.add( totalInvValueL );
pane.add( totalInvValueTF );
pane.add( yearL );
pane.add( yearTF );
pane.add( restockingFeeL );
pane.add( restockingFeeTF );
setSize(WIDTH, HEIGHT);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[] args)
{
InventoryGUI InventoryObj = new InventoryGUI();
}
}
Maybe I can use the get methods, but I just don't know how the syntax works. Or Maybe I can't use the get methods, if not, could someone give me an idea of how the data gets into the GUI? Thanks!

New Topic/Question
Reply




MultiQuote





|