Cobalt 60, a radioactive form of cobalt used in cancer therapy, decays or dissip
ID: 3621732 • Letter: C
Question
Cobalt 60, a radioactive form of cobalt used in cancer therapy, decays or dissipates over a period of time. Each year, 12 percent of the amount present at the beginning of the year will have decayed. Write a Java program CConverter.java using Swing class which requests the initial amount of Cobalt 60 and n number of years, and determines the amount remaining afer n years. Your GUI should resemble the interface below:
The Javapad editor must also be implemented.
Here is the javapad editor that needs to be implemented:
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class Javapad extends JFrame {
private JMenuBar menuBar;
private JMenu fileMenu;
private JMenuItem n, open, save, exit;
public Javapad() {
super("Javapad");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setPreferredSize(new Dimension(640, 480));
buildGUI(); pack();
setVisible(true);
}
class FileListener implements ActionListener {
private JFileChooser fc;
private JTextArea area;
public FileListener(JTextArea area) {
fc = new JFileChooser();
this.area = area;
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == open) {
int returnVal = fc.showOpenDialog(Javapad.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
try {
File file = fc.getSelectedFile();
area.setText(s);
}
catch (IOException exc) {
exc.printStackTrace();
System.exit(1);
}
}
}
else if(e.getSource() == save) {
int returnVal = fc.showSaveDialog(Javapad.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
try {
File file = fc.getSelectedFile();
}
catch(IOException exc) {
exc.printStackTrace();
System.exit(1); }
}
}
}
}
private void buildGUI() {
Container container = this.getContentPane();
menuBar = new JMenuBar();
menuBar.setBorder( new BevelBorder(BevelBorder.RAISED) );
menuBar.setBorderPainted(true);
container.add(menuBar, BorderLayout.NORTH);
fileMenu = new JMenu("File");
menuBar.add(fileMenu);
JMenuItem n = new JMenuItem("New");
fileMenu.add(n);
fileMenu.addSeparator();
open = new JMenuItem("Open");
fileMenu.add(open);
fileMenu.addSeparator();
save = new JMenuItem("Save");
fileMenu.add(save);
fileMenu.addSeparator();
JMenuItem exit = new JMenuItem("Exit");
fileMenu.add(exit);
JTextArea edit = new JTextArea(30,20);
edit.setFont(new Font("Courier", Font.PLAIN, 14));
JScrollPane sp = new JScrollPane(edit);
sp.setPreferredSize(new Dimension(450, 100));
container.add(sp, BorderLayout.CENTER);
FileListener fl = new FileListener(edit);
open.addActionListener(fl);
save.addActionListener(fl);
}
public static void main(String[] args) { Javapad jp = new Javapad();
}
}
Explanation / Answer
see if this is helpful:- http://flylib.com/books/en/3.29.1.43/1/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.