I having major issues trying to make a GUI for this program. How do I connect my program to my GUI? I don't get it?Can someone help me with this? I also can't get result to read on my GUI.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ofelia.s_inventory_program_3_and_4_gui;
/**
*
* @author Ofelia G. S. Stewart
*/
public class GUI extends javax.swing.JFrame {
/**
* Creates new form GUI
*/
public GUI() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
Exit = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
Exit.setText("Exit");
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null},
{null, null, null, null, null, null},
{null, null, null, null, null, null},
{null, null, null, null, null, null},
{null, null, null, null, null, null},
{null, null, null, null, null, null}
},
new String [] {
"DVD Title:", "Qty. of Stock:", "Item #:", "Price:", "Restocking Fee:", "Total Value:"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class
};
boolean[] canEdit = new boolean [] {
false, false, false, false, false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jTable1.setRowHeight(24);
jScrollPane1.setViewportView(jTable1);
if (jTable1.getColumnModel().getColumnCount() > 0) {
jTable1.getColumnModel().getColumn(0).setResizable(false);
jTable1.getColumnModel().getColumn(1).setResizable(false);
jTable1.getColumnModel().getColumn(2).setResizable(false);
jTable1.getColumnModel().getColumn(3).setResizable(false);
jTable1.getColumnModel().getColumn(4).setResizable(false);
jTable1.getColumnModel().getColumn(5).setResizable(false);
}
jLabel1.setText("Welcome to DVD Inventory");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 554, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(251, 251, 251)
.addComponent(Exit)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addGap(207, 207, 207)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(Exit)
.addContainerGap(23, Short.MAX_VALUE))
);
jLabel1.getAccessibleContext().setAccessibleName("Welcome to DVD Inventory");
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new GUI().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton Exit;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
// End of variables declaration
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ofelia.s_inventory_program_3_and_4_gui;
/**
*
* @author Ofelia G. S. Stewart
*/
public class TestClass{
public static void main(String arg[]){
Product dvd;
dvd = new DVD(" Armegeddon",1,5,17.00);
System.out.println(dvd);
dvd = new DVD(" Fast 5",2,3,17.00);
System.out.println(dvd);
dvd = new DVD(" Independence Day",3,10,19.95);
System.out.println(dvd);
dvd = new DVD(" Tokyo Drift",4,11,19.95);
System.out.println(dvd);
dvd = new DVD(" Ride Along",5,12,11.00);
System.out.println(dvd);
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ofelia.s_inventory_program_3_and_4_gui;
/**
*
* @author Ofelia G. S. Stewart
*/
class Product{
private double prdStock;
private double prdPrice;
private double prdItem;
Product(double Stock, double Price, double Item){
prdStock = Stock;
prdPrice = Price;
prdItem = Item;
}
public void setPrdItem(int item){
prdItem = item;
}//end method set DVD Item
//return DVD Item
public double getPrdItem(){
return prdItem;
}//end method get DVD Item
//set DVD Title
public void setPrdStock(double Stock){
prdStock = Stock;
}//end method set DVD Stock
//return DVD Stock
public double getPrdStock(){
return prdStock;
}//end method get DVD Stock
public void setPrdPrice(double Price){
prdPrice = Price;
}//end method Set DVD Price
//return DVD price
public double getPrdPrice(){
return prdPrice;
}//end method get DVD Price
//calculate inventory value
public double value(){
return prdPrice * prdStock;
}//end method value
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ofelia.s_inventory_program_3_and_4_gui;
/**
*
* @author Ofelia G. S. Stewart
*/
class DVD extends Product{
String title;
double restockingFee=.05;
DVD(String title,double Stock, double Price, double Item){
super(Stock,Price,Item);
this.title=title;
}
public void setTitle(String title){
this.title=title;
}
public String getTitle(){
return this.title;
}
@Override
public double value(){
double temp=getPrdPrice() * getPrdStock();
double temp1=temp*restockingFee;
return temp+temp1;
}
@Override
public String toString()
{
return "Product: " + getTitle() + "\n" +
"Product Item: " + getPrdItem() + "\n" +
"Qty In Stock: " + getPrdStock() + "\n" +
"Product Price: $" + getPrdPrice() + "\n" +
"Stock Value without Restocking Fee: $" + super.value()+ "\n" +
"Stock Value with Restocking Fee: $" + value();
}
}// end