Commit ec48e71a authored by Neff's avatar Neff
Browse files

folders where deleted back to current state

parent 95d97e7c
Pipeline #10389 passed with stage
in 1 minute and 35 seconds
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-22">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>AngleConverter</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=22
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=22
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=22
import java.awt.*;
import javax.swing.*;
public class AngleDrawer extends JFrame {
private static final long serialVersionUID = 1L; // Empfohlene serialVersionUID
private final JTextField gradField;
private final DrawPanel drawPanel;
public AngleDrawer() {
// Fenster konfigurieren
setTitle("Grad-Anzeige auf Kreis");
setSize(400, 400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(null); // Kein Layout-Manager, manuelle Positionierung
// Eingabefeld und Label
JLabel label = new JLabel("Grad:");
label.setBounds(20, 20, 50, 30); // x, y, Breite, Höhe
add(label);
gradField = new JTextField();
gradField.setBounds(70, 20, 100, 30);
add(gradField);
// Button
JButton drawButton = new JButton("Zeichnen");
drawButton.setBounds(180, 20, 100, 30);
add(drawButton);
// Zeichenbereich
drawPanel = new DrawPanel();
drawPanel.setBounds(20, 70, 350, 280); // Position und Größe des Zeichenbereichs
add(drawPanel);
// Button-Action
drawButton.addActionListener(e -> {
try {
double grad = Double.parseDouble(gradField.getText());
drawPanel.setAngle(grad);
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(this, "Bitte eine gültige Gradzahl eingeben.");
}
});
}
private static class DrawPanel extends JPanel {
private static final long serialVersionUID = 1L; // Empfohlene serialVersionUID
private double angle = 0; // Winkel in Grad
public void setAngle(double angle) {
this.angle = angle % 360; // Winkel auf Bereich [0, 360) reduzieren
repaint(); // Neuzeichnen des Panels anfordern
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
// Panel-Mitte und Radius berechnen
int width = getWidth();
int height = getHeight();
int radius = Math.min(width, height) / 2 - 10;
int centerX = width / 2;
int centerY = height / 2;
// Kreis zeichnen
g.drawOval(centerX - radius, centerY - radius, radius * 2, radius * 2);
// Pfeil berechnen und zeichnen
double radian = Math.toRadians(angle);
int arrowX = centerX + (int) (radius * Math.cos(radian));
int arrowY = centerY - (int) (radius * Math.sin(radian));
g.drawLine(centerX, centerY, arrowX, arrowY);
// Winkel anzeigen
g.drawString("Grad: " + (int) angle, 10, 20);
}
}
public static void main(String[] args) {
// GUI starten
SwingUtilities.invokeLater(() -> {
AngleDrawer frame = new AngleDrawer();
frame.setVisible(true);
});
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment