역시 리브레 위키도 사람 많은 곳이다 생각하고 남남처럼 지내는게 맞다. 감당 못하면 피해야지...
sudo pacman -S jdk-openjdk
sudo pacman -S code
F1 누르고
> settings json
intellicode 설치하고
java.home 입력해서 자동으로 뜨는 거 확인
"java.jdt.ls.java.home": "/usr/lib/jvm/java-17-openjdk/"
코드 쓰고 F5
package code;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Test extends JFrame implements ActionListener {
class DrawPanel extends JPanel {
public int positionX; public int positionY;
public void paintComponent(Graphics g) {
g.setColor(Color.BLACK);
g.drawOval(positionX, positionY, 100, 100);
}
}
DrawPanel drawPanel;
int moveOffset;
public Test () {
setSize(800, 500);
setLayout(new BorderLayout());
JButton upButton = new JButton("Up");
upButton.addActionListener(this);
add(upButton, "North");
JButton downButton = new JButton("Down");
downButton.addActionListener(this);
add(downButton , "South");
JButton rightButton = new JButton("Right");
rightButton.addActionListener(this);
add(rightButton, "East");
JButton leftButton = new JButton("Left");
leftButton.addActionListener(this);
add(leftButton, "West");
drawPanel = new DrawPanel();
getContentPane().add(drawPanel);
moveOffset = 20;
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
final class Vector{
static int X; static int Y;
}
switch (command) {
case "Up":
Vector.Y = -1; break;
case "Down":
Vector.Y = 1; break;
case "Left":
Vector.X = -1; break;
case "Right":
Vector.X = 1; break;
}
new Thread(() -> {
for (int i = 0; i < moveOffset; i++) {
try {
Thread.sleep(i);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
drawPanel.positionY += Vector.Y;
drawPanel.positionX += Vector.X;
getContentPane().repaint();
}
Vector.X = 0;
Vector.Y = 0;
}).start();
}
public static void main(String[] args) {
Test9_ppt window = new Test();
}
}
//오옹 나이스
어차피 사회에선 나를 욕할 ㅅㄲ들 천지다