#4 liborb
Zatím se mi povedlo udělat tohle
package javaapplication4;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.Math.*;
public class Kalkulacka extends JFrame implements ActionListener
{
public JButton JB;
public JTextField JTF;
public float cislo;
public String retezec, znak;
public Kalkulacka ()
{
this.setSize(280, 65);
this.setTitle("Kalkulacka");
this.setLocation(500,500);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new FlowLayout(FlowLayout.LEFT,10,3));
JTF = new JTextField ("",20);
JB = new JButton("Zaokrouhli!");
this.getContentPane().add (JTF);
this.getContentPane().add (JB);
this.setVisible(true);
JB.addActionListener
(
new java.awt.event.ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
retezec = JTF.getText();
cislo = Float.parseFloat(retezec);
Math.round(10.3);
System.out.println("cislo = " + Math.round(Math.E));
JTF.setText("");
JTF.requestFocusInWindow();
}
}
);
}
public static void main (String [] args)
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e)
{
e.printStackTrace();
}
Kalkulacka okno = new Kalkulacka () ;
}
@Override
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
a nevím jak dál.. někde tam budou i chyby