Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 77 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. import edu.princeton.cs.introcs.StdDraw;
  2. import javax.swing.*;
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import java.util.HashMap;
  6. import java.util.Map;
  7.  
  8.  
  9. public class Vaja extends JFrame{
  10.     JPanel p = new JPanel();
  11.     JButton b = new JButton("Hello");
  12.     JLabel t = new JLabel("SUUUUUP");
  13.     JTextField tf = new JTextField(null, 10);
  14.     Map<Point, Integer> mesta= new HashMap<>();
  15.     public static void main(String[] args) {
  16.         new Vaja();
  17.     }
  18.     public Vaja(){
  19.         super("Test");
  20.         setSize(500,500);
  21.         setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  22.         setResizable(true);
  23.  
  24.         b.addActionListener(new ActionListener() {
  25.             @Override
  26.             public void actionPerformed(ActionEvent e) {
  27.                 spremeniIme();
  28.             }
  29.         });
  30.         addMouseMotionListener(new MouseMotionListener() {
  31.             @Override
  32.             public void mouseDragged(MouseEvent e) {
  33.  
  34.             }
  35.  
  36.             @Override
  37.             public void mouseMoved(MouseEvent e) {
  38.                 Point tmp = e.getLocationOnScreen();
  39.                 obisk(tmp);
  40.  
  41.             }
  42.         });
  43.         p.add(b);
  44.         p.add(t);
  45.         p.add(tf);
  46.         add(p);
  47.  
  48.         setVisible(true);
  49.     }
  50.     void novDialog(){
  51.         JDialog d = new JDialog(this, false);
  52.         d.setSize(100, 100);
  53.         d.setLocation(250, 250);
  54.         d.setVisible(true);
  55.     }
  56.     void spremeniIme(){
  57.         String tmp = this.tf.getText();
  58.         this.t.setText(tmp);
  59.     }
  60.     void obisk(Point here){
  61.         if(mesta.containsKey(here)){
  62.             mesta.put(here, mesta.get(here)+1);
  63.         }
  64.         else{
  65.             mesta.put(here, 1);
  66.         }
  67.         System.out.printf("Mesto %d %d, je bilo obiskano %d krat\n", here.x, here.y, mesta.get(here));
  68.     }
  69. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top