package tests;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
public class myFrame extends JFrame {
public static final long serialVersionUID = 1L;
public JPanel hPanel = null;
public JPanel pLinks = null;
public JButton eButton = null;
public JDesktopPane pRechts = null;
public boolean isInternalFrame = false;
public eFormular eFrm;
public JPanel getHauptPanel() {
if (hPanel == null) {
hPanel = new JPanel();
hPanel.setLayout(new BorderLayout());
hPanel.setBackground(Color.red);
hPanel.add(getpLinks(), BorderLayout.WEST);
hPanel.add(getaPanel(), BorderLayout.CENTER);
}
return hPanel;
}
public JButton getEingabeButton() {
if (eButton == null) {
eButton = new JButton();
eButton = new JButton(new ImageIcon("1.png"));
eButton.setRolloverIcon(new ImageIcon("2.png"));
eButton.setPressedIcon(new ImageIcon("3.png"));
eButton.setBounds(new Rectangle(15, 30, 96, 96));
eButton.setBorderPainted(false);
eButton.setContentAreaFilled(false);
eButton.setFocusPainted(false);
eButton.setText("Eingabe...");
eButton.setVerticalTextPosition(SwingConstants.BOTTOM);
eButton.setHorizontalTextPosition(SwingConstants.CENTER);
eButton.addActionListener(new eFormularAufruf());
}
return eButton;
}
public JPanel getpLinks() {
if (pLinks == null) {
GridBagConstraints gBC_eButton = new GridBagConstraints();
gBC_eButton.gridx = 0;
gBC_eButton.weighty = 0.1;
gBC_eButton.gridy = 0;
pLinks = new JPanel();
pLinks.setLayout(new GridBagLayout());
pLinks.setBackground(new Color(241, 166, 36));
pLinks.setPreferredSize(new Dimension(110, 100));
pLinks.add(getEingabeButton(), gBC_eButton);
}
return pLinks;
}
public JDesktopPane getaPanel() {
if (pRechts == null) {
pRechts = new JDesktopPane();
pRechts.setBackground(new Color(200,200,200));
}
return pRechts;
}
public myFrame() {
super();
initialize();
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
public void initialize() {
setExtendedState(JFrame.MAXIMIZED_BOTH);
this.setContentPane(getHauptPanel());
this.setTitle("myFrame");
this.setSize(new Dimension(1083, 846));
}
class eFormularAufruf implements ActionListener {
public void actionPerformed(ActionEvent e) {
for (int i = 0; i < pRechts.getAllFrames().length
&& !isInternalFrame; i++) {
isInternalFrame = pRechts.getAllFrames()[i] == eFrm;
}
if (!isInternalFrame) {
eFrm = new eFormular();
pRechts.add(eFrm);
eButton.setIcon(new ImageIcon("3.png"));
if (!eFrm.isVisible()) {
eFrm.setVisible(true);
}
}
}
}
class schliessButton implements ActionListener {
public void actionPerformed(ActionEvent e) {
allesSchliessen();
}
}
public void allesSchliessen() {
this.setVisible(false);
this.dispose();
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
myFrame thisClass = new myFrame();
thisClass.setVisible(true);
}
});
}
}