Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4.  
  5.  
  6. public class ButtonFrame extends JFrame {
  7.     private JTextField inputField = new JTextField(20);
  8.  
  9.     public ButtonFrame(String title){
  10.         setTitle(title);
  11.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  12.  
  13.         LayoutManager layout = new FlowLayout();
  14.         setLayout(new FlowLayout());
  15.  
  16.         JRadioButtonMenuItem svensk = new JRadioButtonMenuItem("Svensk");
  17.         JRadioButtonMenuItem norsk = new JRadioButtonMenuItem("Norsk");
  18.  
  19.         JLabel label = new JLabel("Skriv inn nummer");
  20.         JButton button = new JButton("Enter");
  21.         add(svensk);
  22.         add(norsk);
  23.         add(label);
  24.         add(inputField);
  25.         add(button);
  26.         ButtonListener buttonListener = new ButtonListener();
  27.         button.addActionListener(buttonListener);
  28.         pack();
  29.  
  30.     }
  31. }
  32.  
  33. public class ButtonListener implements ActionListener {
  34.     public void actionPerformed(ActionEvent happening) {
  35.         String input = inputField.getText();
  36.     }
  37.  
  38. }
  39.  
  40.  
  41.  
  42.  
  43. public class TestValuta {
  44.     public static void main(String[]args) {
  45.         ButtonFrame mainframe = new ButtonFrame("Valuta");
  46.         mainframe.setVisible(true);
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement