import java.awt.*; import java.applet.*; import java.awt.event.*; public class Test extends Applet implements ActionListener { Label lb; TextField tf1, tf2, tf3; Button bt; int size, size1, size2, s1, s, s2, total; float percSize, percSize1, percSize2; public void init() { setLayout(null); lb = new Label("Enter Statistic Figures"); tf1 = new TextField(); tf2 = new TextField(); tf3 = new TextField(); bt = new Button("Draw"); bt.addActionListener(this); lb.setBounds(20,40,140,20); tf1.setBounds(170,40,40,20); tf2.setBounds(220,40,40,20); tf3.setBounds(270,40,40,20); bt.setBounds(380,40,60,20); add(lb); add(tf1); add(tf2); add(tf3); add(bt); } public void paint(Graphics g) { //od lewej,od gory, pochylenie=200, szerokosc=200 (proporcjonalnie!), od kata, rozsz. o kat g.setColor(Color.BLUE); g.fillArc(100,200,400,400,0,s); g.setColor(Color.ORANGE); g.fillArc(100,200,400,400,s,s1); g.setColor(Color.GREEN); g.fillArc(100,200,400,400,s1,s2); } public void actionPerformed(ActionEvent e) { size = Integer.parseInt(tf1.getText()); size1 = Integer.parseInt(tf2.getText()); size2 = Integer.parseInt(tf3.getText()); total = size+size1+size2; percSize = (size * 100.0f) / total; percSize1 = (size1 * 100.0f) / total; percSize2 = (size2 * 100.0f) / total; s = percSize*360/100; s1 = percSize1*360/100; s2 = percSize2*360/100; repaint(); } } The error code does not work when compiling + does not display the diagram itself (Does not draw) When compiling this line of code, s = percSize * 360/100; Throws error possible lossy conversion from float to int
possible lossy conversion from float to int- says only that the accuracy of the number is lost, since it converts into an integer, which means throwing away everything after the comma ..... you need to understand whether the whole suits you or if you want to maintain accuracy - Alexey Shimansky