Sunday, September 1, 2019

Contoh Code Bergerak Mengikuti Mouse di Netbeans

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.event.MouseMotionListener;
import javax.swing.JFrame;
public class Hanif extends JFrame implements MouseMotionListener{
public static void main(String[] args) {
new FrameTengah();
}
String c = “HANIF”;
int x,y;
int  a=0,  b=0;
public FrameTengah(){
this.setTitle(“Frame Tengah”);
this.setSize(500,500);
Dimension ukDimension = Toolkit.getDefaultToolkit().getScreenSize();
int lebar = ukDimension.width;
int tinggi = ukDimension.height;
int x = (lebar-this.getWidth())/2;
int y = (tinggi-this.getHeight())/2;
this.setLocation(x, y);
this.setVisible(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
addMouseMotionListener(this);
}
public void paint(Graphics g) {
g.clearRect(0, 0, 500, 500);
g.drawString(c, a, b);
}
public void mouseDragged(MouseEvent e) {
i = e.getX ();
j = e.getY();
repaint();
}
public void mouseMoved(MouseEvent e) {
i = e.getX();
j = e.getY();
repaint();
}
}

Memunculkan Simbol & Emoji Pada OS Mac

  Memunculkan Simbol & Emoji  1. Buka aplikasi Pages / Notes pada Macbook. 2. Klik pada Menubar Edit --> Pilih Emoji and Symbols a...