Hallo,
ich wollte ein banales Programm zur Berechnung von Kreisen schreiben. Jedoch hab ich ein kleines Problem. hier kommt der Quelltext.
Bei folgender Stelle:
Sagt mir Eclipse
"the Methode getAlphaFrame() from the type gui is never used locally"
Weiterhin bekomm ich es auch nicht gestarted, was zum einen aus zuvor geschilderten Problem resultiert.
Kann mir jemand helfen
?
Danke
Peter
ich wollte ein banales Programm zur Berechnung von Kreisen schreiben. Jedoch hab ich ein kleines Problem. hier kommt der Quelltext.
Code:
import javax.swing.JFrame;
import javax.swing.JPanel;
//import java.awt.Component;
import javax.swing.JTextField;
import javax.swing.JLabel;
//import java.awt.BorderLayout;
import javax.swing.JButton;
public class gui {
// TODO Auto-generated method stub
/**
* This method initializes Out_Durchmesser
*
* @return javax.swing.JTextField
*/
private JTextField getOut_Durchmesser() {
if (Out_Durchmesser == null) {
Out_Durchmesser = new JTextField();
Out_Durchmesser.setBounds(new java.awt.Rectangle(15,95,80,15));
}
return Out_Durchmesser;
}
/**
* This method initializes Out_Umfan
*
* @return javax.swing.JTextField
*/
private JTextField getOut_Umfang() {
if (Out_Umfang == null) {
Out_Umfang = new JTextField();
Out_Umfang.setBounds(new java.awt.Rectangle(110,95,80,15));
}
return Out_Umfang;
}
/**
* This method initializes Out_Flaeche
*
* @return javax.swing.JTextField
*/
private JTextField getOut_Flaeche() {
if (Out_Flaeche == null) {
Out_Flaeche = new JTextField();
Out_Flaeche.setBounds(new java.awt.Rectangle(195,95,80,15));
}
return Out_Flaeche;
}
private JFrame AlphaFrame = null; // @jve:decl-index=0:visual-constraint="174,78"
private JPanel AplhaFrame = null;
private JLabel Title_Radius = null;
private JTextField In_Radius = null;
private JButton Btn_calc = null;
private JLabel Title_Durchmesser = null;
private JTextField Out_Durchmesser = null;
private JLabel Title_Umfang = null;
private JTextField Out_Umfang = null;
private JLabel Title_Flaeche = null;
private JTextField Out_Flaeche = null;
/**
* This method initializes AlphaFrame
*
* @return javax.swing.JFrame
*/
private JFrame getAlphaFrame() {
if (AlphaFrame == null) {
AlphaFrame = new JFrame();
AlphaFrame.setSize(new java.awt.Dimension(300,161));
AlphaFrame.setPreferredSize(new java.awt.Dimension(400,250));
AlphaFrame.setContentPane(getAplhaFrame());
AlphaFrame.setTitle("Kreisberechung");
}
return AlphaFrame;
}
/**
* This method initializes AplhaFrame
*
* @return javax.swing.JPanel
*/
private JPanel getAplhaFrame() {
if (AplhaFrame == null) {
Title_Umfang = new JLabel();
Title_Umfang.setBounds(new java.awt.Rectangle(110,80,80,15));
Title_Umfang.setText("Umfang");
Title_Flaeche = new JLabel();
Title_Flaeche.setBounds(new java.awt.Rectangle(195,80,80,15));
Title_Flaeche.setText("Fläche");
Title_Durchmesser = new JLabel();
Title_Durchmesser.setBounds(new java.awt.Rectangle(15,80,80,15));
Title_Durchmesser.setText("Durchmesser");
Title_Radius = new JLabel();
Title_Radius.setBounds(new java.awt.Rectangle(115,15,80,15));
Title_Radius.setToolTipText("Please insert Radius");
Title_Radius.setText("Radius");
AplhaFrame = new JPanel();
AplhaFrame.setLayout(null);
AplhaFrame.setPreferredSize(new java.awt.Dimension(400,250));
AplhaFrame.add(Title_Radius, null);
AplhaFrame.add(getIn_Radius(), null);
AplhaFrame.add(getBtn_calc(), null);
AplhaFrame.add(Title_Durchmesser, null);
AplhaFrame.add(getOut_Durchmesser(), null);
AplhaFrame.add(Title_Umfang, null);
AplhaFrame.add(getOut_Umfang(), null);
AplhaFrame.add(Title_Flaeche, null);
AplhaFrame.add(getOut_Flaeche(), null);
}
return AplhaFrame;
}
/**
* This method initializes In_Radius
*
* @return javax.swing.JTextField
*/
private JTextField getIn_Radius() {
if (In_Radius == null) {
In_Radius = new JTextField();
In_Radius.setBounds(new java.awt.Rectangle(115,30,80,15));
In_Radius.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
}
});
}
return In_Radius;
}
/**
* This method initializes Btn_calc
*
* @return javax.swing.JButton
*/
private JButton getBtn_calc() {
if (Btn_calc == null) {
Btn_calc = new JButton();
Btn_calc.setBounds(new java.awt.Rectangle(105,50,100,15));
Btn_calc.setText("berechne");
Btn_calc.setToolTipText("Click to calculate");
Btn_calc.setName("berechne");
Btn_calc.setSelected(true);
Btn_calc.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
int rad = new Integer(In_Radius.getText()).intValue();
int drm = rad*2;
String sdrm = String.valueOf(drm);
Out_Durchmesser.setText(sdrm);
double umf = drm*Math.PI;
String sumf = String.valueOf(umf);
Out_Umfang.setText(sumf);
double area = drm*drm*Math.PI;
String sarea = String.valueOf(area);
Out_Flaeche.setText(sarea);
}
});
}
return Btn_calc;
}
public static void main(String[] args) {
JFrame test2 = new JFrame();
}
}
Bei folgender Stelle:
Code:
private JFrame getAlphaFrame() {
if (AlphaFrame == null) {
AlphaFrame = new JFrame();
AlphaFrame.setSize(new java.awt.Dimension(300,161));
AlphaFrame.setPreferredSize(new java.awt.Dimension(400,250));
AlphaFrame.setContentPane(getAplhaFrame());
AlphaFrame.setTitle("Kreisberechung");
}
return AlphaFrame;
Sagt mir Eclipse
"the Methode getAlphaFrame() from the type gui is never used locally"
Weiterhin bekomm ich es auch nicht gestarted, was zum einen aus zuvor geschilderten Problem resultiert.
Kann mir jemand helfen
Danke
Peter