-1
距離を変換する方法を構築する必要があります。例えば、kmをマイルに変換し、その逆もあります。私はkmをマイルに変換する方法を知っていますが、複数のメソッドを記述しないようにして、コードがあまりにも多くなるようにしています。コンバータGUI(距離変換器)を実行する方法がありません
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class Parametri
extends JFrame {
/** Konstruktor Parametri**/
public Parametri() {
super("Menyra 1");
// setTitle ("Menyra 1")-ky funksion eshte kryer nga super("Menyra 1");
this.setSize(260, 300);
this.setVisible(true);
JLabel label1 = new JLabel("Konvertimi i njesive");
JLabel label2 = new JLabel("Lloj i konvertimit");
// JComboBox
JComboBox lloj1 = new JComboBox();
lloj1.addItem("Gjatesi");
lloj1.addItem("Gjeresi");
lloj1.addItem("Lartesi");
lloj1.addItem("Trashesi");
JLabel label5 = new JLabel("Vendosni vleren qe doni te konvertoni");
JTextField input = new JTextField(10);// 10-gjatesia e fushes por jo numri i karaktereve
JLabel label6 = new JLabel("Nga:");
JComboBox llojA = new JComboBox();
llojA.addItem("Meter (M)");
llojA.addItem("Kilometer (KM)");
llojA.addItem("Centimeter (CM)");
llojA.addItem("Milimeter(MM)");
llojA.addItem("Inch (Inch)");
llojA.addItem("Milje (Milje)");
JLabel label3 = new JLabel("Konvertuar ne:");
JComboBox llojB = new JComboBox();
llojB.addItem("Meter (M)");
llojB.addItem("Kilometer (KM)");
llojB.addItem("Centimeter (CM)");
llojB.addItem("Milimeter(MM)");
llojB.addItem("Inch (Inch)");
llojB.addItem("Milje (Milje)");
JButton button3 = new JButton("Konverto");
JLabel label4 = new JLabel("Vlera e konvertuar");
JTextField output = new JTextField(10);// 10-gjatesia e fushes por jo numri i karaktereve
JButton button2 = new JButton("Fshij");
Container c = this.getContentPane();
c.setLayout(new FlowLayout());
c.setBackground(Color.orange);
c.add(label1);
c.add(label2);
c.add(lloj1);
c.add(label5);
c.add(input);
c.add(label6);
c.add(llojA);
c.add(label3);
c.add(llojB);
c.add(button3);
c.add(label4);
c.add(output);
c.add(button2);
label1.setForeground(Color.blue);
button2.setBackground(Color.black);
button2.setForeground(Color.red);
button3.setBackground(Color.black);
button3.setForeground(Color.red);
this.setContentPane(c);
}
public static void main(String[] args) {
Parametri m1 = new Parametri();
}
}
私は実際にあなたが何を言っているかを削除するには分からない – Albanian