Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.hexd;
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.File;
- import java.io.FileReader;
- import javax.swing.BorderFactory;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.JScrollPane;
- import javax.swing.JTextField;
- import javax.swing.JTextPane;
- import javax.swing.SwingUtilities;
- import javax.swing.border.EtchedBorder;
- import javax.swing.border.TitledBorder;
- import javax.swing.text.BadLocationException;
- import javax.swing.text.StyledDocument;
- public class taxCalc {
- private static final Color bg = new Color(77, 77, 77);
- private static final Color fg = new Color(0, 255, 0);
- private static final Color tx = new Color(255, 153, 89);
- private static final Font font = new Font("Inconsolata", Font.PLAIN, 16);
- public taxCalc() {
- createView();
- }
- public void createView() {
- JFrame frame = new JFrame();
- frame.setTitle("Tax Calculator");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setSize(450, 200);
- frame.setLocationRelativeTo(null);
- frame.setResizable(false);
- frame.setVisible(true);
- JPanel terminal = new JPanel(new BorderLayout());
- terminal.setBorder(
- BorderFactory.createTitledBorder(
- BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
- "Output",
- TitledBorder.LEFT,
- TitledBorder.TOP,
- font,
- fg));
- terminal.setBackground(bg);
- frame.getContentPane().add(terminal);
- JTextPane output = new JTextPane();
- output.setContentType("text/html");
- onStart(output);
- output.setBackground(bg);
- output.setForeground(fg);
- output.setFont(font);
- terminal.add(output);
- JScrollPane overflow = new JScrollPane(output);
- overflow.setBorder(null);
- terminal.add(overflow, BorderLayout.CENTER);
- StyledDocument document = output.getStyledDocument();
- JTextField input = new JTextField();
- input.setBackground(bg);
- input.setForeground(fg);
- input.setFont(font);
- input.setCaretColor(tx);
- input.setBorder(BorderFactory.createLoweredBevelBorder());
- input.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- try {
- document.insertString(document.getLength(), "n" + input.getText(), null);
- output.setCaretPosition(output.getDocument().getLength());
- } catch (BadLocationException err) {
- err.printStackTrace();
- }
- input.selectAll();
- }
- });
- frame.getContentPane().add(input, BorderLayout.SOUTH);
- }
- public void tax(double gross, boolean scotch, boolean marital) {
- double pta;
- if (marital == true) {
- pta = 8.695;
- } else {
- pta = 11.850;
- }
- pta = (gross - pta);
- System.out.println(pta);
- if (gross >= 1.00 && gross <= 34.500) {
- } else if (gross >= 34.501 && gross <= 150.000) {
- } else if (gross >= 150.001) {
- }
- }
- public static void onStart(JTextPane output) {
- try {
- String path = "C:\Users\HexD\Documents\Tax Calc\src\com.hexd\welcome.html";
- File file = new File(path);
- FileReader fr = new FileReader(file);
- while(fr.read() != -1) {
- output.read(fr, null);
- }
- fr.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void main(String[] args) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- new taxCalc();
- }
- });
- }
- }
- public static void main(String[] args)
- boolean boolVal(int x) { return x == 1;}
- public static void main(String[] args) {
- if(args.length > 0) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- new taxCalc(Integer.parseInt(args[0]) ,
- boolVal(Integer.parseInt(args[1])),
- boolVal(Integer.parseInt[args[2]])));
- }
- });
- }
- }
Add Comment
Please, Sign In to add comment