|
|
@ -64,6 +64,8 @@ public class TasksFrame extends JFrame { |
|
|
|
|
|
|
|
public void run() { |
|
|
|
|
|
|
|
setupAtoi(); |
|
|
|
|
|
|
|
setupFib(); |
|
|
|
|
|
|
|
setupHelloWorld(); |
|
|
@ -113,6 +115,62 @@ public class TasksFrame extends JFrame { |
|
|
|
setupReverse(); |
|
|
|
} |
|
|
|
|
|
|
|
private void setupAtoi(){ |
|
|
|
JPanel jPanel = setupPanel("atoi"); |
|
|
|
|
|
|
|
JLabel jLabel = new JLabel(); |
|
|
|
jLabel.setVisible(true); |
|
|
|
jLabel.setText("Enter a Integer and get and a Bit"); |
|
|
|
jPanel.setBounds(5, 20, 200, 30); |
|
|
|
jPanel.add(jLabel); |
|
|
|
|
|
|
|
JTextField input = new JTextField(); |
|
|
|
input.setVisible(true); |
|
|
|
input.setBounds(5, 30, 200, 30); |
|
|
|
jPanel.add(input); |
|
|
|
|
|
|
|
JTextField output = new JTextField(); |
|
|
|
output.setVisible(true); |
|
|
|
output.setBounds(5, 60, 200, 30); |
|
|
|
jPanel.add(output); |
|
|
|
|
|
|
|
JButton jButton = new JButton("iton"); |
|
|
|
jButton.setVisible(true); |
|
|
|
jButton.setBounds(210, 30, 100, 30); |
|
|
|
jPanel.add(jButton); |
|
|
|
jButton.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
String text = input.getText(); |
|
|
|
int value = Integer.valueOf(text); |
|
|
|
|
|
|
|
String binary = calcAtoi(value); |
|
|
|
output.setText(binary); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// JButton jButton2 = new JButton("ntoi"); |
|
|
|
// jButton2.setVisible(true); |
|
|
|
// jButton2.setBounds(210, 30, 100, 30); |
|
|
|
// jPanel.add(jButton2); |
|
|
|
// jButton2.addActionListener(new ActionListener() { |
|
|
|
// @Override |
|
|
|
// public void actionPerformed(ActionEvent e) { |
|
|
|
// String text = output.getText(); |
|
|
|
// int value = Integer.valueOf(text); |
|
|
|
// |
|
|
|
// String binary = calcAtoi(value); |
|
|
|
// output.setText(binary); |
|
|
|
// |
|
|
|
// } |
|
|
|
// }); |
|
|
|
} |
|
|
|
|
|
|
|
public String calcAtoi(int value) { |
|
|
|
return Integer.toBinaryString(value); |
|
|
|
} |
|
|
|
|
|
|
|
private void setupFib() { |
|
|
|
JPanel jPanel = setupPanel("Fibonacci"); |
|
|
|
|
|
|
|