Skip to content
Permalink
da734c8b62
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
233 lines (189 sloc) 7.73 KB
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();
JPanel mainTab = new JPanel();
mainTab.setLayout(new BoxLayout(mainTab, BoxLayout.Y_AXIS));
JLabel salary = new JLabel();
//set salary to salary variable here
mainTab.add(salary);
JLabel plusSymbol = new JLabel("+");
plusSymbol.setFont(new Font("Verdana",1,50));
plusSymbol.setAlignmentX(Component.CENTER_ALIGNMENT);
mainTab.add(plusSymbol);
JLabel passiveincome = new JLabel();
//set passiveincome to passiveincome variable here
JLabel passiveMes = new JLabel("Cash Flow from Interest/Dividends and Real Estate/Business");
passiveincome.setFont(new Font("Verdana",1,35));
passiveincome.setAlignmentX(Component.CENTER_ALIGNMENT);
mainTab.add(passiveincome);
passiveMes.setFont(new Font("Verdana",1,10));
passiveMes.setAlignmentX(Component.CENTER_ALIGNMENT);
mainTab.add(passiveMes);
JLabel equalSymbol = new JLabel("=");
equalSymbol.setFont(new Font("Verdana",1,50));
equalSymbol.setAlignmentX(Component.CENTER_ALIGNMENT);
mainTab.add(equalSymbol);
JLabel totalincome = new JLabel();
//set totalincome to totalincome variable here
totalincome.setFont(new Font("Verdana",1,35));
totalincome.setAlignmentX(Component.CENTER_ALIGNMENT);
mainTab.add(totalincome);
JLabel minusSymbol = new JLabel("-");
minusSymbol.setFont(new Font("Verdana",1,50));
minusSymbol.setAlignmentX(Component.CENTER_ALIGNMENT);
mainTab.add(minusSymbol);
JLabel totalexpense = new JLabel();
//set totalexpense to totalexpense variable here
totalincome.setFont(new Font("Verdana",1,35));
totalincome.setAlignmentX(Component.CENTER_ALIGNMENT);
mainTab.add(totalexpense);
JLabel equalSymbol2 = new JLabel("=");
equalSymbol2.setFont(new Font("Verdana",1,50));
equalSymbol2.setAlignmentX(Component.CENTER_ALIGNMENT);
mainTab.add(equalSymbol2);
JLabel cashflow = new JLabel();
//set cashflow to cashflow variable here
totalincome.setFont(new Font("Verdana",1,35));
totalincome.setAlignmentX(Component.CENTER_ALIGNMENT);
mainTab.add(cashflow);
tabbedPane.addTab("Total CashFlow", mainTab);
tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
String[] incomeColumns = {"Description", "CashFlow"};
Object[][] income = {
{"Description", "CashFlow"},
{"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 = {
{"Description", "CashFlow"},
{"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 = {
{"Description", "CashFlow"},
{"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 = {
{"Description", "Down Payment", "Cost"},
{"Name",""/**user variable*/,""},
{"Name", ""/**user variable**/,""},
{"Name",""/**user variable**/, ""/**user variable**/,""}, //total stocks number and total money
};
JTable assetTable2 = new JTable(asset2, assetColumns2 );
Container assetTab = new Container();
assetTab.setLayout(new BoxLayout(assetTab, BoxLayout.Y_AXIS));
assetTab.add(assetTable);
assetTab.add(assetTable2);
tabbedPane.addTab("Assets", assetTab);
tabbedPane.setMnemonicAt(3, KeyEvent.VK_4);
String[] liabiltiesColumns = {"Description", "Liabilities"};
Object[][] liabilties = {
{"Description", "Liabilities"},
{"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 = {
{"Real Estate/Business", "Mortgage/Liability"},
{"Name",""/**user variable*/},
{"Name", ""/**user variable**/},
{"Name",""/**user variable**/, ""/**user variable**/},
{"Name", ""/**user variable**/},
{"Name", ""/**user variable**/},
};
JTable liabiltiesTable2 = new JTable(liabilties2, liabiltiesColumns2 );
Container liabilitiesTab = new Container();
liabilitiesTab.setLayout(new BoxLayout(liabilitiesTab, BoxLayout.Y_AXIS));
liabilitiesTab.add(liabiltiesTable);
liabilitiesTab.add(liabiltiesTable2);
tabbedPane.addTab("Liabilities", liabilitiesTab);
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(49, 32, 216));
mainFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowEvent){
System.exit(0);
}
});
tabbedPane.setPreferredSize(new Dimension(500, 750));
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(49, 32, 216));
mainFrame.setLayout(new FlowLayout());
mainFrame.add(headerLabel);
mainFrame.add(controlPanel);
mainFrame.add(statusLabel);
mainFrame.setVisible(true);
mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
mainFrame.add(splitPane);
//add game window like so
// splitPane.add(gamewindow);
splitPane.add(tabbedPane);
}
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);
}
}