Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
2102-Group-Project-Spring-2017/src/view/FSWindow.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
184 lines (143 sloc)
5.58 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package view; | |
import java.awt.*; | |
import java.awt.Window; | |
import java.awt.event.*; | |
import javax.swing.*; | |
public class FSWindow { | |
//please ignore all of this. It's mostly my reference code. I'm going to work on it later. | |
private JFrame mainFrame; | |
private JLabel headerLabel; | |
private JLabel statusLabel; | |
private JPanel controlPanel; | |
public FSWindow(){ | |
prepareGUI(); | |
} | |
public static void main(String[] args){ | |
FSWindow FSWindow = new FSWindow(); | |
FSWindow.showButtonDemo(); | |
} | |
private void prepareGUI(){ | |
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); | |
splitPane.setOneTouchExpandable(true); | |
splitPane.setDividerLocation(150); | |
JTabbedPane tabbedPane = new JTabbedPane(); | |
ImageIcon icon = createImageIcon("images/middle.gif"); | |
String[] columnNames = {"First Name", "Last Name"}; | |
Object[][] data = { | |
{"Kathy", "Smith"}, | |
{"John", "Doe"}, | |
{"Sue", "Black"}, | |
{"Jane", "White"}, | |
{"Joe", "Brown"} | |
}; | |
JTable table = new JTable(data, columnNames); | |
tabbedPane.addTab("Total CashFlow", table); | |
tabbedPane.setMnemonicAt(0, KeyEvent.VK_1); | |
String[] incomeColumns = {"Description", "CashFlow"}; | |
Object[][] income = { | |
{"Salary",""/**salary of user*/}, | |
{"Interest/dividends", ""/**call interest of user*/}, | |
{"Real Estate/Business",""/**business of user*/}, | |
{"Real Estate/Business",""/**business of user*/}, | |
{"Real Estate/Business",""/**business of user*/}, | |
{"Real Estate/Business",""/**business of user*/}, | |
}; | |
JTable incomeTable = new JTable(income, incomeColumns); | |
tabbedPane.addTab("Income", incomeTable); | |
tabbedPane.setMnemonicAt(1, KeyEvent.VK_2); | |
String[] expenseColumns = {"Description", "CashFlow"}; | |
Object[][] expense = { | |
{"Taxes",""/**user variable*/}, | |
{"Home Mortgage Payment", ""/**user variable**/}, | |
{"School Loan Payment",""/**user variable**/}, | |
{"Car Loan Payment",""/**user variable**/}, | |
{"Credit Card Payment",""/**user variable**/}, | |
{"Other Expenses",""/**user variable**/}, | |
{"Bank Loan Payment",""/**user variable**/}, | |
{"Per Child Expense",""/**user variable**/}, | |
}; | |
JTable expenseTable = new JTable(expense, expenseColumns); | |
tabbedPane.addTab("Expenses", expenseTable); | |
tabbedPane.setMnemonicAt(2, KeyEvent.VK_3); | |
String[] assetColumns = {"Description", "CashFlow"}; | |
Object[][] asset = { | |
{"Savings",""/**user variable*/}, | |
{"Precious Metals", ""/**user variable**/}, | |
{"Stocks",""/**user variable**/}, //total stocks number and total money | |
}; | |
JTable assetTable = new JTable(asset, assetColumns ); | |
String[] assetColumns2 = {"Description", "Down Payment", "Cost"}; | |
Object[][] asset2 = { | |
{"Name",""/**user variable*/,""}, | |
{"Name", ""/**user variable**/,""}, | |
{"Name",""/**user variable**/, ""/**user variable**/,""}, //total stocks number and total money | |
}; | |
JTable assetTable2 = new JTable(asset2, assetColumns2 ); | |
tabbedPane.addTab("Assets", assetTable2); | |
tabbedPane.setMnemonicAt(3, KeyEvent.VK_4); | |
String[] liabiltiesColumns = {"Description", "Liabilities"}; | |
Object[][] liabilties = { | |
{"Home Mortgage",""/**user variable*/}, | |
{"School Loans", ""/**user variable**/}, | |
{"Car Loans",""/**user variable**/, ""/**user variable**/}, | |
{"Credit Card Debt", ""/**user variable**/}, | |
{"Bank Loans", ""/**user variable**/}, | |
}; | |
JTable liabiltiesTable = new JTable(liabilties, liabiltiesColumns ); | |
String[] liabiltiesColumns2 = {"Real Estate/Business", "Mortgage/Liability"}; | |
Object[][] liabilties2 = { | |
{"Name",""/**user variable*/}, | |
{"Name", ""/**user variable**/}, | |
{"Name",""/**user variable**/, ""/**user variable**/}, | |
{"Name", ""/**user variable**/}, | |
{"Name", ""/**user variable**/}, | |
}; | |
JTable liabiltiesTable2 = new JTable(liabilties2, liabiltiesColumns2 ); | |
Component panel5 = (JComponent) makeTextPanel("Panel #5"); | |
tabbedPane.addTab("Liabilities", panel5); | |
tabbedPane.setMnemonicAt(4, KeyEvent.VK_5); | |
incomeTable.setPreferredSize(new Dimension(410, 250)); | |
expenseTable.setPreferredSize(new Dimension(410, 250)); | |
assetTable.setPreferredSize(new Dimension(410, 250)); | |
assetTable2.setPreferredSize(new Dimension(410, 250)); | |
mainFrame = new JFrame("CashFlow"); | |
mainFrame.getContentPane().setBackground(new Color(149, 32, 216)); | |
mainFrame.setSize(400,250); | |
//need to set this to null and position everything manually | |
mainFrame.setLayout(new FlowLayout()); | |
mainFrame.addWindowListener(new WindowAdapter() { | |
public void windowClosing(WindowEvent windowEvent){ | |
System.exit(0); | |
} | |
}); | |
headerLabel = new JLabel("", JLabel.CENTER); | |
headerLabel.setFont(headerLabel.getFont().deriveFont(Font.BOLD, 16f)); | |
statusLabel = new JLabel("",JLabel.CENTER); | |
//new statuslabel of "10% of your whatever is XX dollars" | |
statusLabel.setSize(350,100); | |
controlPanel = new JPanel(); | |
controlPanel.setLayout(new FlowLayout()); | |
controlPanel.setBackground(new Color(149, 32, 216)); | |
mainFrame.add(headerLabel); | |
mainFrame.add(controlPanel); | |
mainFrame.add(statusLabel); | |
mainFrame.setVisible(true); | |
mainFrame.add(splitPane); | |
splitPane.add(tabbedPane); | |
} | |
private ImageIcon createImageIcon(String string) { | |
// TODO Auto-generated method stub | |
return null; | |
} | |
protected Component makeTextPanel(String text) { | |
JPanel panel = new JPanel(false); | |
JLabel filler = new JLabel(text); | |
filler.setHorizontalAlignment(JLabel.CENTER); | |
panel.setLayout(new GridLayout(1, 1)); | |
panel.add(filler); | |
return panel; | |
} | |
private void showButtonDemo(){ | |
mainFrame.setVisible(true); | |
} | |
} |