package myproject;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class Tutorial {
public static void main(String[] args) {
// TODO Auto-generated method stub
JFrame frame = new JFrame("Walter white restaurant");
JPanel panel = new JPanel();
panel.setLayout(null);
JLabel label = new JLabel();
label.setIcon(new ImageIcon("logo.png"));
label.setBounds(30, 5, 220, 200);
JTextField pole2 = new JTextField();
pole2.setBounds(30, 330, 90, 20);
JTextArea pole=new JTextArea("");
pole.setBounds(190, 20, 190, 320);
JButton button = new JButton();
button.setText("add");
button.setBounds(30, 300, 90, 20);
JButton button2 = new JButton();
button2.setText("export");
button2.setBounds(30, 360, 90, 20);
String food[]={"fish","steak","salat","chese"};
final JComboBox cb=new JComboBox(food);
cb.setBounds(30, 200,90,20);
String drinks[]={"beer","wine","Cola","coffe"};
final JComboBox cb2=new JComboBox(drinks);
cb2.setBounds(30, 240,90,20);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String j = pole2.getText();
String ja = pole.getText();
String data = ""
cb.getItemAt(cb.getSelectedIndex()) + " + " + cb2.getItemAt(cb2.getSelectedIndex()) + " (" + j
" Pounds)" ;
pole.setText(ja + data + "\n");
}
});
button2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("/home/me/Documents"));
int retrival = chooser.showSaveDialog(null);
if (retrival == JFileChooser.APPROVE_OPTION) {
try(FileWriter fw = new FileWriter(chooser.getSelectedFile()+".txt")) {
fw.write(pole.getText());
} catch (Exception ex) {
ex.printStackTrace();
}
} }
});
panel.add(cb2);
panel.add(cb);
panel.add(label);
panel.add(button);
panel.add(pole);
panel.add(pole2);
panel.add(button2);
frame.add(panel);
frame.setSize(450, 450);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setBackground(null);
}
}
On this page of the site you can watch the video online Tutorial for java menu with a duration of hours minute second in good quality, which was uploaded by the user IT Janko 22 April 2024, share the link with friends and acquaintances, this video has already been watched 21 times on youtube and it was liked by 0 viewers. Enjoy your viewing!