You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.5 KiB
47 lines
1.5 KiB
package cmpt213.assignment3.packagedeliveries.view;
|
|
|
|
import javax.swing.*;
|
|
import java.awt.*;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionListener;
|
|
|
|
public class Input {
|
|
JTextField typeLabel;
|
|
public Input(Frame main){
|
|
JPanel p = new JPanel();
|
|
String[] type={"book", "perishable", "electronic"};
|
|
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
|
|
JComboBox<String> packageType=new JComboBox<>(type);
|
|
packageType.setPreferredSize(new Dimension(300, 30));
|
|
packageType.addActionListener(new ActionListener() {
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
String p=(String) packageType.getSelectedItem();
|
|
switch (p){
|
|
case "book":
|
|
typeLabel.setText("author name");
|
|
break;
|
|
case "perishable":
|
|
typeLabel.setText("expiry date");
|
|
break;
|
|
case "electronic":
|
|
typeLabel.setText("handling fee");
|
|
}
|
|
}
|
|
});
|
|
|
|
JPanel name=new JPanel();
|
|
JLabel nameLabel=new JLabel();
|
|
JTextField namefield= new JTextField();
|
|
name.setLayout(new BoxLayout(name, BoxLayout.X_AXIS));
|
|
nameLabel.setText("name:");
|
|
nameLabel.setPreferredSize(new Dimension(50, 25));
|
|
name.add(nameLabel);
|
|
name.add(namefield);
|
|
name.setPreferredSize(new Dimension(200, 50));
|
|
|
|
|
|
}
|
|
|
|
}
|