Skip to content

Instantly share code, notes, and snippets.

@erayakartuna
Last active December 13, 2016 07:26
Show Gist options
  • Save erayakartuna/e25356317d389a1e512d836a1a64c85e to your computer and use it in GitHub Desktop.
Save erayakartuna/e25356317d389a1e512d836a1a64c85e to your computer and use it in GitHub Desktop.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DENEME extends JFrame
{
public static final int WIDTH = 300;
public static final int HEIGHT = 300;
public static JTextField textfield_1;
public static JTextField textfield_2;
public static JTextField textfield_3;
public static void main(String[] arg){
JFrame frame = new JFrame("Soru 1");
JPanel panel = new JPanel();
JLabel label_1 = new JLabel("Height");
JLabel label_2 = new JLabel("Weight");
JLabel label_3 = new JLabel("Body Result");
textfield_1 = new JTextField("",20);
textfield_2 = new JTextField("",20);
textfield_3 = new JTextField("",20);
JButton button = new JButton("Body Check");
button.setSize(new Dimension(40, 40));
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
int height = Integer.parseInt(textfield_1.getText());
int width = Integer.parseInt(textfield_2.getText());
if(height - 100- width > 10){
textfield_3.setText("Your Body Unbalanced");
}
else{
textfield_3.setText("Your Body balanced");
}
}
});
panel.add(label_1);
panel.add(textfield_1);
panel.add(label_2);
panel.add(textfield_2);
panel.add(label_3);
panel.add(textfield_3);
panel.add(button);
frame.add(panel);
frame.setSize(WIDTH,HEIGHT);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment