Команда «Java: запустить код» отсутствует vscodeJAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Команда «Java: запустить код» отсутствует vscode

Сообщение Anonymous »

Я новичок в Java и работал над простым приложением Java, которое создает простое приложение с графическим интерфейсом пользователя с полем ввода текста, кнопкой и меткой вывода. При нажатии кнопки отображается приветственное сообщение на основе ввода пользователя.
Код:

Код: Выделить всё

package com.example.inputoutputgui;

import java.awt.FlowLayout;      //Imports classes for creating graphical user interfaces (GUIs).
import java.awt.event.ActionEvent;        //Provides classes for creating and managing graphical user interface components.
import java.awt.event.ActionListener; //Provides interfaces for handling events, such as button clicks.

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

//Class Declaration
//----------------------------------------
//InputOutputGUI: The name of the class.
//extends JFrame: Inherits from the JFrame class, which is the base class for creating window-based applications
//implements ActionListener: Implements the ActionListener interface to handle button click events.
public class InputOutputGUI extends JFrame implements ActionListener {
private JTextField inputTextField;  //Class Variable: A text field for user input.
private JButton generateButton;    //Class Variable: A button to trigger the generation of output.
private JLabel outputLabel;    //Class Variable: Provides interfaces for handling events, such as button clicks.

//Constructor
public InputOutputGUI() {
super("Generate hello message including your name");   //Sets the title of the window.
setLayout(new FlowLayout());  //Sets the layout manager for the window to FlowLayout, which arranges components horizontally.

//Component Creation and Initialization
//Creates instances of JTextField, JButton, and JLabel.
inputTextField = new JTextField(20);
generateButton = new JButton("Generate");  ////Sets the text of the button to "Generate".
outputLabel = new JLabel();
//Adds an action listener to the button, which will call the actionPerformed method when the button is clicked.
generateButton.addActionListener(this);
//Adding Components to the Frame
//Adds the text field, button, and label to the frame.
add(inputTextField);
add(generateButton);
add(outputLabel);

//Frame Configuration
setSize(300, 150);   //Sets the size of the frame.
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  //Specifies that the application should exit when the frame is closed.
setVisible(true);    //Makes the frame visible.
}

//Action Listener Method
//This method is called when the button is clicked.
//Gets the text from the input text field.
//Sets the text of the output label to a greeting message including the input text.
public void actionPerformed(ActionEvent e) {
String input = inputTextField.getText();
outputLabel.setText("Hello, " + input + "!");
}

//Main Method
//Creates an instance of the InputOutputGUI class, which starts the application.
public static void main(String[] args) {
new InputOutputGUI();
}
}
Структура папок:

Код: Выделить всё

Hello-App/
src/
main/
java/
com/
example/
InputOutputGUI/
InputOutputGUI.java
когда мне нужно запустить код запуска Java
я не нашел его
Изображение

JDK установлен
Пакет расширений Java установлен
Изображение

Домашняя страница Java:
Изображение


Подробнее здесь: https://stackoverflow.com/questions/788 ... ing-vscode
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»