import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
//TIP To Run code, press or
// click the icon in the gutter.
public class Main extends JFrame {
JButton buttonDel, buttonDiv;
JTextField screen;
public Main(String title) throws HeadlessException {
super(title);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(1920,1080);
setLocationRelativeTo(null);
setVisible(true);
setLayout(new GridBagLayout());
setPreferredSize(new Dimension(500,500));
GridBagConstraints g = new GridBagConstraints();
g.fill = GridBagConstraints.HORIZONTAL;
buttonDel = new JButton("Del");
buttonDiv = new JButton("/");
screen = new JTextField();
buttonDel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
screen.setText(screen.getText() + "1");
}
});
g.gridx = 0;
g.gridy = 0;
g.gridwidth = 1;
g.gridheight = 1;
g.fill = GridBagConstraints.BOTH;
add(buttonDel, g);
g.gridx = 1;
add(buttonDiv, g);
g.gridx = 0;
g.gridy = 1;
g.gridwidth = 2;
add(screen, g);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
new Main("Kalkulačka");
}
});
}
}