diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f68d109
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,29 @@
+### IntelliJ IDEA ###
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/src/About.java b/src/About.java
new file mode 100644
index 0000000..5e8de49
--- /dev/null
+++ b/src/About.java
@@ -0,0 +1,81 @@
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.event.*;
+
+/**
+ * @version 1.0, 19.11.2011
+ * @author Simon Vetter
+ */
+
+public class About extends JDialog {
+ private JLabel Text_Title = new JLabel();
+ private JLabel Text_Author_Title = new JLabel();
+ private JLabel Text_DS_Title = new JLabel();
+ private JSeparator Table_vert = new JSeparator();
+ private JSeparator Table_hori = new JSeparator();
+ private JLabel Text_Author = new JLabel();
+ private JLabel Text_DS = new JLabel();
+ private JLabel Text_Copyright = new JLabel();
+
+ private String givenTitle;
+
+ public About(JFrame owner, String title, boolean modal) {
+ super(owner, title, modal);
+ givenTitle = title;
+ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ int frameWidth = 325;
+ int frameHeight = 220;
+ setSize(frameWidth, frameHeight);
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
+ int x = (d.width - getSize().width) / 2;
+ int y = (d.height - getSize().height) / 2;
+ setLocation(x, y);
+ Container cp = getContentPane();
+ cp.setLayout(null);
+
+ Text_Title.setBounds(10, 5, 300, 30);
+ Text_Title.setText(givenTitle);
+ Text_Title.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_Title.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_Title.setFont(new Font("Dialog", Font.BOLD, 20));
+ cp.add(Text_Title);
+ Text_Author_Title.setBounds(10, 45, 150, 30);
+ Text_Author_Title.setText("Author");
+ Text_Author_Title.setFont(new Font("Dialog", Font.BOLD, 18));
+ Text_Author_Title.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_Author_Title.setHorizontalTextPosition(SwingConstants.CENTER);
+ cp.add(Text_Author_Title);
+ Text_DS_Title.setBounds(160, 45, 150, 30);
+ Text_DS_Title.setText("Diction Supervisor");
+ Text_DS_Title.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_DS_Title.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_DS_Title.setFont(new Font("Dialog", Font.BOLD, 15));
+ cp.add(Text_DS_Title);
+ Table_vert.setBounds(160, 45, 1, 100);
+ Table_vert.setOrientation(SwingConstants.VERTICAL);
+ cp.add(Table_vert);
+ Table_hori.setBounds(10, 75, 300, 1);
+ cp.add(Table_hori);
+ Text_Author.setBounds(10, 80, 140, 60);
+ Text_Author.setText("
Simon Vetter
Frankfurt, Germany
");
+ Text_Author.setHorizontalAlignment(SwingConstants.RIGHT);
+ Text_Author.setFont(new Font("Dialog", Font.BOLD, 13));
+ cp.add(Text_Author);
+ Text_DS.setBounds(170, 80, 449, 60);
+ Text_DS.setText("Ben
Cardiff, Wales
");
+ Text_DS.setHorizontalTextPosition(SwingConstants.LEFT);
+ Text_DS.setFont(new Font("Dialog", Font.BOLD, 13));
+ cp.add(Text_DS);
+ Text_Copyright.setBounds(10, 160, 300, 25);
+ Text_Copyright.setText("© Simon Vetter 2011 - All rights reserved");
+ Text_Copyright.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_Copyright.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_Copyright.setFont(new Font("Dialog", Font.BOLD, 13));
+ cp.add(Text_Copyright);
+
+ setResizable(false);
+ setVisible(true);
+ }
+
+}
diff --git a/src/BitrateConverter.java b/src/BitrateConverter.java
new file mode 100644
index 0000000..7f4a3d6
--- /dev/null
+++ b/src/BitrateConverter.java
@@ -0,0 +1,319 @@
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
+/**
+ * @version 1.0, 2.11.2011
+ * @author Simon Vetter
+ */
+
+public class BitrateConverter extends JFrame {
+ private JLabel Text_Title = new JLabel();
+ private JNumberField Rate_given = new JNumberField();
+ private JComboBox Unit_Size_given = new JComboBox();
+ private JRadioButton K_given_1024 = new JRadioButton();
+ private JRadioButton K_given_1000 = new JRadioButton();
+ private ButtonGroup K_given = new ButtonGroup();
+ private JSeparator verticalLine = new JSeparator();
+ private JNumberField Rate_wanted = new JNumberField();
+ private JComboBox Unit_Size_wanted = new JComboBox();
+ private JRadioButton K_wanted_1024 = new JRadioButton();
+ private JRadioButton K_wanted_1000 = new JRadioButton();
+ private ButtonGroup K_wanted = new ButtonGroup();
+ private JComboBox Unit_Time_given = new JComboBox();
+ private JComboBox Unit_Time_wanted = new JComboBox();
+ private JLabel Text_Slash1 = new JLabel();
+ private JLabel Text_Slash2 = new JLabel();
+ private JButton About_Button = new JButton();
+ private JToggleButton Help_Button = new JToggleButton();
+
+ public BitrateConverter(String title) {
+ super(title);
+ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ int frameWidth = 570;
+ int frameHeight = 230;
+ setSize(frameWidth, frameHeight);
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
+ int x = (d.width - getSize().width) / 2 + 508;
+ int y = (d.height - getSize().height) / 2;
+ setLocation(x, y);
+ setResizable(false);
+ Container cp = getContentPane();
+ cp.setLayout(null);
+
+ Text_Title.setBounds(90, 0, 380, 55);
+ Text_Title.setText("Bitrate Converter");
+ Text_Title.setToolTipText("v1.0 © Simon Vetter 2011");
+ Text_Title.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_Title.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_Title.setFont(new Font("Dialog", Font.BOLD, 30));
+ Text_Title.setEnabled(true);
+ cp.add(Text_Title);
+ Rate_given.setBounds(20, 65, 300, 35);
+ Rate_given.setText("");
+ Rate_given.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Rate_given.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent evt) {
+ Rate_given_KeyReleased(evt);
+ }
+ });
+ cp.add(Rate_given);
+ Unit_Size_given.setBounds(330, 65, 60, 35);
+ Unit_Size_given.setModel(new DefaultComboBoxModel(new String[] {"b", "Kb", "Mb", "Gb", "B", "KB", "MB", "GB"}));
+ Unit_Size_given.setSelectedIndex(1);
+ Unit_Size_given.setMaximumRowCount(8);
+ Unit_Size_given.setFont(new Font("Dialog", Font.PLAIN, 16));
+ Unit_Size_given.setEditable(false);
+ Unit_Size_given.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Unit_Size_given_ActionPerformed(evt);
+ }
+ });
+ cp.add(Unit_Size_given);
+ K_given_1024.setBounds(470, 62, 80, 20);
+ K_given_1024.setText("K = 1024");
+ K_given_1024.setSelected(true);
+ K_given_1024.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ K_given_1024_ActionPerformed(evt);
+ }
+ });
+ cp.add(K_given_1024);
+ K_given_1000.setBounds(470, 83, 80, 20);
+ K_given_1000.setText("K = 1000");
+ K_given_1000.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ K_given_1000_ActionPerformed(evt);
+ }
+ });
+ cp.add(K_given_1000);
+ K_given.add(K_given_1024);
+ K_given.add(K_given_1000);
+ verticalLine.setBounds(20, 125, 520, 1);
+ cp.add(verticalLine);
+ Rate_wanted.setBounds(20, 150, 300, 35);
+ Rate_wanted.setText("0");
+ Rate_wanted.setEditable(false);
+ Rate_wanted.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Rate_wanted.setSelectionEnd(0);
+ Rate_wanted.setSelectionStart(0);
+ cp.add(Rate_wanted);
+ Unit_Size_wanted.setBounds(330, 150, 60, 35);
+ Unit_Size_wanted.setEditable(false);
+ Unit_Size_wanted.setFont(new Font("Dialog", Font.PLAIN, 16));
+ Unit_Size_wanted.setMaximumRowCount(8);
+ Unit_Size_wanted.setModel(new DefaultComboBoxModel(new String[] {"b", "Kb", "Mb", "Gb", "B", "KB", "MB", "GB"}));
+ Unit_Size_wanted.setSelectedIndex(1);
+ Unit_Size_wanted.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Unit_Size_wanted_ActionPerformed(evt);
+ }
+ });
+ cp.add(Unit_Size_wanted);
+ K_wanted_1024.setBounds(470, 147, 80, 20);
+ K_wanted_1024.setText("K = 1024");
+ K_wanted_1024.setSelected(true);
+ K_wanted_1024.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ K_wanted_1024_ActionPerformed(evt);
+ }
+ });
+ cp.add(K_wanted_1024);
+ K_wanted_1000.setBounds(470, 168, 80, 20);
+ K_wanted_1000.setText("K = 1000");
+ K_wanted_1000.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ K_wanted_1000_ActionPerformed(evt);
+ }
+ });
+ cp.add(K_wanted_1000);
+ K_wanted.add(K_wanted_1024);
+ K_wanted.add(K_wanted_1000);
+ Unit_Time_given.setBounds(410, 65, 50, 35);
+ Unit_Time_given.setModel(new DefaultComboBoxModel(new String[] {"s", "min", "h", "d"}));
+ Unit_Time_given.setSelectedIndex(0);
+ Unit_Time_given.setEditable(false);
+ Unit_Time_given.setFont(new Font("Dialog", Font.PLAIN, 16));
+ Unit_Time_given.setMaximumRowCount(4);
+ Unit_Time_given.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Unit_Time_given_ActionPerformed(evt);
+ }
+ });
+ cp.add(Unit_Time_given);
+ Unit_Time_wanted.setBounds(410, 150, 50, 35);
+ Unit_Time_wanted.setModel(new DefaultComboBoxModel(new String[] {"s", "min", "h", "d"}));
+ Unit_Time_wanted.setEditable(false);
+ Unit_Time_wanted.setFont(new Font("Dialog", Font.PLAIN, 16));
+ Unit_Time_wanted.setMaximumRowCount(4);
+ Unit_Time_wanted.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Unit_Time_wanted_ActionPerformed(evt);
+ }
+ });
+ cp.add(Unit_Time_wanted);
+ Text_Slash1.setBounds(390, 58, 20, 50);
+ Text_Slash1.setText("/");
+ Text_Slash1.setFont(new Font("Dialog", Font.PLAIN, 40));
+ Text_Slash1.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_Slash1.setHorizontalTextPosition(SwingConstants.CENTER);
+ cp.add(Text_Slash1);
+ Text_Slash2.setBounds(390, 143, 20, 50);
+ Text_Slash2.setText("/");
+ Text_Slash2.setFont(new Font("Dialog", Font.PLAIN, 40));
+ Text_Slash2.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_Slash2.setHorizontalTextPosition(SwingConstants.CENTER);
+ cp.add(Text_Slash2);
+ About_Button.setBounds(20, 15, 70, 30);
+ About_Button.setText("About");
+ About_Button.setMargin(new Insets(2, 2, 2, 2));
+ About_Button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ About_Button_ActionPerformed(evt);
+ }
+ });
+ About_Button.setHorizontalTextPosition(SwingConstants.CENTER);
+ cp.add(About_Button);
+ Help_Button.setBounds(470, 15, 70, 30);
+ Help_Button.setText("Help");
+ Help_Button.setMargin(new Insets(2, 2, 2, 2));
+ Help_Button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Help_Button_ActionPerformed(evt);
+ }
+ });
+ Help_Button.setToolTipText("switches tooltips on/off");
+ cp.add(Help_Button);
+
+ setVisible(true);
+ }
+
+ private String getSelectedRadioButton(ButtonGroup bg) {
+ for (java.util.Enumeration e = bg.getElements(); e.hasMoreElements();) {
+ AbstractButton b = e.nextElement();
+ if (b.isSelected()) return b.getText();
+ }
+ return null;
+ }
+
+ public void Rate_given_KeyReleased(KeyEvent evt) {
+ if (!Rate_given.getText().equals(Rate_given.getText().replace(',', '.'))) {
+ Rate_given.setText(Rate_given.getText().replace(',', '.'));
+ }
+ try {
+ if (Rate_given.getDouble() < 0.) {
+ Rate_given.setText(Rate_given.getText().substring(Rate_given.getText().indexOf('-') + 1));
+ }
+ } catch (NumberFormatException e) { }
+ calculate();
+ }
+ private void Unit_Size_given_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ private void Unit_Time_given_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ private void Unit_Size_wanted_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ private void Unit_Time_wanted_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ private void K_given_1024_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ private void K_given_1000_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ private void K_wanted_1024_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ private void K_wanted_1000_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+
+
+ private void calculate() {
+ double check;
+ try {
+ check = Rate_given.getDouble();
+ } catch (java.lang.NumberFormatException e) {
+ Rate_wanted.setText("0");
+ return;
+ }
+ if (!(check > 0.)) {
+ Rate_wanted.setText("0");
+ return;
+ }
+
+ BigDecimal value = new BigDecimal(0);
+ value = value.valueOf(Rate_given.getDouble());
+
+ long[] SizeToBits = new long[10], SizeToUnit = new long[10];
+ if (getSelectedRadioButton(K_given).equals("K = 1000")) {
+ long[] temp = {1L, 1000L, 1000000L, 1000000000L, 8L, 8000L, 8000000L, 8000000000L};
+ SizeToBits = temp;
+ }
+ else {
+ long[] temp = {1L, 1024L, 1048576L, 1073741824L, 8L, 8192L, 8388608L, 8589934592L};
+ SizeToBits = temp;
+ }
+ if (getSelectedRadioButton(K_wanted).equals("K = 1000")) {
+ long[] temp = {1L, 1000L, 1000000L, 1000000000L, 8L, 8000L, 8000000L, 8000000000L};
+ SizeToUnit = temp;
+ }
+ else {
+ long[] temp = {1L, 1024L, 1048576L, 1073741824L, 8L, 8192L, 8388608L, 8589934592L};
+ SizeToUnit = temp;
+ }
+ int[] TimeConversion = {1, 60, 3600, 86400};
+
+ value = value.multiply(BigDecimal.valueOf(SizeToBits[Unit_Size_given.getSelectedIndex()] * (long) TimeConversion[Unit_Time_wanted.getSelectedIndex()]));
+ value = value.divide(BigDecimal.valueOf(SizeToUnit[Unit_Size_wanted.getSelectedIndex()] * (long) TimeConversion[Unit_Time_given.getSelectedIndex()]), 4, BigDecimal.ROUND_HALF_UP);
+
+ Rate_wanted.setText(value.toString());
+ }
+
+ public void About_Button_ActionPerformed(ActionEvent evt) {
+ new About(this, "About Bitrate Converter", true);
+ }
+
+ public void Help_Button_ActionPerformed(ActionEvent evt) {
+ if (Help_Button.isSelected()) {
+ Rate_given.setToolTipText("enter the bitrate you want to convert here");
+ Unit_Size_given.setToolTipText("select the unit for the given bitrate");
+ Unit_Time_given.setToolTipText("select the unit for the given bitrate");
+ K_given_1024.setToolTipText("1 MB = 1024 B");
+ K_given_1000.setToolTipText("1 MB = 1000 B");
+ verticalLine.setToolTipText("found me!");
+ Rate_wanted.setToolTipText("that's your result!");
+ Unit_Size_wanted.setToolTipText("select the unit for your result");
+ Unit_Time_wanted.setToolTipText("select the unit for your result");
+ K_wanted_1024.setToolTipText("1 MB = 1024 B");
+ K_wanted_1000.setToolTipText("1 MB = 1000 B");
+ }
+ else {
+ Rate_given.setToolTipText(null);
+ Unit_Size_given.setToolTipText(null);
+ Unit_Time_given.setToolTipText(null);
+ K_given_1024.setToolTipText(null);
+ K_given_1000.setToolTipText(null);
+ verticalLine.setToolTipText(null);
+ Rate_wanted.setToolTipText(null);
+ Unit_Size_wanted.setToolTipText(null);
+ Unit_Time_wanted.setToolTipText(null);
+ K_wanted_1024.setToolTipText(null);
+ K_wanted_1000.setToolTipText(null);
+ }
+
+
+ }
+
+
+ public static void main(String[] args) {
+ new BitrateConverter("Bitrate Converter");
+ }
+}
\ No newline at end of file
diff --git a/src/BitrateGenerator.java b/src/BitrateGenerator.java
new file mode 100644
index 0000000..13dd6da
--- /dev/null
+++ b/src/BitrateGenerator.java
@@ -0,0 +1,696 @@
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
+/**
+ * @version 1.0.1, 24.11.2011
+ * @author Simon Vetter
+ */
+
+public class BitrateGenerator extends JFrame {
+ private JLabel Text_Title = new JLabel();
+ private JSeparator Seperator_h_top = new JSeparator();
+ private JSeparator Seperator_h_uppermid = new JSeparator();
+ private JSeparator Seperator_h_lowermid = new JSeparator();
+ private JSeparator Seperator_h_bottom = new JSeparator();
+ private JSeparator Seperator_v_left = new JSeparator();
+ private JSeparator Seperator_v_mid = new JSeparator();
+ private JSeparator Seperator_v_right = new JSeparator();
+ private JLabel Text_Filesize = new JLabel();
+ private JRadioButton calculate_Filesize = new JRadioButton();
+ private JNumberField Filesize_Figure = new JNumberField();
+ private JComboBox Filesize_Format = new JComboBox();
+ private JRadioButton Filesize_K1024 = new JRadioButton();
+ private JRadioButton Filesize_K1000 = new JRadioButton();
+ private ButtonGroup Filesize_K_Group = new ButtonGroup();
+ private JCheckBox Bitrate_includeAudio = new JCheckBox();
+ private JComboBox Bitrate_Audio_Figure = new JComboBox();
+ private JLabel Text_Bitrate_Audio_Format = new JLabel();
+ private JLabel Text_Length = new JLabel();
+ private JRadioButton calculate_Length = new JRadioButton();
+ private JNumberField Length_hours = new JNumberField();
+ private JLabel Text_Length_h = new JLabel();
+ private JNumberField Length_minutes = new JNumberField();
+ private JLabel Text_Length_min = new JLabel();
+ private JNumberField Length_seconds = new JNumberField();
+ private JLabel Text_Length_s = new JLabel();
+ private JLabel Text_Bitrate = new JLabel();
+ private JRadioButton calculate_Bitrate = new JRadioButton();
+ private JNumberField Bitrate_Figure = new JNumberField();
+ private JComboBox Bitrate_Format_Size = new JComboBox();
+ private JLabel Text_Bitrate_Slash = new JLabel();
+ private JComboBox Bitrate_Format_Length = new JComboBox();
+ private JRadioButton Bitrate_K1024 = new JRadioButton();
+ private JRadioButton Bitrate_K1000 = new JRadioButton();
+ private ButtonGroup Bitrate_K_Group = new ButtonGroup();
+ private ButtonGroup calculate_Group = new ButtonGroup();
+ private JButton About_Button = new JButton();
+ private JToggleButton Help_Button = new JToggleButton();
+
+ public BitrateGenerator(String title) {
+ super(title);
+ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ int frameWidth = 547;
+ int frameHeight = 332;
+ setSize(frameWidth, frameHeight);
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
+ int x = (d.width - getSize().width) / 2;
+ int y = (d.height - getSize().height) / 2 - 329;
+ setLocation(x, y);
+ setResizable(false);
+ Container cp = getContentPane();
+ cp.setLayout(null);
+
+ Text_Title.setBounds(90, 0, 360, 55);
+ Text_Title.setText("Bitrate Generator");
+ Text_Title.setFont(new Font("Dialog", Font.BOLD, 30));
+ Text_Title.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_Title.setToolTipText("v1.0.1 © Simon Vetter 2011");
+ cp.add(Text_Title);
+ Seperator_h_top.setBounds(10, 65, 521, 1);
+ cp.add(Seperator_h_top);
+ Seperator_h_uppermid.setBounds(12, 130, 517, 1);
+ cp.add(Seperator_h_uppermid);
+ Seperator_h_lowermid.setBounds(12, 195, 517, 1);
+ cp.add(Seperator_h_lowermid);
+ Seperator_h_bottom.setBounds(12, 295, 519, 1);
+ cp.add(Seperator_h_bottom);
+ Seperator_v_left.setBounds(10, 65, 1, 231);
+ Seperator_v_left.setOrientation(SwingConstants.VERTICAL);
+ cp.add(Seperator_v_left);
+ Seperator_v_mid.setBounds(130, 67, 1, 227);
+ Seperator_v_mid.setOrientation(SwingConstants.VERTICAL);
+ cp.add(Seperator_v_mid);
+ Seperator_v_right.setBounds(530, 67, 1, 229);
+ Seperator_v_right.setOrientation(SwingConstants.VERTICAL);
+ cp.add(Seperator_v_right);
+ Text_Filesize.setBounds(15, 70, 110, 35);
+ Text_Filesize.setText("Filesize");
+ Text_Filesize.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_Filesize.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_Filesize.setFont(new Font("Dialog", Font.BOLD, 25));
+ cp.add(Text_Filesize);
+ calculate_Filesize.setBounds(20, 105, 105, 20);
+ calculate_Filesize.setText("calculate this");
+ calculate_Filesize.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ calculate_Filesize_ActionPerformed(evt);
+ }
+ });
+ cp.add(calculate_Filesize);
+ Filesize_Figure.setBounds(145, 80, 220, 35);
+ Filesize_Figure.setText("");
+ Filesize_Figure.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Filesize_Figure.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent evt) {
+ Filesize_Figure_KeyReleased(evt);
+ }
+ });
+ cp.add(Filesize_Figure);
+ Filesize_Format.setBounds(375, 80, 60, 35);
+ Filesize_Format.setModel(new DefaultComboBoxModel(new String[] {"B", "KB", "MB", "GB", "TB", "PB", "b", "Kb", "Mb", "Gb"}));
+ Filesize_Format.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Filesize_Format.setSelectedIndex(2);
+ Filesize_Format.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Filesize_Format_ActionPerformed(evt);
+ }
+ });
+ Filesize_Format.setMaximumRowCount(10);
+ cp.add(Filesize_Format);
+ Filesize_K1024.setBounds(445, 77, 80, 20);
+ Filesize_K1024.setText("K = 1024");
+ Filesize_K1024.setSelected(true);
+ Filesize_K1024.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Filesize_K1024_ActionPerformed(evt);
+ }
+ });
+ cp.add(Filesize_K1024);
+ Filesize_K1000.setBounds(445, 98, 80, 20);
+ Filesize_K1000.setText("K = 1000");
+ Filesize_K1000.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Filesize_K1000_ActionPerformed(evt);
+ }
+ });
+ cp.add(Filesize_K1000);
+ Filesize_K_Group.add(Filesize_K1024);
+ Filesize_K_Group.add(Filesize_K1000);
+ Bitrate_includeAudio.setBounds(145, 255, 150, 30);
+ Bitrate_includeAudio.setText(" Audio stream:");
+ Bitrate_includeAudio.setFont(new Font("Dialog", Font.PLAIN, 16));
+ Bitrate_includeAudio.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Bitrate_includeAudio_ActionPerformed(evt);
+ }
+ });
+ cp.add(Bitrate_includeAudio);
+ Bitrate_Audio_Figure.setBounds(300, 255, 60, 30);
+ Bitrate_Audio_Figure.setEditable(false);
+ Bitrate_Audio_Figure.setModel(new DefaultComboBoxModel(new String[] {"20", "24", "32", "48", "56", "64", "80", "96", "112", "128", "160", "192", "224", "256", "320", "350", "384"}));
+ Bitrate_Audio_Figure.setSelectedIndex(13);
+ Bitrate_Audio_Figure.setEnabled(false);
+ Bitrate_Audio_Figure.setFont(new Font("Dialog", Font.PLAIN, 16));
+ Bitrate_Audio_Figure.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Bitrate_Audio_Figure_ActionPerformed(evt);
+ }
+ });
+ cp.add(Bitrate_Audio_Figure);
+ Text_Bitrate_Audio_Format.setBounds(370, 255, 50, 30);
+ Text_Bitrate_Audio_Format.setText("Kbit/s");
+ Text_Bitrate_Audio_Format.setEnabled(false);
+ Text_Bitrate_Audio_Format.setFont(new Font("Dialog", Font.PLAIN, 18));
+ cp.add(Text_Bitrate_Audio_Format);
+ Text_Length.setBounds(15, 135, 110, 35);
+ Text_Length.setText("Length");
+ Text_Length.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_Length.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_Length.setFont(new Font("Dialog", Font.BOLD, 25));
+ cp.add(Text_Length);
+ calculate_Length.setBounds(20, 170, 105, 20);
+ calculate_Length.setText("calculate this");
+ calculate_Length.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ calculate_Length_ActionPerformed(evt);
+ }
+ });
+ cp.add(calculate_Length);
+ Length_hours.setBounds(145, 145, 80, 35);
+ Length_hours.setText("");
+ Length_hours.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Length_hours.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent evt) {
+ Length_hours_KeyReleased(evt);
+ }
+ });
+ cp.add(Length_hours);
+ Text_Length_h.setBounds(230, 145, 20, 35);
+ Text_Length_h.setText("h");
+ Text_Length_h.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Text_Length_h.setHorizontalTextPosition(SwingConstants.CENTER);
+ cp.add(Text_Length_h);
+ Length_minutes.setBounds(255, 145, 80, 35);
+ Length_minutes.setText("");
+ Length_minutes.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Length_minutes.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent evt) {
+ Length_minutes_KeyReleased(evt);
+ }
+ });
+ cp.add(Length_minutes);
+ Text_Length_min.setBounds(340, 145, 35, 35);
+ Text_Length_min.setText("min");
+ Text_Length_min.setFont(new Font("Dialog", Font.PLAIN, 18));
+ cp.add(Text_Length_min);
+ Length_seconds.setBounds(380, 145, 80, 35);
+ Length_seconds.setText("");
+ Length_seconds.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Length_seconds.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent evt) {
+ Length_seconds_KeyReleased(evt);
+ }
+ });
+ cp.add(Length_seconds);
+ Text_Length_s.setBounds(465, 145, 20, 35);
+ Text_Length_s.setText("s");
+ Text_Length_s.setFont(new Font("Dialog", Font.PLAIN, 18));
+ cp.add(Text_Length_s);
+ Text_Bitrate.setBounds(15, 210, 110, 35);
+ Text_Bitrate.setText("Bitrate");
+ Text_Bitrate.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_Bitrate.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_Bitrate.setFont(new Font("Dialog", Font.BOLD, 25));
+ cp.add(Text_Bitrate);
+ calculate_Bitrate.setBounds(20, 245, 105, 20);
+ calculate_Bitrate.setText("calculate this");
+ calculate_Bitrate.setSelected(true);
+ calculate_Bitrate.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ calculate_Bitrate_ActionPerformed(evt);
+ }
+ });
+ cp.add(calculate_Bitrate);
+ Bitrate_Figure.setBounds(145, 210, 145, 35);
+ Bitrate_Figure.setText("");
+ Bitrate_Figure.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Bitrate_Figure.setEnabled(true);
+ Bitrate_Figure.setEditable(false);
+ Bitrate_Figure.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent evt) {
+ Bitrate_Figure_KeyReleased(evt);
+ }
+ });
+ cp.add(Bitrate_Figure);
+ Bitrate_Format_Size.setBounds(300, 210, 60, 35);
+ Bitrate_Format_Size.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Bitrate_Format_Size.setModel(new DefaultComboBoxModel(new String[] {"b", "Kb", "Mb", "Gb", "B", "KB", "MB", "GB"}));
+ Bitrate_Format_Size.setSelectedIndex(1);
+ Bitrate_Format_Size.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Bitrate_Format_Size_ActionPerformed(evt);
+ }
+ });
+ cp.add(Bitrate_Format_Size);
+ Text_Bitrate_Slash.setBounds(360, 203, 20, 50);
+ Text_Bitrate_Slash.setText("/");
+ Text_Bitrate_Slash.setFont(new Font("Dialog", Font.PLAIN, 40));
+ Text_Bitrate_Slash.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_Bitrate_Slash.setHorizontalTextPosition(SwingConstants.CENTER);
+ cp.add(Text_Bitrate_Slash);
+ Bitrate_Format_Length.setBounds(380, 210, 55, 35);
+ Bitrate_Format_Length.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Bitrate_Format_Length.setModel(new DefaultComboBoxModel(new String[] {"s", "min", "h", "d"}));
+ Bitrate_Format_Length.setMaximumRowCount(4);
+ Bitrate_Format_Length.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Bitrate_Format_Length_ActionPerformed(evt);
+ }
+ });
+ cp.add(Bitrate_Format_Length);
+ Bitrate_K1024.setBounds(445, 207, 80, 20);
+ Bitrate_K1024.setText("K = 1024");
+ Bitrate_K1024.setSelected(true);
+ Bitrate_K1024.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Bitrate_K1024_ActionPerformed(evt);
+ }
+ });
+ cp.add(Bitrate_K1024);
+ Bitrate_K1000.setBounds(445, 229, 80, 20);
+ Bitrate_K1000.setText("K = 1000");
+ Bitrate_K1000.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Bitrate_K1000_ActionPerformed(evt);
+ }
+ });
+ cp.add(Bitrate_K1000);
+ Bitrate_K_Group.add(Bitrate_K1024);
+ Bitrate_K_Group.add(Bitrate_K1000);
+ calculate_Group.add(calculate_Filesize);
+ calculate_Group.add(calculate_Length);
+ calculate_Group.add(calculate_Bitrate);
+ About_Button.setBounds(20, 15, 70, 30);
+ About_Button.setText("About");
+ About_Button.setMargin(new Insets(2, 2, 2, 2));
+ About_Button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ About_Button_ActionPerformed(evt);
+ }
+ });
+ cp.add(About_Button);
+ Help_Button.setBounds(450, 15, 70, 30);
+ Help_Button.setText("Help");
+ Help_Button.setMargin(new Insets(2, 2, 2, 2));
+ Help_Button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Help_Button_ActionPerformed(evt);
+ }
+ });
+ Help_Button.setToolTipText("switches tooltips on/off");
+ cp.add(Help_Button);
+
+ setVisible(true);
+ }
+
+
+
+
+
+
+ private void calculate() {
+ if (calculate_Filesize.isSelected()) {
+ calculateFilesize();
+ return;
+ }
+ else if (calculate_Length.isSelected()) {
+ calculateLength();
+ return;
+ }
+ else if (calculate_Bitrate.isSelected()) {
+ calculateBitrate();
+ return;
+ }
+ calculateBitrate();
+ }
+
+ private void calculateFilesize() {
+ BigDecimal seconds = getLength();
+ BigDecimal bitsPerSecond = getBitrate();
+ BigDecimal result = bitsPerSecond.multiply(seconds);
+ printFilesize(result);
+ }
+ private void calculateLength() {
+ BigDecimal bits = getFilesize();
+ BigDecimal bitsPerSecond = getBitrate();
+ BigDecimal result;
+ try {
+ result = bits.divide(bitsPerSecond, 2, BigDecimal.ROUND_HALF_UP);
+ } catch (Exception e) {
+ result = new BigDecimal(0);
+ }
+ printLength(result);
+ }
+ private void calculateBitrate() {
+ BigDecimal bits = getFilesize();
+ BigDecimal seconds = getLength();
+ BigDecimal result;
+ try {
+ result = bits.divide(seconds, 0, BigDecimal.ROUND_HALF_UP);
+ } catch (Exception e) {
+ result = new BigDecimal(0);
+ }
+ printBitrate(result);
+ }
+
+ private BigDecimal getFilesize() {
+ BigDecimal bits;
+ try {
+ bits = BigDecimal.valueOf(Filesize_Figure.getDouble());
+ } catch (NumberFormatException e) {
+ bits = new BigDecimal(0);
+ }
+ long[] toBits;
+ if (Filesize_K1000.isSelected()) {
+ long[] temp = {8L, 8000L, 8000000L, 8000000000L, 8000000000000L, 8000000000000000L, 1L, 1000L, 1000000L, 1000000000L};
+ toBits = temp;
+ }
+ else {
+ long[] temp = {8L, 8192L, 8388608L, 8589934592L, 8796093022208L, 9007199254740992L, 1L, 1024L, 1048576L, 1073741824L};
+ toBits = temp;
+ }
+ bits = bits.multiply(BigDecimal.valueOf(toBits[Filesize_Format.getSelectedIndex()]));
+ return bits;
+ }
+ private BigDecimal getLength() {
+ BigDecimal seconds, minutes, hours;
+ try {
+ seconds = BigDecimal.valueOf(Length_seconds.getDouble());
+ } catch (NumberFormatException e) {
+ seconds = new BigDecimal(0);
+ }
+ try {
+ minutes = BigDecimal.valueOf(Length_minutes.getDouble());
+ } catch (NumberFormatException e) {
+ minutes = new BigDecimal(0);
+ }
+ try {
+ hours = BigDecimal.valueOf(Length_hours.getDouble());
+ } catch (NumberFormatException e) {
+ hours = new BigDecimal(0);
+ }
+ seconds = seconds.add(minutes.multiply(new BigDecimal(60)));
+ seconds = seconds.add(hours.multiply(new BigDecimal(3600)));
+ return seconds;
+ }
+ private BigDecimal getBitrate() {
+ BigDecimal bitsPerSecond;
+ try {
+ bitsPerSecond = new BigDecimal(Bitrate_Figure.getDouble());
+ } catch (NumberFormatException e) {
+ bitsPerSecond = new BigDecimal(0);
+ }
+ long[] toBPS;
+ if (Bitrate_K1000.isSelected()) {
+ long[] temp = {1L, 1000L, 1000000L, 1000000000L, 8L, 8000L, 8000000L, 8000000000L};
+ toBPS = temp;
+ }
+ else {
+ long[] temp = {1L, 1024L, 1048576L, 1073741824L, 8L, 8192L, 8388608L, 8589934592L};
+ toBPS = temp;
+ }
+ int[] TimeConversion = {1, 60, 3600, 86400};
+ bitsPerSecond = bitsPerSecond.multiply(BigDecimal.valueOf(toBPS[Bitrate_Format_Size.getSelectedIndex()]));
+ bitsPerSecond = bitsPerSecond.divide(BigDecimal.valueOf(TimeConversion[Bitrate_Format_Length.getSelectedIndex()]), 0, BigDecimal.ROUND_HALF_UP);
+ if (Bitrate_includeAudio.isSelected()) {
+ bitsPerSecond = bitsPerSecond.add(getAudioBitrate());
+ }
+ return bitsPerSecond;
+ }
+ private BigDecimal getAudioBitrate() {
+ long[] AudioRate;
+ if (Bitrate_K1000.isSelected()) {
+ long[] temp = {20000L, 24000L, 32000L, 48000L, 56000L, 64000L, 80000L, 96000L, 112000L, 128000L, 160000L, 192000L, 224000L, 256000L, 320000L, 350000L, 384000L};
+ AudioRate = temp;
+ }
+ else {
+ long[] temp = {20480L, 24576L, 32768L, 49152L, 57344L, 65536L, 81920L, 98304L, 114688L, 131072L, 163840L, 196608L, 229376L, 262144L, 327680L, 358400L, 393216L};
+ AudioRate = temp;
+ }
+ return BigDecimal.valueOf(AudioRate[Bitrate_Audio_Figure.getSelectedIndex()]);
+ }
+
+ private void printFilesize(BigDecimal bits) {
+ long[] toUnit;
+ if (Filesize_K1000.isSelected()) {
+ long[] temp = {8L, 8000L, 8000000L, 8000000000L, 8000000000000L, 8000000000000000L, 1L, 1000L, 1000000L, 1000000000L};
+ toUnit = temp;
+ }
+ else {
+ long[] temp = {8L, 8192L, 8388608L, 8589934592L, 8796093022208L, 9007199254740992L, 1L, 1024L, 1048576L, 1073741824L};
+ toUnit = temp;
+ }
+ BigDecimal result = bits.divide(new BigDecimal(toUnit[Filesize_Format.getSelectedIndex()]), 4, BigDecimal.ROUND_HALF_UP);
+ Filesize_Figure.setText(result.toString());
+ }
+ private void printLength(BigDecimal seconds) {
+ BigDecimal minutes = new BigDecimal(0), hours = new BigDecimal(0);
+ while (seconds.doubleValue() >= 60) {
+ seconds = seconds.subtract(new BigDecimal(60));
+ minutes = minutes.add(new BigDecimal(1));
+ }
+ while (minutes.doubleValue() >= 60) {
+ minutes = minutes.subtract(new BigDecimal(60));
+ hours = hours.add(new BigDecimal(1));
+ }
+ Length_hours.setText(hours.toString());
+ Length_minutes.setText(minutes.toString());
+ Length_seconds.setText(seconds.toString());
+ }
+ private void printBitrate(BigDecimal bitsPerSecond) {
+ BigDecimal result = bitsPerSecond;
+ if (Bitrate_includeAudio.isSelected()) {
+ result = result.subtract(getAudioBitrate());
+ }
+ long[] toUnit;
+ if (Bitrate_K1000.isSelected()) {
+ long[] temp = {1L, 1000L, 1000000L, 1000000000L, 8L, 8000L, 8000000L, 8000000000L};
+ toUnit = temp;
+ }
+ else {
+ long[] temp = {1L, 1024L, 1048576L, 1073741824L, 8L, 8192L, 8388608L, 8589934592L};
+ toUnit = temp;
+ }
+ int[] TimeConversion = {1, 60, 3600, 86400};
+ result = result.multiply(BigDecimal.valueOf(TimeConversion[Bitrate_Format_Length.getSelectedIndex()]));
+ result = result.divide(BigDecimal.valueOf(toUnit[Bitrate_Format_Size.getSelectedIndex()]), 2, BigDecimal.ROUND_HALF_UP);
+ Bitrate_Figure.setText(result.toString());
+ }
+
+
+ private String getSelectedRadioButton(ButtonGroup bg) {
+ for (java.util.Enumeration e = bg.getElements(); e.hasMoreElements();) {
+ AbstractButton b = e.nextElement();
+ if (b.isSelected()) return b.getText();
+ }
+ return null;
+ }
+
+ private void About_Button_ActionPerformed(ActionEvent evt) {
+ new About(this, "About Bitrate Generator", true);
+ }
+
+ private void Help_Button_ActionPerformed(ActionEvent evt) {
+ if (Help_Button.isSelected()) {
+ Seperator_h_top.setToolTipText("found me!");
+ Seperator_h_uppermid.setToolTipText("found me!");
+ Seperator_h_lowermid.setToolTipText("found me!");
+ Seperator_h_bottom.setToolTipText("found me!");
+ Seperator_v_left.setToolTipText("found me!");
+ Seperator_v_mid.setToolTipText("found me!");
+ Seperator_v_right.setToolTipText("found me!");
+
+ Text_Filesize.setToolTipText("the size of your video file");
+ calculate_Filesize.setToolTipText("use the given length and bitrate to calculate the resulting filesize");
+ Filesize_Figure.setToolTipText("enter the given filesize here");
+ Filesize_Format.setToolTipText("select the format for the filesize");
+ Filesize_K1024.setToolTipText("1 MB = 1024 B");
+ Filesize_K1000.setToolTipText("1 MB = 1000 B");
+
+ Text_Length.setToolTipText("the length of your video");
+ calculate_Length.setToolTipText("use the given filesize and bitrate to calculate the resulting video length");
+ Length_hours.setToolTipText("enter the given video length here");
+ Text_Length_h.setToolTipText("hours");
+ Length_minutes.setToolTipText("enter the given video length here");
+ Text_Length_min.setToolTipText("minutes");
+ Length_seconds.setToolTipText("enter the given video length here");
+ Text_Length_s.setToolTipText("seconds");
+
+ Text_Bitrate.setToolTipText("the bitrate of your video stream");
+ calculate_Bitrate.setToolTipText("use the given filesize and video length to calculate the resulting bitrate");
+ Bitrate_Figure.setToolTipText("enter the given video stream bitrate here");
+ Bitrate_Format_Size.setToolTipText("select a format for the video stream bitrate");
+ Bitrate_Format_Length.setToolTipText("select a format for the video stream bitrate");
+ Bitrate_K1024.setToolTipText("1 MB = 1024 B");
+ Bitrate_K1000.setToolTipText("1 MB = 1000 B");
+ Bitrate_includeAudio.setToolTipText("factor in an audio stream with the given bitrate on the right");
+ Bitrate_Audio_Figure.setToolTipText("enter the bitrate of the audio stream here");
+ }
+ else {
+ Seperator_h_top.setToolTipText(null);
+ Seperator_h_uppermid.setToolTipText(null);
+ Seperator_h_lowermid.setToolTipText(null);
+ Seperator_h_bottom.setToolTipText(null);
+ Seperator_v_left.setToolTipText(null);
+ Seperator_v_mid.setToolTipText(null);
+ Seperator_v_right.setToolTipText(null);
+ Text_Filesize.setToolTipText(null);
+ calculate_Filesize.setToolTipText(null);
+ Filesize_Figure.setToolTipText(null);
+ Filesize_Format.setToolTipText(null);
+ Filesize_K1024.setToolTipText(null);
+ Filesize_K1000.setToolTipText(null);
+ Text_Length.setToolTipText(null);
+ calculate_Length.setToolTipText(null);
+ Length_hours.setToolTipText(null);
+ Text_Length_h.setToolTipText(null);
+ Length_minutes.setToolTipText(null);
+ Text_Length_min.setToolTipText(null);
+ Length_seconds.setToolTipText(null);
+ Text_Length_s.setToolTipText(null);
+ Text_Bitrate.setToolTipText(null);
+ calculate_Bitrate.setToolTipText(null);
+ Bitrate_Figure.setToolTipText(null);
+ Bitrate_Format_Size.setToolTipText(null);
+ Bitrate_Format_Length.setToolTipText(null);
+ Bitrate_K1024.setToolTipText(null);
+ Bitrate_K1000.setToolTipText(null);
+ Bitrate_includeAudio.setToolTipText(null);
+ Bitrate_Audio_Figure.setToolTipText(null);
+ }
+ }
+
+ public void Bitrate_includeAudio_ActionPerformed(ActionEvent evt) {
+ Bitrate_Audio_Figure.setEnabled(Bitrate_includeAudio.isSelected());
+ Text_Bitrate_Audio_Format.setEnabled(Bitrate_includeAudio.isSelected());
+ calculate();
+ }
+
+ public void calculate_Filesize_ActionPerformed(ActionEvent evt) {
+ Filesize_Figure.setEditable(false);
+ Length_hours.setEditable(true);
+ Length_minutes.setEditable(true);
+ Length_seconds.setEditable(true);
+ Bitrate_Figure.setEditable(true);
+ calculate();
+ }
+ public void calculate_Length_ActionPerformed(ActionEvent evt) {
+ Filesize_Figure.setEditable(true);
+ Length_hours.setEditable(false);
+ Length_minutes.setEditable(false);
+ Length_seconds.setEditable(false);
+ Bitrate_Figure.setEditable(true);
+ calculate();
+ }
+ public void calculate_Bitrate_ActionPerformed(ActionEvent evt) {
+ Filesize_Figure.setEditable(true);
+ Length_hours.setEditable(true);
+ Length_minutes.setEditable(true);
+ Length_seconds.setEditable(true);
+ Bitrate_Figure.setEditable(false);
+ calculate();
+ }
+
+
+
+ public void Filesize_Figure_KeyReleased(KeyEvent evt) {
+ if (!Filesize_Figure.getText().equals(Filesize_Figure.getText().replace(',', '.'))) {
+ Filesize_Figure.setText(Filesize_Figure.getText().replace(',', '.'));
+ }
+ try {
+ if (Filesize_Figure.getDouble() < 0.) {
+ Filesize_Figure.setText(Filesize_Figure.getText().substring(Filesize_Figure.getText().indexOf('-') + 1));
+ }
+ } catch (NumberFormatException e) { }
+ calculate();
+ }
+ public void Length_hours_KeyReleased(KeyEvent evt) {
+ if (!Length_hours.getText().equals(Length_hours.getText().replace(',', '.'))) {
+ Length_hours.setText(Length_hours.getText().replace(',', '.'));
+ }
+ try {
+ if (Length_hours.getDouble() < 0.) {
+ Length_hours.setText(Length_hours.getText().substring(Length_hours.getText().indexOf('-') + 1));
+ }
+ } catch (NumberFormatException e) { }
+ calculate();
+ }
+ public void Length_minutes_KeyReleased(KeyEvent evt) {
+ if (!Length_minutes.getText().equals(Length_minutes.getText().replace(',', '.'))) {
+ Length_minutes.setText(Length_minutes.getText().replace(',', '.'));
+ }
+ try {
+ if (Length_minutes.getDouble() < 0.) {
+ Length_minutes.setText(Length_minutes.getText().substring(Length_minutes.getText().indexOf('-') + 1));
+ }
+ } catch (NumberFormatException e) { }
+ calculate();
+ }
+ public void Length_seconds_KeyReleased(KeyEvent evt) {
+ if (!Length_seconds.getText().equals(Length_seconds.getText().replace(',', '.'))) {
+ Length_seconds.setText(Length_seconds.getText().replace(',', '.'));
+ }
+ try {
+ if (Length_seconds.getDouble() < 0.) {
+ Length_seconds.setText(Length_seconds.getText().substring(Length_seconds.getText().indexOf('-') + 1));
+ }
+ } catch (NumberFormatException e) { }
+ calculate();
+ }
+ public void Bitrate_Figure_KeyReleased(KeyEvent evt) {
+ if (!Bitrate_Figure.getText().equals(Bitrate_Figure.getText().replace(',', '.'))) {
+ Bitrate_Figure.setText(Bitrate_Figure.getText().replace(',', '.'));
+ }
+ try {
+ if (Bitrate_Figure.getDouble() < 0.) {
+ Bitrate_Figure.setText(Bitrate_Figure.getText().substring(Bitrate_Figure.getText().indexOf('-') + 1));
+ }
+ } catch (NumberFormatException e) { }
+ calculate();
+ }
+
+
+ public void Filesize_K1024_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ public void Filesize_K1000_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ public void Bitrate_K1024_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ public void Bitrate_K1000_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ public void Filesize_Format_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ public void Bitrate_Format_Size_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ public void Bitrate_Format_Length_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ public void Bitrate_Audio_Figure_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+
+
+ public static void main(String[] args) {
+ new BitrateGenerator("Bitrate Generator");
+ }
+}
diff --git a/src/FilesizeConverter.java b/src/FilesizeConverter.java
new file mode 100644
index 0000000..f9db156
--- /dev/null
+++ b/src/FilesizeConverter.java
@@ -0,0 +1,268 @@
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.math.BigDecimal;
+
+/**
+ * @version 1.0, 2.11.2011
+ * @author Simon Vetter
+ */
+
+public class FilesizeConverter extends JFrame {
+ private JLabel Text_Title = new JLabel();
+ private JNumberField Size_given = new JNumberField();
+ private JComboBox Unit_given = new JComboBox();
+ private JRadioButton K_given_1024 = new JRadioButton();
+ private JRadioButton K_given_1000 = new JRadioButton();
+ private ButtonGroup K_given = new ButtonGroup();
+ private JSeparator verticalLine = new JSeparator();
+ private JNumberField Size_wanted = new JNumberField();
+ private JComboBox Unit_wanted = new JComboBox();
+ private JRadioButton K_wanted_1024 = new JRadioButton();
+ private JRadioButton K_wanted_1000 = new JRadioButton();
+ private ButtonGroup K_wanted = new ButtonGroup();
+ private JButton About_Button = new JButton();
+ private JToggleButton Help_Button = new JToggleButton();
+
+ public FilesizeConverter(String title) {
+ super(title);
+ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ int frameWidth = 500;
+ int frameHeight = 230;
+ setSize(frameWidth, frameHeight);
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
+ int x = (d.width - getSize().width) / 2 - 473;
+ int y = (d.height - getSize().height) / 2;
+ setLocation(x, y);
+ setResizable(false);
+ Container cp = getContentPane();
+ cp.setLayout(null);
+
+ Text_Title.setBounds(90, 0, 310, 55);
+ Text_Title.setText("Filesize Converter");
+ Text_Title.setToolTipText("v1.0 © Simon Vetter 2011");
+ Text_Title.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_Title.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_Title.setFont(new Font("Dialog", Font.BOLD, 30));
+ Text_Title.setEnabled(true);
+ cp.add(Text_Title);
+ Size_given.setBounds(20, 65, 300, 35);
+ Size_given.setText("");
+ Size_given.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Size_given.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent evt) {
+ Size_given_KeyReleased(evt);
+ }
+ });
+ cp.add(Size_given);
+ Unit_given.setBounds(330, 65, 60, 35);
+ Unit_given.setModel(new DefaultComboBoxModel(new String[] {"B", "KB", "MB", "GB", "TB", "PB", "b", "Kb", "Mb", "Gb"}));
+ Unit_given.setSelectedIndex(2);
+ Unit_given.setMaximumRowCount(10);
+ Unit_given.setFont(new Font("Dialog", Font.PLAIN, 16));
+ Unit_given.setEditable(false);
+ Unit_given.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Unit_given_ActionPerformed(evt);
+ }
+ });
+ cp.add(Unit_given);
+ K_given_1024.setBounds(400, 62, 80, 20);
+ K_given_1024.setText("K = 1024");
+ K_given_1024.setSelected(true);
+ K_given_1024.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ K_given_1024_ActionPerformed(evt);
+ }
+ });
+ cp.add(K_given_1024);
+ K_given_1000.setBounds(400, 83, 80, 20);
+ K_given_1000.setText("K = 1000");
+ K_given_1000.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ K_given_1000_ActionPerformed(evt);
+ }
+ });
+ cp.add(K_given_1000);
+ K_given.add(K_given_1024);
+ K_given.add(K_given_1000);
+ verticalLine.setBounds(20, 125, 450, 1);
+ cp.add(verticalLine);
+ Size_wanted.setBounds(20, 150, 300, 35);
+ Size_wanted.setText("0");
+ Size_wanted.setEditable(false);
+ Size_wanted.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Size_wanted.setSelectionEnd(0);
+ Size_wanted.setSelectionStart(0);
+ cp.add(Size_wanted);
+ Unit_wanted.setBounds(330, 150, 60, 35);
+ Unit_wanted.setEditable(false);
+ Unit_wanted.setFont(new Font("Dialog", Font.PLAIN, 16));
+ Unit_wanted.setMaximumRowCount(10);
+ Unit_wanted.setModel(new DefaultComboBoxModel(new String[] {"B", "KB", "MB", "GB", "TB", "PB", "b", "Kb", "Mb", "Gb"}));
+ Unit_wanted.setSelectedIndex(2);
+ Unit_wanted.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Unit_wanted_ActionPerformed(evt);
+ }
+ });
+ cp.add(Unit_wanted);
+ K_wanted_1024.setBounds(400, 147, 80, 20);
+ K_wanted_1024.setText("K = 1024");
+ K_wanted_1024.setSelected(true);
+ K_wanted_1024.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ K_wanted_1024_ActionPerformed(evt);
+ }
+ });
+ cp.add(K_wanted_1024);
+ K_wanted_1000.setBounds(400, 168, 80, 20);
+ K_wanted_1000.setText("K = 1000");
+ K_wanted_1000.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ K_wanted_1000_ActionPerformed(evt);
+ }
+ });
+ cp.add(K_wanted_1000);
+ K_wanted.add(K_wanted_1024);
+ K_wanted.add(K_wanted_1000);
+ About_Button.setBounds(20, 13, 70, 30);
+ About_Button.setText("About");
+ About_Button.setMargin(new Insets(2, 2, 2, 2));
+ About_Button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ About_Button_ActionPerformed(evt);
+ }
+ });
+ About_Button.setHorizontalTextPosition(SwingConstants.CENTER);
+ cp.add(About_Button);
+ Help_Button.setBounds(400, 15, 70, 30);
+ Help_Button.setText("Help");
+ Help_Button.setMargin(new Insets(2, 2, 2, 2));
+ Help_Button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Help_Button_ActionPerformed(evt);
+ }
+ });
+ Help_Button.setHorizontalTextPosition(SwingConstants.CENTER);
+ Help_Button.setToolTipText("switches tooltips on/off");
+ cp.add(Help_Button);
+
+ setVisible(true);
+ }
+
+ private String getSelectedRadioButton(ButtonGroup bg) {
+ for (java.util.Enumeration e = bg.getElements(); e.hasMoreElements();) {
+ AbstractButton b = e.nextElement();
+ if (b.isSelected()) return b.getText();
+ }
+ return null;
+ }
+
+ private void Size_given_KeyReleased(KeyEvent evt) {
+ if (!Size_given.getText().equals(Size_given.getText().replace(',', '.'))) {
+ Size_given.setText(Size_given.getText().replace(',', '.'));
+ }
+ try {
+ if (Size_given.getDouble() < 0.) {
+ Size_given.setText(Size_given.getText().substring(Size_given.getText().indexOf('-') + 1));
+ }
+ } catch (NumberFormatException e) { }
+ calculate();
+ }
+ private void Unit_given_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ private void Unit_wanted_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ private void K_given_1024_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ private void K_given_1000_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ private void K_wanted_1024_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+ private void K_wanted_1000_ActionPerformed(ActionEvent evt) {
+ calculate();
+ }
+
+ private void calculate() {
+ double check;
+ try {
+ check = Size_given.getDouble();
+ } catch (java.lang.NumberFormatException e) {
+ Size_wanted.setText("0");
+ return;
+ }
+ if (!(check > 0.)) {
+ Size_wanted.setText("0");
+ return;
+ }
+
+ BigDecimal value = new BigDecimal(8);
+ value = value.valueOf(Size_given.getDouble());
+
+ long[] toBits = new long[10], toUnit = new long[10];
+ if (getSelectedRadioButton(K_given).equals("K = 1000")) {
+ long[] temp = {8L, 8000L, 8000000L, 8000000000L, 8000000000000L, 8000000000000000L, 1L, 1000L, 1000000L, 1000000000L};
+ toBits = temp;
+ }
+ else {
+ long[] temp = {8L, 8192L, 8388608L, 8589934592L, 8796093022208L, 9007199254740992L, 1L, 1024L, 1048576L, 1073741824L};
+ toBits = temp;
+ }
+ if (getSelectedRadioButton(K_wanted).equals("K = 1000")) {
+ long[] temp = {8L, 8000L, 8000000L, 8000000000L, 8000000000000L, 8000000000000000L, 1L, 1000L, 1000000L, 1000000000L};
+ toUnit = temp;
+ }
+ else {
+ long[] temp = {8L, 8192L, 8388608L, 8589934592L, 8796093022208L, 9007199254740992L, 1L, 1024L, 1048576L, 1073741824L};
+ toUnit = temp;
+ }
+
+ value = value.multiply(BigDecimal.valueOf(toBits[Unit_given.getSelectedIndex()]));
+ value = value.divide(BigDecimal.valueOf(toUnit[Unit_wanted.getSelectedIndex()]), 4, BigDecimal.ROUND_HALF_UP);
+
+ Size_wanted.setText(value.toString());
+ }
+
+ private void About_Button_ActionPerformed(ActionEvent evt) {
+ new About(this, "About Filesize Converter", true);
+ }
+
+ private void Help_Button_ActionPerformed(ActionEvent evt) {
+ if (Help_Button.isSelected()) {
+ Size_given.setToolTipText("enter the filesize you want to convert here");
+ Unit_given.setToolTipText("select the unit for the given filesize");
+ K_given_1024.setToolTipText("1 MB = 1024 B");
+ K_given_1000.setToolTipText("1 MB = 1000 B");
+ verticalLine.setToolTipText("found me!");
+ Size_wanted.setToolTipText("that's your result!");
+ Unit_wanted.setToolTipText("select the unit for your result");
+ K_wanted_1024.setToolTipText("1 MB = 1024 B");
+ K_wanted_1000.setToolTipText("1 MB = 1000 B");
+ About_Button.setToolTipText("click me!");
+ }
+ else {
+ Size_given.setToolTipText(null);
+ Unit_given.setToolTipText(null);
+ K_given_1024.setToolTipText(null);
+ K_given_1000.setToolTipText(null);
+ verticalLine.setToolTipText(null);
+ Size_wanted.setToolTipText(null);
+ Unit_wanted.setToolTipText(null);
+ K_wanted_1024.setToolTipText(null);
+ K_wanted_1000.setToolTipText(null);
+ About_Button.setToolTipText(null);
+ }
+ }
+
+
+ public static void main(String[] args) {
+ new FilesizeConverter("Filesize Converter");
+ }
+}
\ No newline at end of file
diff --git a/src/TimeCalculator.java b/src/TimeCalculator.java
new file mode 100644
index 0000000..5af4e8d
--- /dev/null
+++ b/src/TimeCalculator.java
@@ -0,0 +1,729 @@
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.math.BigDecimal;
+
+
+/**
+ * @version 1.0, 19.11.2011
+ * @author Simon Vetter
+ */
+
+public class TimeCalculator extends JFrame {
+ private JLabel Text_Title = new JLabel();
+ private JNumberField Time_hours_given1 = new JNumberField();
+ private JLabel Text_l1_h = new JLabel();
+ private JNumberField Time_minutes_given1 = new JNumberField();
+ private JLabel Text_l1_min = new JLabel();
+ private JNumberField Time_seconds_given1 = new JNumberField();
+ private JLabel Text_l1_s = new JLabel();
+ private JButton switchMode_Button = new JButton();
+ private JSeparator Seperator_h_top = new JSeparator();
+ private JSeparator Seperator_v_left = new JSeparator();
+ private JSeparator Seperator_v_right = new JSeparator();
+ private JNumberField Time_hours_given2 = new JNumberField();
+ private JLabel Text_l2_h = new JLabel();
+ private JNumberField Time_minutes_given2 = new JNumberField();
+ private JLabel Text_l2_min = new JLabel();
+ private JNumberField Time_seconds_given2 = new JNumberField();
+ private JLabel Text_l2_s = new JLabel();
+ private JButton Button_equals_nf = new JButton();
+ private JButton swapButton = new JButton();
+ private JSeparator Seperator_swap_top = new JSeparator();
+ private JSeparator Seperator_swap_bottom = new JSeparator();
+ private JNumberField Time_hours_wanted = new JNumberField();
+ private JLabel Text_l3_h = new JLabel();
+ private JNumberField Time_minutes_wanted = new JNumberField();
+ private JLabel Text_l3_min = new JLabel();
+ private JNumberField Time_seconds_wanted = new JNumberField();
+ private JLabel Text_l3_s = new JLabel();
+ private JCheckBox activate_hours = new JCheckBox();
+ private JCheckBox activate_minutes = new JCheckBox();
+ private JCheckBox activate_seconds = new JCheckBox();
+ private JSeparator Seperator_h_bottom = new JSeparator();
+ private JButton moveWayUpButton = new JButton();
+ private JButton moveUpButton = new JButton();
+ private JButton About_Button = new JButton();
+ private JToggleButton Help_Button = new JToggleButton();
+
+ public TimeCalculator(String title) {
+ super(title);
+ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ int frameWidth = 495;
+ int frameHeight = 395;
+ setSize(frameWidth, frameHeight);
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
+ int x = (d.width - getSize().width) / 2;
+ int y = (d.height - getSize().height) / 2 + 361;
+ setLocation(x, y);
+ setResizable(false);
+ Container cp = getContentPane();
+ cp.setLayout(null);
+
+ Text_Title.setBounds(90, 0, 315, 55);
+ Text_Title.setText("Time Calculator");
+ Text_Title.setFont(new Font("Dialog", Font.BOLD, 30));
+ Text_Title.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_Title.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_Title.setToolTipText("v1.0 © Simon Vetter 2011");
+ cp.add(Text_Title);
+ Time_hours_given1.setBounds(30, 75, 80, 35);
+ Time_hours_given1.setText("");
+ Time_hours_given1.setHorizontalAlignment(SwingConstants.RIGHT);
+ Time_hours_given1.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Time_hours_given1.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent evt) {
+ Time_hours_given1_KeyReleased(evt);
+ }
+ });
+ cp.add(Time_hours_given1);
+ Text_l1_h.setBounds(115, 75, 20, 35);
+ Text_l1_h.setText("h");
+ Text_l1_h.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Text_l1_h.setHorizontalAlignment(SwingConstants.LEFT);
+ Text_l1_h.setHorizontalTextPosition(SwingConstants.CENTER);
+ cp.add(Text_l1_h);
+ Time_minutes_given1.setBounds(140, 75, 80, 35);
+ Time_minutes_given1.setText("");
+ Time_minutes_given1.setHorizontalAlignment(SwingConstants.RIGHT);
+ Time_minutes_given1.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Time_minutes_given1.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent evt) {
+ Time_minutes_given1_KeyReleased(evt);
+ }
+ });
+ cp.add(Time_minutes_given1);
+ Text_l1_min.setBounds(225, 75, 35, 35);
+ Text_l1_min.setText("min");
+ Text_l1_min.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_l1_min.setFont(new Font("Dialog", Font.PLAIN, 18));
+ cp.add(Text_l1_min);
+ Time_seconds_given1.setBounds(265, 75, 80, 35);
+ Time_seconds_given1.setText("");
+ Time_seconds_given1.setHorizontalAlignment(SwingConstants.RIGHT);
+ Time_seconds_given1.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Time_seconds_given1.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent evt) {
+ Time_seconds_given1_KeyReleased(evt);
+ }
+ });
+ cp.add(Time_seconds_given1);
+ Text_l1_s.setBounds(350, 75, 20, 35);
+ Text_l1_s.setText("s");
+ Text_l1_s.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_l1_s.setFont(new Font("Dialog", Font.PLAIN, 18));
+ cp.add(Text_l1_s);
+ switchMode_Button.setBounds(30, 130, 335, 30);
+ switchMode_Button.setText("=");
+ switchMode_Button.setMargin(new Insets(2, 2, 2, 2));
+ switchMode_Button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ switchMode_Button_ActionPerformed(evt);
+ }
+ });
+ switchMode_Button.setSelected(false);
+ switchMode_Button.setFont(new Font("Dialog", Font.BOLD, 25));
+ cp.add(switchMode_Button);
+ Seperator_h_top.setBounds(20, 65, 355, 1);
+ cp.add(Seperator_h_top);
+ Seperator_v_left.setBounds(20, 65, 1, 285);
+ Seperator_v_left.setOrientation(SwingConstants.VERTICAL);
+ cp.add(Seperator_v_left);
+ Seperator_v_right.setBounds(374, 67, 1, 283);
+ Seperator_v_right.setOrientation(SwingConstants.VERTICAL);
+ cp.add(Seperator_v_right);
+ Time_hours_given2.setBounds(30, 180, 80, 35);
+ Time_hours_given2.setText("");
+ Time_hours_given2.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Time_hours_given2.setHorizontalAlignment(SwingConstants.RIGHT);
+ Time_hours_given2.setEnabled(false);
+ Time_hours_given2.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent evt) {
+ Time_hours_given2_KeyReleased(evt);
+ }
+ });
+ cp.add(Time_hours_given2);
+ Text_l2_h.setBounds(115, 180, 20, 35);
+ Text_l2_h.setText("h");
+ Text_l2_h.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Text_l2_h.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_l2_h.setEnabled(false);
+ cp.add(Text_l2_h);
+ Time_minutes_given2.setBounds(140, 180, 80, 35);
+ Time_minutes_given2.setText("");
+ Time_minutes_given2.setHorizontalAlignment(SwingConstants.RIGHT);
+ Time_minutes_given2.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Time_minutes_given2.setEnabled(false);
+ Time_minutes_given2.setVisible(true);
+ Time_minutes_given2.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent evt) {
+ Time_minutes_given2_KeyReleased(evt);
+ }
+ });
+ cp.add(Time_minutes_given2);
+ Text_l2_min.setBounds(225, 180, 35, 35);
+ Text_l2_min.setText("min");
+ Text_l2_min.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Text_l2_min.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_l2_min.setEnabled(false);
+ cp.add(Text_l2_min);
+ Time_seconds_given2.setBounds(265, 180, 80, 35);
+ Time_seconds_given2.setText("");
+ Time_seconds_given2.setHorizontalAlignment(SwingConstants.RIGHT);
+ Time_seconds_given2.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Time_seconds_given2.setEnabled(false);
+ Time_seconds_given2.addKeyListener(new KeyAdapter() {
+ public void keyReleased(KeyEvent evt) {
+ Time_seconds_given2_KeyReleased(evt);
+ }
+ });
+ cp.add(Time_seconds_given2);
+ Text_l2_s.setBounds(350, 180, 20, 35);
+ Text_l2_s.setText("s");
+ Text_l2_s.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Text_l2_s.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_l2_s.setEnabled(false);
+ cp.add(Text_l2_s);
+ Button_equals_nf.setBounds(20, 235, 355, 30);
+ Button_equals_nf.setText("=");
+ Button_equals_nf.setMargin(new Insets(2, 2, 2, 2));
+ Button_equals_nf.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Button_equals_nf_ActionPerformed(evt);
+ }
+ });
+ Button_equals_nf.setFont(new Font("Dialog", Font.BOLD, 25));
+ Button_equals_nf.setVerticalAlignment(SwingConstants.CENTER);
+ cp.add(Button_equals_nf);
+ swapButton.setBounds(410, 93, 55, 105);
+ swapButton.setText("swap");
+ swapButton.setMargin(new Insets(2, 2, 2, 2));
+ swapButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ swapButton_ActionPerformed(evt);
+ }
+ });
+ swapButton.setFont(new Font("Dialog", Font.BOLD, 16));
+ cp.add(swapButton);
+ Seperator_swap_top.setBounds(390, 93, 20, 1);
+ cp.add(Seperator_swap_top);
+ Seperator_swap_bottom.setBounds(390, 197, 20, 1);
+ cp.add(Seperator_swap_bottom);
+ Time_hours_wanted.setBounds(30, 285, 80, 35);
+ Time_hours_wanted.setText("0");
+ Time_hours_wanted.setEditable(false);
+ Time_hours_wanted.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Time_hours_wanted.setHorizontalAlignment(SwingConstants.RIGHT);
+ cp.add(Time_hours_wanted);
+ Text_l3_h.setBounds(115, 285, 20, 35);
+ Text_l3_h.setText("h");
+ Text_l3_h.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_l3_h.setFont(new Font("Dialog", Font.PLAIN, 18));
+ cp.add(Text_l3_h);
+ Time_minutes_wanted.setBounds(140, 285, 80, 35);
+ Time_minutes_wanted.setText("0");
+ Time_minutes_wanted.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Time_minutes_wanted.setEditable(false);
+ Time_minutes_wanted.setHorizontalAlignment(SwingConstants.RIGHT);
+ cp.add(Time_minutes_wanted);
+ Text_l3_min.setBounds(225, 285, 35, 35);
+ Text_l3_min.setText("min");
+ Text_l3_min.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_l3_min.setFont(new Font("Dialog", Font.PLAIN, 18));
+ cp.add(Text_l3_min);
+ Time_seconds_wanted.setBounds(265, 285, 80, 35);
+ Time_seconds_wanted.setText("0");
+ Time_seconds_wanted.setHorizontalAlignment(SwingConstants.RIGHT);
+ Time_seconds_wanted.setFont(new Font("Dialog", Font.PLAIN, 18));
+ Time_seconds_wanted.setEditable(false);
+ cp.add(Time_seconds_wanted);
+ Text_l3_s.setBounds(350, 285, 20, 35);
+ Text_l3_s.setText("s");
+ Text_l3_s.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_l3_s.setFont(new Font("Dialog", Font.PLAIN, 18));
+ cp.add(Text_l3_s);
+ activate_hours.setBounds(35, 320, 70, 20);
+ activate_hours.setText("activate");
+ activate_hours.setSelected(true);
+ activate_hours.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ activate_hours_ActionPerformed(evt);
+ }
+ });
+ cp.add(activate_hours);
+ activate_minutes.setBounds(145, 320, 70, 20);
+ activate_minutes.setText("activate");
+ activate_minutes.setSelected(true);
+ activate_minutes.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ activate_minutes_ActionPerformed(evt);
+ }
+ });
+ cp.add(activate_minutes);
+ activate_seconds.setBounds(270, 320, 70, 20);
+ activate_seconds.setText("activate");
+ activate_seconds.setSelected(true);
+ activate_seconds.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ activate_seconds_ActionPerformed(evt);
+ }
+ });
+ cp.add(activate_seconds);
+ Seperator_h_bottom.setBounds(22, 349, 353, 1);
+ cp.add(Seperator_h_bottom);
+ moveWayUpButton.setBounds(390, 282, 85, 20);
+ moveWayUpButton.setText("move way up");
+ moveWayUpButton.setMargin(new Insets(2, 2, 2, 2));
+ moveWayUpButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ moveWayUpButton_ActionPerformed(evt);
+ }
+ });
+ moveWayUpButton.setHorizontalTextPosition(SwingConstants.CENTER);
+ moveWayUpButton.setFont(new Font("Dialog", Font.PLAIN, 12));
+ cp.add(moveWayUpButton);
+ moveUpButton.setBounds(390, 303, 85, 20);
+ moveUpButton.setText("move up");
+ moveUpButton.setMargin(new Insets(2, 2, 2, 2));
+ moveUpButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ moveUpButton_ActionPerformed(evt);
+ }
+ });
+ moveUpButton.setHorizontalTextPosition(SwingConstants.CENTER);
+ moveUpButton.setFont(new Font("Dialog", Font.PLAIN, 12));
+ cp.add(moveUpButton);
+ About_Button.setBounds(20, 15, 70, 30);
+ About_Button.setText("About");
+ About_Button.setMargin(new Insets(2, 2, 2, 2));
+ About_Button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ About_Button_ActionPerformed(evt);
+ }
+ });
+ About_Button.setHorizontalTextPosition(SwingConstants.CENTER);
+ cp.add(About_Button);
+ Help_Button.setBounds(405, 15, 70, 30);
+ Help_Button.setText("Help");
+ Help_Button.setMargin(new Insets(2, 2, 2, 2));
+ Help_Button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Help_Button_ActionPerformed(evt);
+ }
+ });
+ Help_Button.setToolTipText("switches tooltips on/off");
+ cp.add(Help_Button);
+
+ setVisible(true);
+ }
+
+
+
+
+
+ private void switchMode_Button_ActionPerformed(ActionEvent evt) {
+ switchMode();
+ calculate();
+ }
+
+ private void Button_equals_nf_ActionPerformed(ActionEvent evt) {
+ // This button does not have any features, it's just part of the layout
+ calculate();
+ }
+
+ private void swapButton_ActionPerformed(ActionEvent evt) {
+ swapButton();
+ calculate();
+ }
+
+ private void activate_hours_ActionPerformed(ActionEvent evt) {
+ if (!activate_hours.isSelected() && (activate_minutes.isSelected() ^ activate_seconds.isSelected())) {
+ activate_minutes.setEnabled(!activate_minutes.isSelected());
+ activate_seconds.setEnabled(!activate_seconds.isSelected());
+ }
+ else {
+ activate_minutes.setEnabled(true);
+ activate_seconds.setEnabled(true);
+ }
+ Time_hours_wanted.setEnabled(activate_hours.isSelected());
+ Text_l3_h.setEnabled(activate_hours.isSelected());
+ calculate();
+ }
+ private void activate_minutes_ActionPerformed(ActionEvent evt) {
+ if (!activate_minutes.isSelected() && (activate_hours.isSelected() ^ activate_seconds.isSelected())) {
+ activate_hours.setEnabled(!activate_hours.isSelected());
+ activate_seconds.setEnabled(!activate_seconds.isSelected());
+ }
+ else {
+ activate_hours.setEnabled(true);
+ activate_seconds.setEnabled(true);
+ }
+ Time_minutes_wanted.setEnabled(activate_minutes.isSelected());
+ Text_l3_min.setEnabled(activate_minutes.isSelected());
+ calculate();
+ }
+ private void activate_seconds_ActionPerformed(ActionEvent evt) {
+ if (!activate_seconds.isSelected() && (activate_hours.isSelected() ^ activate_minutes.isSelected())) {
+ activate_hours.setEnabled(!activate_hours.isSelected());
+ activate_minutes.setEnabled(!activate_minutes.isSelected());
+ }
+ else {
+ activate_hours.setEnabled(true);
+ activate_minutes.setEnabled(true);
+ }
+ Time_seconds_wanted.setEnabled(activate_seconds.isSelected());
+ Text_l3_s.setEnabled(activate_seconds.isSelected());
+ calculate();
+ }
+
+ private void moveWayUpButton_ActionPerformed(ActionEvent evt) {
+ moveWayUp();
+ calculate();
+ }
+ private void moveUpButton_ActionPerformed(ActionEvent evt) {
+ moveUp();
+ calculate();
+ }
+
+
+
+ public void Time_hours_given1_KeyReleased(KeyEvent evt) {
+ if (!Time_hours_given1.getText().equals(Time_hours_given1.getText().replace(',', '.'))) {
+ Time_hours_given1.setText(Time_hours_given1.getText().replace(',', '.'));
+ }
+ try {
+ if (Time_hours_given1.getDouble() < 0.) {
+ Time_hours_given1.setText(Time_hours_given1.getText().substring(Time_hours_given1.getText().indexOf('-') + 1));
+ }
+ } catch (NumberFormatException e) { }
+ calculate();
+ }
+ public void Time_minutes_given1_KeyReleased(KeyEvent evt) {
+ if (!Time_minutes_given1.getText().equals(Time_minutes_given1.getText().replace(',', '.'))) {
+ Time_minutes_given1.setText(Time_minutes_given1.getText().replace(',', '.'));
+ }
+ try {
+ if (Time_minutes_given1.getDouble() < 0.) {
+ Time_minutes_given1.setText(Time_minutes_given1.getText().substring(Time_minutes_given1.getText().indexOf('-') + 1));
+ }
+ } catch (NumberFormatException e) { }
+ calculate();
+ }
+ public void Time_seconds_given1_KeyReleased(KeyEvent evt) {
+ if (!Time_seconds_given1.getText().equals(Time_seconds_given1.getText().replace(',', '.'))) {
+ Time_seconds_given1.setText(Time_seconds_given1.getText().replace(',', '.'));
+ }
+ try {
+ if (Time_seconds_given1.getDouble() < 0.) {
+ Time_seconds_given1.setText(Time_seconds_given1.getText().substring(Time_seconds_given1.getText().indexOf('-') + 1));
+ }
+ } catch (NumberFormatException e) { }
+ calculate();
+ }
+ public void Time_hours_given2_KeyReleased(KeyEvent evt) {
+ if (!Time_hours_given2.getText().equals(Time_hours_given2.getText().replace(',', '.'))) {
+ Time_hours_given2.setText(Time_hours_given2.getText().replace(',', '.'));
+ }
+ try {
+ if (Time_hours_given2.getDouble() < 0.) {
+ Time_hours_given2.setText(Time_hours_given2.getText().substring(Time_hours_given2.getText().indexOf('-') + 1));
+ }
+ } catch (NumberFormatException e) { }
+ calculate();
+ }
+ public void Time_minutes_given2_KeyReleased(KeyEvent evt) {
+ if (!Time_minutes_given2.getText().equals(Time_minutes_given2.getText().replace(',', '.'))) {
+ Time_minutes_given2.setText(Time_minutes_given2.getText().replace(',', '.'));
+ }
+ try {
+ if (Time_minutes_given2.getDouble() < 0.) {
+ Time_minutes_given2.setText(Time_minutes_given2.getText().substring(Time_minutes_given2.getText().indexOf('-') + 1));
+ }
+ } catch (NumberFormatException e) { }
+ calculate();
+ }
+ public void Time_seconds_given2_KeyReleased(KeyEvent evt) {
+ if (!Time_seconds_given2.getText().equals(Time_seconds_given2.getText().replace(',', '.'))) {
+ Time_seconds_given2.setText(Time_seconds_given2.getText().replace(',', '.'));
+ }
+ try {
+ if (Time_seconds_given2.getDouble() < 0.) {
+ Time_seconds_given2.setText(Time_seconds_given2.getText().substring(Time_seconds_given2.getText().indexOf('-') + 1));
+ }
+ } catch (NumberFormatException e) { }
+ calculate();
+ }
+
+
+
+
+
+
+ private void calculate() {
+ double input_h1, input_min1, input_s1;
+ try {
+ input_h1 = Time_hours_given1.getDouble();
+ } catch (java.lang.NumberFormatException e) {
+ input_h1 = 0.;
+ }
+ try {
+ input_min1 = Time_minutes_given1.getDouble();
+ } catch (java.lang.NumberFormatException e) {
+ input_min1 = 0.;
+ }
+ try {
+ input_s1 = Time_seconds_given1.getDouble();
+ } catch (java.lang.NumberFormatException e) {
+ input_s1 = 0.;
+ }
+ BigDecimal hours1 = new BigDecimal(0), minutes1 = new BigDecimal(0), seconds1 = new BigDecimal(0);
+ if (input_h1 > 0.) {
+ hours1 = hours1.valueOf(input_h1);
+ }
+ if (input_min1 > 0.) {
+ minutes1 = minutes1.valueOf(input_min1);
+ }
+ if (input_s1 > 0.) {
+ seconds1 = seconds1.valueOf(input_s1);
+ }
+
+ if (switchMode_Button.getText().equals("=")) {
+ convert(hours1, minutes1, seconds1);
+ return;
+ }
+
+ double input_h2, input_min2, input_s2;
+ try {
+ input_h2 = Time_hours_given2.getDouble();
+ } catch (java.lang.NumberFormatException e) {
+ input_h2 = 0.;
+ }
+ try {
+ input_min2 = Time_minutes_given2.getDouble();
+ } catch (java.lang.NumberFormatException e) {
+ input_min2 = 0.;
+ }
+ try {
+ input_s2 = Time_seconds_given2.getDouble();
+ } catch (java.lang.NumberFormatException e) {
+ input_s2 = 0.;
+ }
+ BigDecimal hours2 = new BigDecimal(0), minutes2 = new BigDecimal(0), seconds2 = new BigDecimal(0);
+ if (input_h2 > 0.) {
+ hours2 = hours2.valueOf(input_h2);
+ }
+ if (input_min2 > 0.) {
+ minutes2 = minutes2.valueOf(input_min2);
+ }
+ if (input_s2 > 0.) {
+ seconds2 = seconds2.valueOf(input_s2);
+ }
+
+ if (switchMode_Button.getText().equals("+")) {
+ addition(hours1, minutes1, seconds1, hours2, minutes2, seconds2);
+ return;
+ }
+
+ if (switchMode_Button.getText().equals("–")) {
+ subtraction(hours1, minutes1, seconds1, hours2, minutes2, seconds2);
+ return;
+ }
+
+ convert(hours1, minutes1, seconds1);
+ }
+ private void addition(BigDecimal hours1, BigDecimal minutes1, BigDecimal seconds1, BigDecimal hours2, BigDecimal minutes2, BigDecimal seconds2) {
+ print(seconds1.add(minutes1.multiply(new BigDecimal(60))).add(hours1.multiply(new BigDecimal(3600))).add(seconds2).add(minutes2.multiply(new BigDecimal(60))).add(hours2.multiply(new BigDecimal(3600))));
+ }
+ private void subtraction(BigDecimal hours1, BigDecimal minutes1, BigDecimal seconds1, BigDecimal hours2, BigDecimal minutes2, BigDecimal seconds2) {
+ print(seconds1.add(minutes1.multiply(new BigDecimal(60))).add(hours1.multiply(new BigDecimal(3600))).subtract(seconds2).subtract(minutes2.multiply(new BigDecimal(60))).subtract(hours2.multiply(new BigDecimal(3600))));
+ }
+ private void convert(BigDecimal hours, BigDecimal minutes, BigDecimal seconds) {
+ print(seconds.add(minutes.multiply(new BigDecimal(60))).add(hours.multiply(new BigDecimal(3600))));
+ }
+ private void print(BigDecimal seconds) {
+ if (!activate_hours.isSelected() && !activate_minutes.isSelected()) {
+ Time_hours_wanted.setText("0");
+ Time_hours_wanted.setText("0");
+ Time_seconds_wanted.setText(seconds.toString());
+ return;
+ }
+ BigDecimal minutes = new BigDecimal(0), hours = new BigDecimal(0);
+ while (seconds.doubleValue() >= 60) {
+ seconds = seconds.subtract(new BigDecimal(60));
+ minutes = minutes.add(new BigDecimal(1));
+ }
+ if (!activate_hours.isSelected() && activate_minutes.isSelected() && activate_seconds.isSelected()) {
+ Time_hours_wanted.setText("0");
+ Time_minutes_wanted.setText(minutes.toString());
+ Time_seconds_wanted.setText(seconds.toString());
+ return;
+ }
+ if (!activate_hours.isSelected() && activate_minutes.isSelected() && !activate_seconds.isSelected()) {
+ Time_hours_wanted.setText("0");
+ Time_minutes_wanted.setText(minutes.add(seconds.divide(new BigDecimal(60), 2, BigDecimal.ROUND_HALF_UP)).toString());
+ Time_seconds_wanted.setText("0");
+ return;
+ }
+ while (minutes.doubleValue() >= 60) {
+ minutes = minutes.subtract(new BigDecimal(60));
+ hours = hours.add(new BigDecimal(1));
+ }
+ if (activate_hours.isSelected() && activate_minutes.isSelected() && !activate_seconds.isSelected()) {
+ Time_hours_wanted.setText(hours.toString());
+ Time_minutes_wanted.setText(minutes.add(seconds.divide(new BigDecimal(60), 2, BigDecimal.ROUND_HALF_UP)).toString());
+ Time_seconds_wanted.setText("0");
+ return;
+ }
+ if (activate_hours.isSelected() && !activate_minutes.isSelected() && !activate_seconds.isSelected()) {
+ Time_hours_wanted.setText(hours.add(minutes.add(seconds.divide(new BigDecimal(60), 2, BigDecimal.ROUND_HALF_UP)).divide(new BigDecimal(60), 2, BigDecimal.ROUND_HALF_UP)).toString());
+ Time_minutes_wanted.setText("0");
+ Time_seconds_wanted.setText("0");
+ return;
+ }
+ if (activate_hours.isSelected() && !activate_minutes.isSelected() && activate_seconds.isSelected()) {
+ Time_hours_wanted.setText(hours.toString());
+ Time_minutes_wanted.setText("0");
+ Time_seconds_wanted.setText(seconds.add(minutes.multiply(new BigDecimal(60))).toString());
+ return;
+ }
+ Time_hours_wanted.setText(hours.toString());
+ Time_minutes_wanted.setText(minutes.toString());
+ Time_seconds_wanted.setText(seconds.toString());
+ }
+
+ private void switchMode() {
+ if (switchMode_Button.getText().equals("=")) {
+ switchMode_Button.setText("+");
+ activateLine2(true);
+ return;
+ }
+ if (switchMode_Button.getText().equals("+")) {
+ switchMode_Button.setText("–");
+ activateLine2(true);
+ return;
+ }
+ else {
+ switchMode_Button.setText("=");
+ activateLine2(false);
+ }
+ }
+ private void activateLine2(boolean active) {
+ Time_hours_given2.setEnabled(active);
+ Text_l2_h.setEnabled(active);
+ Time_minutes_given2.setEnabled(active);
+ Text_l2_min.setEnabled(active);
+ Time_seconds_given2.setEnabled(active);
+ Text_l2_s.setEnabled(active);
+ }
+
+ private void swapButton() {
+ String temp_h = Time_hours_given1.getText();
+ String temp_min = Time_minutes_given1.getText();
+ String temp_s = Time_seconds_given1.getText();
+ Time_hours_given1.setText(Time_hours_given2.getText());
+ Time_minutes_given1.setText(Time_minutes_given2.getText());
+ Time_seconds_given1.setText(Time_seconds_given2.getText());
+ Time_hours_given2.setText(temp_h);
+ Time_minutes_given2.setText(temp_min);
+ Time_seconds_given2.setText(temp_s);
+ }
+
+ private void moveWayUp() {
+ Time_hours_given1.setText(Time_hours_wanted.getText());
+ Time_minutes_given1.setText(Time_minutes_wanted.getText());
+ Time_seconds_given1.setText(Time_seconds_wanted.getText());
+ }
+ private void moveUp() {
+ Time_hours_given2.setText(Time_hours_wanted.getText());
+ Time_minutes_given2.setText(Time_minutes_wanted.getText());
+ Time_seconds_given2.setText(Time_seconds_wanted.getText());
+ }
+
+
+ public void About_Button_ActionPerformed(ActionEvent evt) {
+ new About(this, "About Time Calculator", true);
+ }
+
+ public void Help_Button_ActionPerformed(ActionEvent evt) {
+ if (Help_Button.isSelected()) {
+ Seperator_h_top.setToolTipText("found me!");
+ Seperator_v_left.setToolTipText("found me!");
+ Seperator_v_right.setToolTipText("found me!");
+ Seperator_h_bottom.setToolTipText("found me!");
+ Time_hours_given1.setToolTipText("enter the first time period you want to calculate with here");
+ Text_l1_h.setToolTipText("hours");
+ Time_minutes_given1.setToolTipText("enter the first time period you want to calculate with here");
+ Text_l1_min.setToolTipText("minutes");
+ Time_seconds_given1.setToolTipText("enter the first time period you want to calculate with here");
+ Text_l1_s.setToolTipText("seconds");
+ switchMode_Button.setToolTipText("switch between convert, addition and subtraction mode");
+ Time_hours_given2.setToolTipText("enter the second time period you want to calculate with here");
+ Text_l2_h.setToolTipText("hours");
+ Time_minutes_given2.setToolTipText("enter the second time period you want to calculate with here");
+ Text_l2_min.setToolTipText("minutes");
+ Time_seconds_given2.setToolTipText("enter the second time period you want to calculate with here");
+ Text_l2_s.setToolTipText("seconds");
+ Button_equals_nf.setToolTipText("click me!");
+ Time_hours_wanted.setToolTipText("that's your result!");
+ Text_l3_h.setToolTipText("hours");
+ Time_minutes_wanted.setToolTipText("that's your result!");
+ Text_l3_min.setToolTipText("minutes");
+ Time_seconds_wanted.setToolTipText("that's your result!");
+ Text_l3_s.setToolTipText("seconds");
+ activate_hours.setToolTipText("display the amount of full hours in your result");
+ activate_minutes.setToolTipText("display the amount of full minutes in your result");
+ activate_seconds.setToolTipText("display the amount of seconds in your result");
+ swapButton.setToolTipText("swap the set time periods in line 1 and 2");
+ Seperator_swap_top.setToolTipText("I point at the first line");
+ Seperator_swap_bottom.setToolTipText("I point at the second line");
+ moveWayUpButton.setToolTipText("move your result to the first line");
+ moveUpButton.setToolTipText("move your result to the second line");
+ }
+ else {
+ Seperator_h_top.setToolTipText(null);
+ Seperator_v_left.setToolTipText(null);
+ Seperator_v_right.setToolTipText(null);
+ Seperator_h_bottom.setToolTipText(null);
+ Time_hours_given1.setToolTipText(null);
+ Text_l1_h.setToolTipText(null);
+ Time_minutes_given1.setToolTipText(null);
+ Text_l1_min.setToolTipText(null);
+ Time_seconds_given1.setToolTipText(null);
+ Text_l1_s.setToolTipText(null);
+ switchMode_Button.setToolTipText(null);
+ Time_hours_given2.setToolTipText(null);
+ Text_l2_h.setToolTipText(null);
+ Time_minutes_given2.setToolTipText(null);
+ Text_l2_min.setToolTipText(null);
+ Time_seconds_given2.setToolTipText(null);
+ Text_l2_s.setToolTipText(null);
+ Button_equals_nf.setToolTipText(null);
+ Time_hours_wanted.setToolTipText(null);
+ Text_l3_h.setToolTipText(null);
+ Time_minutes_wanted.setToolTipText(null);
+ Text_l3_min.setToolTipText(null);
+ Time_seconds_wanted.setToolTipText(null);
+ Text_l3_s.setToolTipText(null);
+ activate_hours.setToolTipText(null);
+ activate_minutes.setToolTipText(null);
+ activate_seconds.setToolTipText(null);
+ swapButton.setToolTipText(null);
+ Seperator_swap_top.setToolTipText(null);
+ Seperator_swap_bottom.setToolTipText(null);
+ moveWayUpButton.setToolTipText(null);
+ moveUpButton.setToolTipText(null);
+ }
+ }
+
+
+
+
+
+
+
+
+ public static void main(String[] args) {
+ new TimeCalculator("TimeCalculator");
+ }
+}
\ No newline at end of file
diff --git a/src/VideoCalcSuite.java b/src/VideoCalcSuite.java
new file mode 100644
index 0000000..74e1038
--- /dev/null
+++ b/src/VideoCalcSuite.java
@@ -0,0 +1,137 @@
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.event.*;
+
+/**
+ * @version 1.0, 25.11.2011
+ * @author Simon Vetter
+ */
+
+public class VideoCalcSuite extends JFrame {
+ private JLabel Text_Title = new JLabel();
+ private JButton Button_BitrateGenerator = new JButton();
+ private JButton Button_FilesizeConverter = new JButton();
+ private JButton Button_TimeCalculator = new JButton();
+ private JButton Button_BitrateConverter = new JButton();
+ private JLabel Text_Author = new JLabel();
+
+ private int amountBG = 0, amountFC = 0, amountBC = 0, amountTC = 0;
+
+ public VideoCalcSuite(String title) {
+ super(title);
+ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ int frameWidth = 426;
+ int frameHeight = 306;
+ setSize(frameWidth, frameHeight);
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
+ int x = (d.width - getSize().width) / 2;
+ int y = (d.height - getSize().height) / 2;
+ setLocation(x, y);
+ setResizable(false);
+ Container cp = getContentPane();
+ cp.setLayout(null);
+
+ Text_Title.setBounds(0, 5, 420, 50);
+ Text_Title.setText("VideoCalc Suite");
+ Text_Title.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_Title.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_Title.setFont(new Font("Dialog", Font.BOLD, 40));
+ Text_Title.setToolTipText("© Simon Vetter 2011
All rights reserved.");
+ cp.add(Text_Title);
+ Button_BitrateGenerator.setBounds(10, 100, 400, 50);
+ Button_BitrateGenerator.setText("Bitrate Generator");
+ Button_BitrateGenerator.setMargin(new Insets(2, 2, 2, 2));
+ Button_BitrateGenerator.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Button_BitrateGenerator_ActionPerformed(evt);
+ }
+ });
+ Button_BitrateGenerator.setFont(new Font("Dialog", Font.BOLD, 18));
+ Button_BitrateGenerator.setToolTipText("open a new Bitrate Generator");
+ cp.add(Button_BitrateGenerator);
+ Button_FilesizeConverter.setBounds(10, 160, 195, 50);
+ Button_FilesizeConverter.setText("Filesize Converter");
+ Button_FilesizeConverter.setMargin(new Insets(2, 2, 2, 2));
+ Button_FilesizeConverter.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Button_FilesizeConverter_ActionPerformed(evt);
+ }
+ });
+ Button_FilesizeConverter.setFont(new Font("Dialog", Font.BOLD, 18));
+ Button_FilesizeConverter.setToolTipText("open a new Filesize Converter");
+ cp.add(Button_FilesizeConverter);
+ Button_TimeCalculator.setBounds(10, 220, 400, 50);
+ Button_TimeCalculator.setText("Time Calculator");
+ Button_TimeCalculator.setMargin(new Insets(2, 2, 2, 2));
+ Button_TimeCalculator.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Button_TimeCalculator_ActionPerformed(evt);
+ }
+ });
+ Button_TimeCalculator.setFont(new Font("Dialog", Font.BOLD, 18));
+ Button_TimeCalculator.setToolTipText("open a new Time Calculator");
+ cp.add(Button_TimeCalculator);
+ Button_BitrateConverter.setBounds(215, 160, 195, 50);
+ Button_BitrateConverter.setText("Bitrate Converter");
+ Button_BitrateConverter.setMargin(new Insets(2, 2, 2, 2));
+ Button_BitrateConverter.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Button_BitrateConverter_ActionPerformed(evt);
+ }
+ });
+ Button_BitrateConverter.setFont(new Font("Dialog", Font.BOLD, 18));
+ Button_BitrateConverter.setToolTipText("open a new Bitrate Converter");
+ cp.add(Button_BitrateConverter);
+ Text_Author.setBounds(0, 55, 420, 30);
+ Text_Author.setText("by Simon Vetter");
+ Text_Author.setHorizontalAlignment(SwingConstants.CENTER);
+ Text_Author.setHorizontalTextPosition(SwingConstants.CENTER);
+ Text_Author.setFont(new Font("Dialog", Font.BOLD, 20));
+ Text_Author.setToolTipText("Simon Vetter
Frankfurt/Main, Germany
@SimeTologist");
+ cp.add(Text_Author);
+
+ setVisible(true);
+ }
+
+ public void Button_BitrateGenerator_ActionPerformed(ActionEvent evt) {
+ amountBG++;
+ String title = "Bitrate Generator";
+ if (amountBG > 1) {
+ title = title + " " + amountBG;
+ }
+ new BitrateGenerator(title);
+ }
+
+ public void Button_FilesizeConverter_ActionPerformed(ActionEvent evt) {
+ amountFC++;
+ String title = "Filesize Converter";
+ if (amountFC > 1) {
+ title = title + " " + amountFC;
+ }
+ new FilesizeConverter(title);
+ }
+
+ public void Button_BitrateConverter_ActionPerformed(ActionEvent evt) {
+ amountBC++;
+ String title = "Bitrate Converter";
+ if (amountBC > 1) {
+ title = title + " " + amountBC;
+ }
+ new BitrateConverter(title);
+ }
+
+ public void Button_TimeCalculator_ActionPerformed(ActionEvent evt) {
+ amountTC++;
+ String title = "Time Calculator";
+ if (amountTC > 1) {
+ title = title + " " + amountTC;
+ }
+ new TimeCalculator(title);
+ }
+
+
+ public static void main(String[] args) {
+ new VideoCalcSuite("VideoCalc Suite");
+ }
+}