Wayback Machine
60 captures
29 Jan 2022 - 22 Jun 2025
May AUG Sep
Previous capture 04 Next capture
2021 2022 2023
success
fail
About this capture
COLLECTED BY
Collection: Save Page Now
TIMESTAMPS
loading
The Wayback Machine - https://web.archive.org/web/20220804153612/https://code.visualstudio.com/docs/java/java-gui
Skip to content  Visual Studio Code
  • Docs
  • Updates
  • Blog
  • API
  • Extensions
  • FAQ
  • Learn
  • Search
  • Search Search
  • Download VS Code Download VS Code Download

Version 1.69 is now available! Read about the new features and fixes from June.

Dismiss this update
'; document.body.appendChild(div.children[0]); } function pushCodingPackEvent(language, os) { let id = `${language}-${os}-coding-pack`; var analytics = window.vscodeAnalytics; analytics && analytics.event( 'click', 'download', id, ); }
  • Overview
  • Setup
    • Overview
    • Linux
    • macOS
    • Windows
    • Raspberry Pi
    • Network
    • Additional Components
    • Enterprise
    • Uninstall
  • Get Started
    • Intro Videos
    • Tips and Tricks
    • User Interface
    • Themes
    • Settings
    • Key Bindings
    • Display Language
    • Telemetry
  • User Guide
    • Basic Editing
    • Extension Marketplace
    • IntelliSense
    • Code Navigation
    • Refactoring
    • Debugging
    • Version Control
    • Working with GitHub
    • VS Code for the Web
    • Tasks
    • Settings Sync
    • Snippets
    • Emmet
    • Command Line Interface
    • Workspace Trust
    • Multi-root Workspaces
    • Accessibility
  • Terminal
    • Terminal Basics
    • Shell Integration
  • Languages
    • Overview
    • JavaScript
    • JSON
    • HTML
    • CSS, SCSS and Less
    • TypeScript
    • Markdown
    • PowerShell
    • C++
    • Java
    • PHP
    • Python
    • Julia
    • R
    • Rust
    • Go
    • T-SQL
    • C#
    • .NET
  • Node.js / JavaScript
    • Working with JavaScript
    • Node.js Tutorial
    • Node.js Debugging
    • Node.js Deployment
    • Browser Debugging
    • Angular Tutorial
    • React Tutorial
    • Vue Tutorial
    • Ember Tutorial
    • Debugging Recipes
    • Extensions
  • TypeScript
    • Tutorial
    • Compiling
    • Editing
    • Refactoring
    • Debugging
  • Python
    • Tutorial
    • Editing Code
    • Linting
    • Debugging
    • Environments
    • Testing
    • Data Science
    • Python Interactive
    • Django Tutorial
    • Flask Tutorial
    • Create containers
    • Python on Azure
    • Settings Reference
  • Java
    • Getting Started
    • Navigate and Edit
    • Refactoring
    • Formatting and Linting
    • Project Management
    • Build Tools
    • Run and Debug
    • Testing
    • Spring Boot
    • Application Servers
    • Java on Azure
    • GUI Applications
    • Extensions
    • FAQ
  • C++
    • Intro Videos
    • GCC on Linux
    • GCC on Windows
    • GCC on Windows Subsystem for Linux
    • Clang on macOS
    • Microsoft C++ on Windows
    • Build with CMake
    • CMake Tools on Linux
    • Editing
    • Debugging
    • Configure debugging
    • Settings
    • Configure IntelliSense for cross-compiling
    • FAQ
  • Containers
    • Overview
    • Node.js
    • Python
    • ASP.NET Core
    • Debug
    • Docker Compose
    • Registries
    • Deploy to Azure
    • Choose a dev environment
    • Customize
    • Develop with Kubernetes
    • Tips and Tricks
  • Data Science
    • Overview
    • Jupyter Notebooks
    • Data Science Tutorial
    • Python Interactive
    • PyTorch Support
    • Azure Machine Learning
  • Azure
    • Extensions
    • Deployment
    • Remote Debugging for Node.js
    • Docker
    • MongoDB
    • Kubernetes
    • Azure Kubernetes Service
  • Remote
    • Overview
    • SSH
    • Containers
    • Windows Subsystem for Linux
    • GitHub Codespaces
    • VS Code Server
    • SSH Tutorial
    • Containers Tutorial
    • WSL Tutorial
    • Attach to Container
    • Create a Dev Container
    • Advanced Containers
    • devcontainer.json
    • devcontainer CLI
    • Tips and Tricks
    • FAQ

Topics

Working with GUI applications in VS Code

You can develop Java GUI applications in Visual Studio Code easily. To achieve that, you need to install the Extension Pack for Java, which includes all the required extensions to develop Java GUI applications.

Install the Extension Pack for Java

If you run into any issues when using the features below, you can contact us by entering an issue.

Develop JavaFX applications

Create a new JavaFX project

You can create a new JavaFX application with just a few steps in VS Code:

  • Step 1: Install the Extension Pack for Java.
  • Step 2: In Visual Studio Code, open the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)) and then select the command Java: Create Java Project.
  • Step 3: Select the option JavaFX in the list, follow the wizard, which will help you scaffold a new JavaFX project via Maven Archetype.

create JavaFX project

Run the JavaFX application

Note: The following guidance only works for projects managed by Maven.

To run the JavaFX application, you can open the Maven Explorer, expand hellofx > Plugins > javafx and run the Maven goal: javafx:run.

More JavaFX examples

More JavaFX project examples can be found in the openjfx samples repository, which covers different project structures (such as Gradle and unmanaged folder projects). There is documentation on each sample to describe how to run the program.

Develop AWT applications

By default, the types from the Abstract Window Toolkit (AWT) are hidden. You may notice that code completions are not working when you are developing an AWT application. To enable completions, you can open the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)) and then select the command Java: Help Center. Go to the Student section and select Enable AWT Development.

Note: This action will update a setting, java.completion.filteredTypes at the workspace level in .vscode\settings.json, so please make sure a workspace is opened in VS Code.

You can use the sample code below to run a simple Java AWT application in VS Code.

import java.awt.*;
import java.awt.event.*;

public class AwtExample extends Frame {
  public AwtExample() {
    Button btn = new Button("Button");
    btn.setBounds(50, 50, 50, 50);
    add(btn);
    setSize(150, 150);
    setTitle("This is my First AWT example");
    setLayout(new FlowLayout());
    setVisible(true);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            dispose();
        }
    });
  }

  public static void main(String args[]){
    new AwtExample();
  }
}

Develop Swing applications

Swing application development is supported by default. You can directly write your Swing application code without any setup.

You can find more Swing samples in the Oracle Swing documentation.

2/11/2022

In this article there are 3 sectionsIn this article

  • Develop JavaFX applications
  • Develop AWT applications
  • Develop Swing applications
  • Hello from Seattle.
  • Follow @code
  • Support
  • Privacy
  • Manage Cookies
  • Terms of Use
  • License
Microsoft homepage Microsoft homepage © 2022 Microsoft