1) Create the following GUI, so that when your program is running, your user can
ID: 663718 • Letter: 1
Question
1) Create the following GUI, so that when your program is running, your user can input information regarding a client and hit the save button to save the information out to a file.
2) Every time the user hits the save button, that information should be saved out to a file called client.txt; each new client's information should append to the information already saved onto the file client.txt.
3) The data in the client.txt file should be formatted like the following.
Client Activity Report Client Name Client ID Starting Balance Closing Balance XXXXXXXXX 9999999 99999.99 99999.99 XXXXXXXXX 9999999 99999.99 99999.99 XXXXXXXXX 9999999 99999.99 99999.99Explanation / Answer
2 and 3 rd part
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Client{
String name;
String ID;
float initial_bal;
float final_bal;
}
public class run extends JApplet implements ActionListener {
Panel p1;
GridLayout gl1;
Font f, f1;
boolean query;
JEditorPane editor;
JButton b1;
List<String[]> l;
String all_talk = "";
void draw_frame(){
p1 = new Panel();
gl1 = new GridLayout(1,1);
p1.setLayout(gl1);
b1 = new JButton("Display");
editor = new JEditorPane("text/html","");
f1 = new Font("SansSerif",Font.BOLD, 16);
editor.setFont(f1);
editor.setEditable(false);
JScrollPane scroll = new JScrollPane (editor);
p1.add(b1);
add(scroll);
input.addActionListener(this);
add(p1,BorderLayout.NORTH);
}
public void actionPerformed(ActionEvent ae){
String str = ae.getActionCommand();
if (str.equals("Display") == true){
for (String[] s : l){
for (int i = 0; i < s.length; i++){
all_talk += s[i] + " ";
}
all_talk += "<br>";
}
editor.setText(all_talk);
all_talk = "";
}
}
public static void main(String[] args) throws IOException{
draw_frame();
l = new ArrayList<String[]>();
BufferedReader br = new BufferedReader(new FileReader("client.txt"));
String s = "";
while ((s = br.readLine()) != null) {
l.add(s.split("|"));
}
draw_frame();
}
}
4th Part
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class A4 extends JPanel{
private static final long serialVersionUID = 1L;
public static Graphics2D g2;
public static void main(String[] a) {
JFrame f = new JFrame();
f.setSize(800, 800);
f.add(new A4());
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
/* Draw_Rectangle */
public static void draw_rect(double x1,double y1,double w,double h){
final float dash1[] = {10.0f};
final BasicStroke dashed = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
g2.setStroke(dashed);
g2.draw(new RoundRectangle2D.Double(x1, y1, w, h, 10, 10));
}
/* Draw a Eclipse */
public static void draw_ecp(double x1,double y1,double w,double h){
GradientPaint redtowhite = new GradientPaint(0,0,Color.RED,100, 0,Color.WHITE);
g2.setPaint(redtowhite);
g2.fill (new Ellipse2D.Double(x1, y1, w, h));
}
public void paint(Graphics g) {
g2 = (Graphics2D) g;
// Draw a Rectangle
draw_rect(100,100,70,80);
// Draw a eclipse
draw_ecp(0, 0, 100, 50);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.