diff --git a/.gitignore b/.gitignore index d8591a4..311425f 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,6 @@ hs_err_pid* replay_pid* # Visual Studio Code settings.json -settings.json \ No newline at end of file +settings.json +# IntelliJ Idea +.idea/* \ No newline at end of file diff --git a/DinoGame/.classpath b/DinoGame/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/DinoGame/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/DinoGame/.idea/.gitignore b/DinoGame/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/DinoGame/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/DinoGame/.idea/artifacts/DinoGame_jar.xml b/DinoGame/.idea/artifacts/DinoGame_jar.xml new file mode 100644 index 0000000..c945d0f --- /dev/null +++ b/DinoGame/.idea/artifacts/DinoGame_jar.xml @@ -0,0 +1,9 @@ + + + $PROJECT_DIR$/bin/artifacts/DinoGame_jar + + + + + + \ No newline at end of file diff --git a/DinoGame/.idea/misc.xml b/DinoGame/.idea/misc.xml new file mode 100644 index 0000000..07115cd --- /dev/null +++ b/DinoGame/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DinoGame/.idea/modules.xml b/DinoGame/.idea/modules.xml new file mode 100644 index 0000000..8f68773 --- /dev/null +++ b/DinoGame/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/DinoGame/.idea/vcs.xml b/DinoGame/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/DinoGame/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DinoGame/.project b/DinoGame/.project new file mode 100644 index 0000000..a107a78 --- /dev/null +++ b/DinoGame/.project @@ -0,0 +1,28 @@ + + + DinoGame + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + + + 1758261738047 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/DinoGame/DinoGame.iml b/DinoGame/DinoGame.iml new file mode 100644 index 0000000..3a692df --- /dev/null +++ b/DinoGame/DinoGame.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DinoGame/resources/all-sprites.png b/DinoGame/resources/all-sprites.png new file mode 100644 index 0000000..3a1e92e Binary files /dev/null and b/DinoGame/resources/all-sprites.png differ diff --git a/DinoGame/resources/best-scores.txt b/DinoGame/resources/best-scores.txt new file mode 100644 index 0000000..ea16103 --- /dev/null +++ b/DinoGame/resources/best-scores.txt @@ -0,0 +1,6 @@ +result=21,date=20200420_144048,player=Dino +result=58,date=20200420_144054,player=Dino +result=328,date=20200420_144126,player=Dino +result=367,date=20200422_130458,player=Dino +result=408,date=20200425_162524,player=Dino +result=537,date=20200425_164524,player=Dino diff --git a/DinoGame/resources/bird-fly-1.png b/DinoGame/resources/bird-fly-1.png new file mode 100644 index 0000000..0d8e745 Binary files /dev/null and b/DinoGame/resources/bird-fly-1.png differ diff --git a/DinoGame/resources/bird-fly-2.png b/DinoGame/resources/bird-fly-2.png new file mode 100644 index 0000000..b349f0f Binary files /dev/null and b/DinoGame/resources/bird-fly-2.png differ diff --git a/DinoGame/resources/cactus-1.png b/DinoGame/resources/cactus-1.png new file mode 100644 index 0000000..1a17639 Binary files /dev/null and b/DinoGame/resources/cactus-1.png differ diff --git a/DinoGame/resources/cactus-2.png b/DinoGame/resources/cactus-2.png new file mode 100644 index 0000000..7768a06 Binary files /dev/null and b/DinoGame/resources/cactus-2.png differ diff --git a/DinoGame/resources/cactus-3.png b/DinoGame/resources/cactus-3.png new file mode 100644 index 0000000..cb402e9 Binary files /dev/null and b/DinoGame/resources/cactus-3.png differ diff --git a/DinoGame/resources/cactus-4.png b/DinoGame/resources/cactus-4.png new file mode 100644 index 0000000..2f42442 Binary files /dev/null and b/DinoGame/resources/cactus-4.png differ diff --git a/DinoGame/resources/cactus-5.png b/DinoGame/resources/cactus-5.png new file mode 100644 index 0000000..3b31b87 Binary files /dev/null and b/DinoGame/resources/cactus-5.png differ diff --git a/DinoGame/resources/cactus-6.png b/DinoGame/resources/cactus-6.png new file mode 100644 index 0000000..2067870 Binary files /dev/null and b/DinoGame/resources/cactus-6.png differ diff --git a/DinoGame/resources/cactus-7.png b/DinoGame/resources/cactus-7.png new file mode 100644 index 0000000..511cb8b Binary files /dev/null and b/DinoGame/resources/cactus-7.png differ diff --git a/DinoGame/resources/cactus-8.png b/DinoGame/resources/cactus-8.png new file mode 100644 index 0000000..b30d190 Binary files /dev/null and b/DinoGame/resources/cactus-8.png differ diff --git a/DinoGame/resources/cactus-9.png b/DinoGame/resources/cactus-9.png new file mode 100644 index 0000000..aa2bdc2 Binary files /dev/null and b/DinoGame/resources/cactus-9.png differ diff --git a/DinoGame/resources/cloud.png b/DinoGame/resources/cloud.png new file mode 100644 index 0000000..9ef7acd Binary files /dev/null and b/DinoGame/resources/cloud.png differ diff --git a/DinoGame/resources/dead.wav b/DinoGame/resources/dead.wav new file mode 100644 index 0000000..a34ac25 Binary files /dev/null and b/DinoGame/resources/dead.wav differ diff --git a/DinoGame/resources/dino-dead.png b/DinoGame/resources/dino-dead.png new file mode 100644 index 0000000..d03044e Binary files /dev/null and b/DinoGame/resources/dino-dead.png differ diff --git a/DinoGame/resources/dino-down-run-1.png b/DinoGame/resources/dino-down-run-1.png new file mode 100644 index 0000000..79710f4 Binary files /dev/null and b/DinoGame/resources/dino-down-run-1.png differ diff --git a/DinoGame/resources/dino-down-run-2.png b/DinoGame/resources/dino-down-run-2.png new file mode 100644 index 0000000..adbf0d0 Binary files /dev/null and b/DinoGame/resources/dino-down-run-2.png differ diff --git a/DinoGame/resources/dino-jump.png b/DinoGame/resources/dino-jump.png new file mode 100644 index 0000000..4043d9e Binary files /dev/null and b/DinoGame/resources/dino-jump.png differ diff --git a/DinoGame/resources/dino-run-1.png b/DinoGame/resources/dino-run-1.png new file mode 100644 index 0000000..5bfb1e7 Binary files /dev/null and b/DinoGame/resources/dino-run-1.png differ diff --git a/DinoGame/resources/dino-run-2.png b/DinoGame/resources/dino-run-2.png new file mode 100644 index 0000000..0550f04 Binary files /dev/null and b/DinoGame/resources/dino-run-2.png differ diff --git a/DinoGame/resources/game-over.png b/DinoGame/resources/game-over.png new file mode 100644 index 0000000..e003a5e Binary files /dev/null and b/DinoGame/resources/game-over.png differ diff --git a/DinoGame/resources/hi.png b/DinoGame/resources/hi.png new file mode 100644 index 0000000..6cd4dd3 Binary files /dev/null and b/DinoGame/resources/hi.png differ diff --git a/DinoGame/resources/intro-text.png b/DinoGame/resources/intro-text.png new file mode 100644 index 0000000..812b784 Binary files /dev/null and b/DinoGame/resources/intro-text.png differ diff --git a/DinoGame/resources/jump.wav b/DinoGame/resources/jump.wav new file mode 100644 index 0000000..8426122 Binary files /dev/null and b/DinoGame/resources/jump.wav differ diff --git a/DinoGame/resources/land.png b/DinoGame/resources/land.png new file mode 100644 index 0000000..5c9b709 Binary files /dev/null and b/DinoGame/resources/land.png differ diff --git a/DinoGame/resources/numbers.png b/DinoGame/resources/numbers.png new file mode 100644 index 0000000..25db276 Binary files /dev/null and b/DinoGame/resources/numbers.png differ diff --git a/DinoGame/resources/paused.png b/DinoGame/resources/paused.png new file mode 100644 index 0000000..51633e6 Binary files /dev/null and b/DinoGame/resources/paused.png differ diff --git a/DinoGame/resources/replay.png b/DinoGame/resources/replay.png new file mode 100644 index 0000000..8babc4d Binary files /dev/null and b/DinoGame/resources/replay.png differ diff --git a/DinoGame/resources/scoreup.wav b/DinoGame/resources/scoreup.wav new file mode 100644 index 0000000..acf1017 Binary files /dev/null and b/DinoGame/resources/scoreup.wav differ diff --git a/DinoGame/src/DinoGame.java b/DinoGame/src/DinoGame.java new file mode 100644 index 0000000..3a9a912 --- /dev/null +++ b/DinoGame/src/DinoGame.java @@ -0,0 +1,466 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.image.BufferedImage; +import javax.imageio.ImageIO; +import java.io.*; +import java.util.ArrayList; +import java.util.Random; +import javax.sound.sampled.*; + +public class DinoGame extends JPanel implements ActionListener, KeyListener { + // Game constants + private static final int WIDTH = 800; + private static final int HEIGHT = 400; + private static final int GROUND_Y = 320; + private static final int FPS = 60; + private static final int GRAVITY = 2; + private static final int JUMP_STRENGTH = -22; + + // Game state + private Timer timer; + private boolean gameStarted = false; + private boolean gameOver = false; + private boolean paused = false; + private int score = 0; + private int highScore = 0; + private double gameSpeed = 12.0; + private int frameCount = 0; + + // Player + private int dinoX = 50; + private int dinoY = GROUND_Y - 90; + private int dinoWidth = 44; + private int dinoHeight = 47; + private int velocityY = 0; + private boolean isJumping = false; + private boolean isDucking = false; + private int animFrame = 0; + + // Images + private BufferedImage dinoRun1, dinoRun2, dinoJump, dinoDead; + private BufferedImage dinoDownRun1, dinoDownRun2; + private BufferedImage cactus1, cactus2, cactus3, cactus4, cactus5, cactus6; + private BufferedImage birdFly1, birdFly2; + private BufferedImage cloud, land, gameOverImg, replayImg, hiImg; + + // Game objects + private ArrayList obstacles = new ArrayList<>(); + private ArrayList clouds = new ArrayList<>(); + private int landX = 0; + private Random rand = new Random(); + private int obstacleTimer = 0; + + // Audio + private Clip jumpSound, deadSound, scoreSound; + + public DinoGame() { + setPreferredSize(new Dimension(WIDTH, HEIGHT)); + setBackground(Color.WHITE); + setFocusable(true); + addKeyListener(this); + + loadImages(); + loadSounds(); + loadHighScore(); + + // Initialize clouds + for (int i = 0; i < 3; i++) { + clouds.add(new Cloud(rand.nextInt(WIDTH), 50 + rand.nextInt(100))); + } + + timer = new Timer(1000 / FPS, this); + timer.start(); + } + + private void loadImages() { + try { + dinoRun1 = ImageIO.read(getClass().getResourceAsStream("/dino-run-1.png")); + dinoRun2 = ImageIO.read(getClass().getResourceAsStream("/dino-run-2.png")); + dinoJump = ImageIO.read(getClass().getResourceAsStream("/dino-jump.png")); + dinoDead = ImageIO.read(getClass().getResourceAsStream("/dino-dead.png")); + dinoDownRun1 = ImageIO.read(getClass().getResourceAsStream("/dino-down-run-1.png")); + dinoDownRun2 = ImageIO.read(getClass().getResourceAsStream("/dino-down-run-2.png")); + + cactus1 = ImageIO.read(getClass().getResourceAsStream("/cactus-1.png")); + cactus2 = ImageIO.read(getClass().getResourceAsStream("/cactus-2.png")); + cactus3 = ImageIO.read(getClass().getResourceAsStream("/cactus-3.png")); + cactus4 = ImageIO.read(getClass().getResourceAsStream("/cactus-4.png")); + cactus5 = ImageIO.read(getClass().getResourceAsStream("/cactus-5.png")); + cactus6 = ImageIO.read(getClass().getResourceAsStream("/cactus-6.png")); + + birdFly1 = ImageIO.read(getClass().getResourceAsStream("/bird-fly-1.png")); + birdFly2 = ImageIO.read(getClass().getResourceAsStream("/bird-fly-2.png")); + + cloud = ImageIO.read(getClass().getResourceAsStream("/cloud.png")); + land = ImageIO.read(getClass().getResourceAsStream("/land.png")); + gameOverImg = ImageIO.read(getClass().getResourceAsStream("/game-over.png")); + replayImg = ImageIO.read(getClass().getResourceAsStream("/replay.png")); + hiImg = ImageIO.read(getClass().getResourceAsStream("/hi.png")); + } catch (Exception e) { + System.err.println("Error loading images: " + e.getMessage()); + e.printStackTrace(); + } + } + + private void loadSounds() { + try { + jumpSound = AudioSystem.getClip(); + jumpSound.open(AudioSystem.getAudioInputStream(getClass().getResourceAsStream("/jump.wav"))); + + deadSound = AudioSystem.getClip(); + deadSound.open(AudioSystem.getAudioInputStream(getClass().getResourceAsStream("/dead.wav"))); + + scoreSound = AudioSystem.getClip(); + scoreSound.open(AudioSystem.getAudioInputStream(getClass().getResourceAsStream("/scoreup.wav"))); + } catch (Exception e) { + System.err.println("Error loading sounds: " + e.getMessage()); + e.printStackTrace(); + } + } + + private void loadHighScore() { + try { + InputStream is = getClass().getResourceAsStream("/best-scores.txt"); + if (is != null) { + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + String line = reader.readLine(); + if (line != null) { + highScore = Integer.parseInt(line.trim()); + } + reader.close(); + } + } catch (Exception e) { + highScore = 0; + } + } + + private void saveHighScore() { + try { + // Save to user's home directory since resources folder is read-only + String userHome = System.getProperty("user.home"); + File scoresFile = new File(userHome, "dino-best-scores.txt"); + PrintWriter writer = new PrintWriter(new FileWriter(scoresFile)); + writer.println(highScore); + writer.close(); + } catch (IOException e) { + System.err.println("Error saving high score: " + e.getMessage()); + } + } + + private void playSound(Clip clip) { + if (clip != null) { + try { + if (clip.isRunning()) { + clip.stop(); + } + clip.setFramePosition(0); + clip.start(); + } catch (Exception e) { + System.err.println("Error playing audio: " + e.getMessage()); + } + } + } + + @Override + public void actionPerformed(ActionEvent e) { + if (!gameStarted || paused) { + repaint(); + return; + } + + if (!gameOver) { + frameCount++; + + // Update score + if (frameCount % 6 == 0) { + score++; + if (score % 100 == 0) { + playSound(scoreSound); + } + } + + // Increase speed + if (frameCount % 600 == 0) { + gameSpeed += 0.5; + } + + // Update dino + if (isJumping) { + velocityY += GRAVITY; + dinoY += velocityY; + + if (dinoY >= GROUND_Y - 90) { + dinoY = GROUND_Y - 90; + isJumping = false; + velocityY = 0; + } + } + + // Animation + if (frameCount % 5 == 0) { + animFrame = (animFrame + 1) % 2; + } + + // Update ground + landX -= (int)gameSpeed; + if (land != null && landX <= -land.getWidth()) { + landX = 0; + } + + // Update clouds + for (Cloud c : clouds) { + c.x -= 2; + if (cloud != null && c.x < -cloud.getWidth()) { + c.x = WIDTH + rand.nextInt(200); + c.y = 50 + rand.nextInt(100); + } + } + + // Spawn obstacles + obstacleTimer++; + if (obstacleTimer > 60 + rand.nextInt(60)) { + spawnObstacle(); + obstacleTimer = 0; + } + + // Update obstacles + for (int i = obstacles.size() - 1; i >= 0; i--) { + Obstacle obs = obstacles.get(i); + obs.x -= (int)gameSpeed; + + if (obs.x < -obs.width) { + obstacles.remove(i); + } else if (checkCollision(obs)) { + gameOver = true; + playSound(deadSound); + if (score > highScore) { + highScore = score; + saveHighScore(); + } + } + } + } + + repaint(); + } + + private void spawnObstacle() { + int type = rand.nextInt(10); + if (type < 7) { + // Cactus + BufferedImage[] cacti = {cactus1, cactus2, cactus3, cactus4, cactus5, cactus6}; + BufferedImage cactusImg = cacti[rand.nextInt(cacti.length)]; + if (cactusImg != null) { + obstacles.add(new Obstacle(WIDTH, GROUND_Y - cactusImg.getHeight(), + cactusImg.getWidth(), cactusImg.getHeight(), + cactusImg, false)); + } + } else { + // Bird + if (birdFly1 != null) { + int birdY = GROUND_Y - 44 - rand.nextInt(2) * 80; + obstacles.add(new Obstacle(WIDTH, birdY, 46, 40, birdFly1, true)); + } + } + } + + private boolean checkCollision(Obstacle obs) { + int dinoActualHeight = isDucking ? 26 : dinoHeight; + int dinoActualY = isDucking ? GROUND_Y - 90 : dinoY; + + Rectangle dinoRect = new Rectangle(dinoX + 5, dinoActualY + 5, + dinoWidth - 10, dinoActualHeight - 10); + Rectangle obsRect = new Rectangle(obs.x + 5, obs.y + 5, + obs.width - 10, obs.height - 10); + + return dinoRect.intersects(obsRect); + } + + private void reset() { + gameOver = false; + gameStarted = true; + score = 0; + gameSpeed = 12.0; + frameCount = 0; + dinoY = GROUND_Y - 90; + velocityY = 0; + isJumping = false; + isDucking = false; + obstacles.clear(); + obstacleTimer = 0; + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2d = (Graphics2D) g; + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + // Draw clouds + for (Cloud c : clouds) { + if (cloud != null) { + g2d.drawImage(cloud, c.x, c.y, null); + } + } + + // Draw ground + if (land != null) { + g2d.drawImage(land, landX, GROUND_Y, null); + g2d.drawImage(land, landX + land.getWidth(), GROUND_Y, null); + } + + // Draw ground line + g2d.setColor(Color.BLACK); + g2d.fillRect(0, GROUND_Y - 2, WIDTH, 2); + + // Draw dino + BufferedImage dinoImg; + if (gameOver) { + dinoImg = dinoDead; + } else if (isJumping) { + dinoImg = dinoJump; + } else if (isDucking) { + dinoImg = (animFrame == 0) ? dinoDownRun1 : dinoDownRun2; + } else { + dinoImg = (animFrame == 0) ? dinoRun1 : dinoRun2; + } + + if (dinoImg != null) { + if (isDucking) { + g2d.drawImage(dinoImg, dinoX, GROUND_Y - 26, 59, 26, null); + } else { + g2d.drawImage(dinoImg, dinoX, dinoY, null); + } + } + + // Draw obstacles + for (Obstacle obs : obstacles) { + if (obs.isBird) { + BufferedImage birdImg = (frameCount % 10 < 5) ? birdFly1 : birdFly2; + if (birdImg != null) { + g2d.drawImage(birdImg, obs.x, obs.y, null); + } + } else { + if (obs.img != null) { + g2d.drawImage(obs.img, obs.x, obs.y, null); + } + } + } + + // Draw score + g2d.setColor(Color.BLACK); + g2d.setFont(new Font("Courier New", Font.BOLD, 16)); + if (hiImg != null && highScore > 0) { + g2d.drawImage(hiImg, WIDTH - 200, 20, null); + g2d.drawString(String.format("%05d", highScore), WIDTH - 150, 35); + } + g2d.drawString(String.format("%05d", score), WIDTH - 80, 35); + + // Draw game over + if (gameOver) { + if (gameOverImg != null) { + g2d.drawImage(gameOverImg, WIDTH / 2 - gameOverImg.getWidth() / 2, 100, null); + } + if (replayImg != null) { + g2d.drawImage(replayImg, WIDTH / 2 - replayImg.getWidth() / 2, 150, null); + } + } + + // Draw start message + if (!gameStarted) { + g2d.setFont(new Font("Arial", Font.BOLD, 20)); + g2d.drawString("Press SPACE to Start", WIDTH / 2 - 120, HEIGHT / 2); + } + + // Draw pause + if (paused) { + g2d.setFont(new Font("Arial", Font.BOLD, 30)); + g2d.drawString("PAUSED", WIDTH / 2 - 60, HEIGHT / 2); + } + } + + @Override + public void keyPressed(KeyEvent e) { + int key = e.getKeyCode(); + + if (key == KeyEvent.VK_SPACE) { + if (!gameStarted) { + gameStarted = true; + } else if (gameOver) { + reset(); + } else if (!isJumping && !isDucking) { + isJumping = true; + velocityY = JUMP_STRENGTH; + playSound(jumpSound); + } + } + + if (key == KeyEvent.VK_DOWN && !isJumping && gameStarted && !gameOver) { + isDucking = true; + } + + if (key == KeyEvent.VK_P && gameStarted && !gameOver) { + paused = !paused; + } + } + + @Override + public void keyReleased(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_DOWN) { + isDucking = false; + } + } + + @Override + public void keyTyped(KeyEvent e) {} + + private class Obstacle { + int x, y, width, height; + BufferedImage img; + boolean isBird; + + Obstacle(int x, int y, int width, int height, BufferedImage img, boolean isBird) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + this.img = img; + this.isBird = isBird; + } + } + + private class Cloud { + int x, y; + + Cloud(int x, int y) { + this.x = x; + this.y = y; + } + } + + public static void main(String[] args) { + try { + SwingUtilities.invokeLater(() -> { + JFrame frame = new JFrame("Chrome Dino Game"); + try { + BufferedImage icon = ImageIO.read(DinoGame.class.getResourceAsStream("/dino-jump.png")); + frame.setIconImage(icon); + } catch (IOException e) { + System.err.println("Errore caricamento icona: " + e.getMessage()); + e.printStackTrace(); + } + DinoGame game = new DinoGame(); + frame.add(game); + frame.pack(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLocationRelativeTo(null); + frame.setResizable(false); + frame.setVisible(true); + }); + } catch (Exception e){ + System.err.println("Error : " + e.getMessage()); + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/PrimaGUI/README.md b/PrimaGUI/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/PrimaGUI/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/PrimaGUI/src/App.java b/PrimaGUI/src/App.java new file mode 100644 index 0000000..5103fc1 --- /dev/null +++ b/PrimaGUI/src/App.java @@ -0,0 +1,14 @@ +import javax.swing.JButton; +import javax.swing.JFrame; +public class App { + public static void main(String[] args) throws Exception { + JFrame f = new JFrame("Una finestra meravigliosa"); + f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + f.setBounds(100,100,800,600); + f.setLayout(null); + JButton b = new JButton("ok"); + b.setBounds(100, 20, 100, 30); + f.add(b); + f.setVisible(true); + } +}