Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
package client;
import javax.swing.JFrame;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import java.awt.Rectangle;
import javax.swing.JComboBox;
public class grund extends JFrame
{
int a;
int b;
int c;
private ImageIcon imageHelp = new ImageIcon(grund.class.getResource("help.gif"));
private ImageIcon imageClose = new ImageIcon(grund.class.getResource("closefile.gif"));
private ImageIcon imageOpen = new ImageIcon(grund.class.getResource("openfile.gif"));
private JButton buttonHelp = new JButton();
private JButton buttonClose = new JButton();
private JButton buttonOpen = new JButton();
private JToolBar toolBar = new JToolBar();
private JLabel statusBar = new JLabel();
private JMenuItem menuHelpAbout = new JMenuItem();
private JMenu menuHelp = new JMenu();
private JMenuItem menuFileExit = new JMenuItem();
private JMenu menuFile = new JMenu();
private JMenuBar menuBar = new JMenuBar();
private JPanel panelCenter = new JPanel();
private BorderLayout layoutMain = new BorderLayout();
private JTextField feld1 = new JTextField();
private JTextField feld2 = new JTextField();
private JTextField feld3 = new JTextField();
private JButton ergebnis = new JButton();
private JComboBox auswahl = new JComboBox(new Object[]{"+","-","*","/" });
public grund()
{
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
private void jbInit() throws Exception
{
this.setJMenuBar(menuBar);
this.getContentPane().setLayout(layoutMain);
panelCenter.setLayout(null);
feld1.setText("jTextField1");
feld1.setBounds(new Rectangle(30, 35, 195, 30));
feld2.setText("jTextField2");
feld2.setBounds(new Rectangle(30, 80, 200, 30));
feld3.setText("jTextField3");
feld3.setBounds(new Rectangle(30, 185, 205, 25));
ergebnis.setText("Rechnen");
ergebnis.setBounds(new Rectangle(90, 135, 85, 30));
ergebnis.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
ergebnis_actionPerformed(e);
}
});
auswahl.setBounds(new Rectangle(270, 65, 80, 30));
this.setSize(new Dimension(400, 300));
menuFile.setText("File");
menuFileExit.setText("Exit");
menuFileExit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
fileExit_ActionPerformed(ae);
}
});
menuHelp.setText("Help");
menuHelpAbout.setText("About");
menuHelpAbout.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
helpAbout_ActionPerformed(ae);
}
});
statusBar.setText("");
buttonOpen.setToolTipText("Open File");
buttonOpen.setIcon(imageOpen);
buttonClose.setToolTipText("Close File");
buttonClose.setIcon(imageClose);
buttonHelp.setToolTipText("About");
buttonHelp.setIcon(imageHelp);
menuFile.add(menuFileExit);
menuBar.add(menuFile);
menuHelp.add(menuHelpAbout);
menuBar.add(menuHelp);
this.getContentPane().add(statusBar, BorderLayout.SOUTH);
toolBar.add(buttonOpen);
toolBar.add(buttonClose);
toolBar.add(buttonHelp);
this.getContentPane().add(toolBar, BorderLayout.NORTH);
panelCenter.add(auswahl, null);
panelCenter.add(ergebnis, null);
panelCenter.add(feld3, null);
panelCenter.add(feld2, null);
panelCenter.add(feld1, null);
this.getContentPane().add(panelCenter, BorderLayout.CENTER);
}
void fileExit_ActionPerformed(ActionEvent e)
{
System.exit(0);
}
void helpAbout_ActionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(this, new grund_AboutBoxPanel1(), "About", JOptionPane.PLAIN_MESSAGE);
}
private void ergebnis_actionPerformed(ActionEvent e)
{
String s;
a=Integer.parseInt(feld1.getText());
b=Integer.parseInt(feld2.getText());
String op=(String) auswahl.getSelectedItem();
switch(op) {
case '+' : ;
break;
case '-': c = a - b;
break;
case '*': c=a*b;
break;
case '/': c=a/b;
break;
}
s=" "+c;
feld3.setText(s);
}
}
public void cbActionPerformed(ActionEvent evt) {
String s = (String)jComboBox1.getSelectedItem();
if(s.equals("+"))
jTextField1.setText("PLUS");
else if(s.equals("-"))
jTextField1.setText("MINUS");
else if(s.equals("*"))
jTextField1.setText("MAL");
else if(s.equals("/"))
jTextField1.setText("DURCH");
else
jTextField1.setText("ERROR");
}
private void ergebnis_actionPerformed(ActionEvent e)
{
String s;
a=Integer.parseInt(feld1.getText());
b=Integer.parseInt(feld2.getText());
String op=(String) auswahl.getSelectedItem();
if(op.equals("+"))
c=a+b;
else if(op.equals("-"))
c=a-b;
else if(op.equals("*"))
c=a*b;
else if(op.equals("/"))
c=a/b;
s= Integer.toString(c);
//s= ""+c;
feld3.setText(s);
}