Guest User

Untitled

a guest
Jul 17th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 KB | None | 0 0
  1. package com.hexd;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Color;
  5. import java.awt.Font;
  6. import java.awt.event.ActionEvent;
  7. import java.awt.event.ActionListener;
  8. import java.io.File;
  9. import java.io.FileReader;
  10.  
  11. import javax.swing.BorderFactory;
  12. import javax.swing.JFrame;
  13. import javax.swing.JPanel;
  14. import javax.swing.JScrollPane;
  15. import javax.swing.JTextField;
  16. import javax.swing.JTextPane;
  17. import javax.swing.SwingUtilities;
  18. import javax.swing.border.EtchedBorder;
  19. import javax.swing.border.TitledBorder;
  20. import javax.swing.text.BadLocationException;
  21. import javax.swing.text.StyledDocument;
  22.  
  23.  
  24. public class taxCalc {
  25.  
  26. private static final Color bg = new Color(77, 77, 77);
  27. private static final Color fg = new Color(0, 255, 0);
  28. private static final Color tx = new Color(255, 153, 89);
  29. private static final Font font = new Font("Inconsolata", Font.PLAIN, 16);
  30.  
  31. public taxCalc() {
  32. createView();
  33. }
  34.  
  35. public void createView() {
  36.  
  37. JFrame frame = new JFrame();
  38. frame.setTitle("Tax Calculator");
  39. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  40. frame.setSize(450, 200);
  41. frame.setLocationRelativeTo(null);
  42. frame.setResizable(false);
  43. frame.setVisible(true);
  44.  
  45. JPanel terminal = new JPanel(new BorderLayout());
  46. terminal.setBorder(
  47. BorderFactory.createTitledBorder(
  48. BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
  49. "Output",
  50. TitledBorder.LEFT,
  51. TitledBorder.TOP,
  52. font,
  53. fg));
  54. terminal.setBackground(bg);
  55. frame.getContentPane().add(terminal);
  56.  
  57. JTextPane output = new JTextPane();
  58. output.setContentType("text/html");
  59.  
  60. onStart(output);
  61.  
  62. output.setBackground(bg);
  63. output.setForeground(fg);
  64. output.setFont(font);
  65. terminal.add(output);
  66.  
  67. JScrollPane overflow = new JScrollPane(output);
  68. overflow.setBorder(null);
  69. terminal.add(overflow, BorderLayout.CENTER);
  70.  
  71. StyledDocument document = output.getStyledDocument();
  72.  
  73. JTextField input = new JTextField();
  74. input.setBackground(bg);
  75. input.setForeground(fg);
  76. input.setFont(font);
  77. input.setCaretColor(tx);
  78. input.setBorder(BorderFactory.createLoweredBevelBorder());
  79.  
  80. input.addActionListener(new ActionListener() {
  81. public void actionPerformed(ActionEvent e) {
  82. try {
  83. document.insertString(document.getLength(), "n" + input.getText(), null);
  84. output.setCaretPosition(output.getDocument().getLength());
  85.  
  86. } catch (BadLocationException err) {
  87. err.printStackTrace();
  88. }
  89. input.selectAll();
  90. }
  91. });
  92. frame.getContentPane().add(input, BorderLayout.SOUTH);
  93. }
  94.  
  95. public void tax(double gross, boolean scotch, boolean marital) {
  96.  
  97. double pta;
  98.  
  99. if (marital == true) {
  100. pta = 8.695;
  101. } else {
  102. pta = 11.850;
  103. }
  104.  
  105. pta = (gross - pta);
  106.  
  107. System.out.println(pta);
  108.  
  109. if (gross >= 1.00 && gross <= 34.500) {
  110.  
  111. } else if (gross >= 34.501 && gross <= 150.000) {
  112.  
  113. } else if (gross >= 150.001) {
  114.  
  115. }
  116.  
  117. }
  118.  
  119. public static void onStart(JTextPane output) {
  120.  
  121. try {
  122. String path = "C:\Users\HexD\Documents\Tax Calc\src\com.hexd\welcome.html";
  123. File file = new File(path);
  124. FileReader fr = new FileReader(file);
  125. while(fr.read() != -1) {
  126. output.read(fr, null);
  127. }
  128. fr.close();
  129. } catch (Exception ex) {
  130. ex.printStackTrace();
  131. }
  132. }
  133.  
  134. public static void main(String[] args) {
  135. SwingUtilities.invokeLater(new Runnable() {
  136. @Override
  137. public void run() {
  138. new taxCalc();
  139. }
  140. });
  141. }
  142. }
  143.  
  144. public static void main(String[] args)
  145.  
  146. boolean boolVal(int x) { return x == 1;}
  147.  
  148. public static void main(String[] args) {
  149. if(args.length > 0) {
  150. SwingUtilities.invokeLater(new Runnable() {
  151. @Override
  152. public void run() {
  153. new taxCalc(Integer.parseInt(args[0]) ,
  154. boolVal(Integer.parseInt(args[1])),
  155. boolVal(Integer.parseInt[args[2]])));
  156. }
  157. });
  158. }
  159. }
Add Comment
Please, Sign In to add comment