public class CreateFile extends JPanel implements ActionListener
{
static CreateFile cf = new CreateFile();
public CreateFile()
{
initComponents();
}
public void initComponents()
{
//Panels
tabbedPane = new JTabbedPane();
editPanel = new EditPanel();
editPanel.setPreferredSize(new Dimension(1200,1200));
scrollPane=new JScrollPane();
editPanel.setAutoscrolls(true);
scrollPane.setPreferredSize(new Dimension(600,600));
websitePanel = new JPanel();
layoutPanel = new JPanel();
fixFormsPanel = new JPanel();
individualFormsPanel = new JPanel();
//Labels
image_label = new JLabel();
website = new JLabel();
logo = new JLabel();
header = new JLabel();
content = new JLabel();
footer = new JLabel();
tile1 = new JLabel();
tile2 = new JLabel();
tile3 = new JLabel();
baustein = new JLabel();
hinweis = new JLabel();
//ButtonGroup
buttonGroup = new ButtonGroup();
//RadioButtons
onlyborderRect = new JRadioButton();
filledRect = new JRadioButton();
//Textfelder
websiteTextField = new JTextField();
headerWidth = new JTextField();
headerHeight = new JTextField();
contentWidth = new JTextField();
contentHeight = new JTextField();
footerWidth = new JTextField();
footerHeight = new JTextField();
tile1Width = new JTextField();
tile1Height = new JTextField();
tile2Width = new JTextField();
tile2Height = new JTextField();
tile3Width = new JTextField();
tile3Height = new JTextField();
bausteinWidth = new JTextField();
bausteinHeight = new JTextField();
//Buttons
buttonLogoUpload = new JButton();
buttonCreateLayout = new JButton();
buttonFixForms = new JButton();
buttonIndividualForms = new JButton();
buttonGroup.add(onlyborderRect);
onlyborderRect.setText("leer");
onlyborderRect.setForeground(Color.white);
onlyborderRect.addActionListener(this);
buttonGroup.add(filledRect);
filledRect.setText("gefüllt");
filledRect.setSelected(true);
filledRect.setForeground(Color.white);
filledRect.addActionListener(this);
buttonCreateLayout.setText("erstellen");
buttonCreateLayout.addActionListener(this);
buttonFixForms.setText("erstellen");
buttonFixForms.addActionListener(this);
buttonIndividualForms.setText("erstellen");
buttonIndividualForms.addActionListener(this);
buttonLogoUpload.setText("laden..");
buttonLogoUpload.addActionListener(this);
Border titled_border = BorderFactory.createRaisedSoftBevelBorder();
layoutPanel.setBackground(darkGrayPanel);
Border tb_layout = BorderFactory.createTitledBorder(titled_border, "Layout", TitledBorder.LEFT, TitledBorder.TOP,font_border, Color.white);
layoutPanel.setBorder(tb_layout);
GroupLayout layoutPanelLayout = new GroupLayout(layoutPanel);
layoutPanel.setLayout(layoutPanelLayout);
layoutPanelLayout.setHorizontalGroup(
layoutPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(GroupLayout.Alignment.TRAILING, layoutPanelLayout.createSequentialGroup()
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layoutPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addComponent(buttonCreateLayout, GroupLayout.PREFERRED_SIZE, 86, 86)
.addGroup(layoutPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layoutPanelLayout.createSequentialGroup()
.addComponent(header, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(headerWidth, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(headerHeight, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE))
.addGroup(layoutPanelLayout.createSequentialGroup()
.addComponent(content, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(contentWidth, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(contentHeight, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE))
.addGroup(layoutPanelLayout.createSequentialGroup()
.addComponent(footer, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(footerWidth, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(footerHeight, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE))))
.addGap(14, 14, 14))
);
layoutPanelLayout.setVerticalGroup(
layoutPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layoutPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(layoutPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(header, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(headerWidth, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(headerHeight, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layoutPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(content, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(contentWidth, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(contentHeight, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layoutPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(footer, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(footerWidth, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(footerHeight, GroupLayout.PREFERRED_SIZE, 25,GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
.addComponent(buttonCreateLayout, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
fixFormsPanel.setBackground(darkGrayPanel);
Border tb_fix = BorderFactory.createTitledBorder(titled_border, "Feste Plätze", TitledBorder.LEFT, TitledBorder.TOP,font_border, Color.white);
fixFormsPanel.setBorder(tb_fix);
GroupLayout fixFormsPanelLayout = new GroupLayout(fixFormsPanel);
fixFormsPanel.setLayout(fixFormsPanelLayout);
fixFormsPanelLayout.setHorizontalGroup(
fixFormsPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(GroupLayout.Alignment.TRAILING, fixFormsPanelLayout.createSequentialGroup()
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(fixFormsPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addComponent(buttonFixForms, GroupLayout.PREFERRED_SIZE, 86, GroupLayout.PREFERRED_SIZE)
.addGroup(fixFormsPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(fixFormsPanelLayout.createSequentialGroup()
.addComponent(tile1, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tile1Width, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tile1Height, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE))
.addGroup(fixFormsPanelLayout.createSequentialGroup()
.addComponent(tile2, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tile2Width, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tile2Height, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE))
.addGroup(fixFormsPanelLayout.createSequentialGroup()
.addComponent(tile3, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tile3Width, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tile3Height, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE))))
.addGap(14, 14, 14))
);
fixFormsPanelLayout.setVerticalGroup(
fixFormsPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(fixFormsPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(fixFormsPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(tile1, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(tile1Width, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(tile1Height, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(fixFormsPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(tile2, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(tile2Width, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(tile2Height, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(fixFormsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tile3, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(tile3Width, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(tile3Height, GroupLayout.PREFERRED_SIZE, 25,GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
.addComponent(buttonFixForms, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
individualFormsPanel.setBackground(darkGrayPanel);
Border tb_individual = BorderFactory.createTitledBorder(titled_border, "Individuelle Plätze", TitledBorder.LEFT, TitledBorder.TOP,font_border, Color.white);
individualFormsPanel.setBorder(tb_individual);
GroupLayout individualFormsPanelLayout = new GroupLayout(individualFormsPanel);
individualFormsPanel.setLayout(individualFormsPanelLayout);
individualFormsPanelLayout.setHorizontalGroup(
individualFormsPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(individualFormsPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(baustein, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(individualFormsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(onlyborderRect, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(filledRect, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(individualFormsPanelLayout.createSequentialGroup()
.addComponent(bausteinWidth, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(bausteinHeight, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE))
.addComponent(buttonIndividualForms, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(14,14,14))
);
individualFormsPanelLayout.setVerticalGroup(
individualFormsPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(individualFormsPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(individualFormsPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(baustein, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(bausteinWidth, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(bausteinHeight, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
.addGap(16, 16, 16)
.addComponent(onlyborderRect, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(filledRect, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(buttonIndividualForms)
.addContainerGap(33, Short.MAX_VALUE))
);
editPanel.setBackground(lightGrayPanel);
GroupLayout editPanelLayout = new GroupLayout(editPanel);
editPanel.setLayout(editPanelLayout);
editPanelLayout.setHorizontalGroup(
editPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(GUI.imageLabel)
.addComponent(image_label)
.addGap(2,2,2)
);
editPanelLayout.setVerticalGroup(
editPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(GUI.imageLabel)
.addComponent(image_label)
.addGap(2,2,2)
);
websitePanel.setBackground(darkGrayPanel);
Border tb_wesite = BorderFactory.createTitledBorder(titled_border, "Webseite", TitledBorder.LEFT, TitledBorder.TOP,font_border, Color.white);
websitePanel.setBorder(tb_wesite);
GroupLayout websitePanelLayout = new GroupLayout(websitePanel);
websitePanel.setLayout(websitePanelLayout);
websitePanelLayout.setHorizontalGroup(
websitePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(GroupLayout.Alignment.TRAILING, websitePanelLayout.createSequentialGroup()
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(websitePanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addGroup(websitePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(websitePanelLayout.createSequentialGroup()
.addComponent(logo, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonLogoUpload, GroupLayout.PREFERRED_SIZE, 86, GroupLayout.PREFERRED_SIZE))
.addGroup(websitePanelLayout.createSequentialGroup()
.addComponent(website, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(websiteTextField, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE))))
.addGap(14, 14, 14))
);
websitePanelLayout.setVerticalGroup(
websitePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(websitePanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(websitePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(website, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(websiteTextField, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(websitePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(logo, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(buttonLogoUpload, GroupLayout.PREFERRED_SIZE, 30,GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addContainerGap())
);
scrollPane.setViewportView(editPanel);
tabbedPane.addTab("neu", scrollPane);
GroupLayout layout = new GroupLayout(this);
this.setLayout(layout);
this.setBackground(darkGrayPanel);
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE,0, Short.MAX_VALUE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
.addComponent(websitePanel, GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE)
.addComponent(layoutPanel, GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE)
.addComponent(fixFormsPanel, GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE)
.addComponent(individualFormsPanel, GroupLayout.DEFAULT_SIZE,0, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(20 , 20, 20)
.addComponent(websitePanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(layoutPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(fixFormsPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(individualFormsPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addComponent(tabbedPane,GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
}
@Override
public void actionPerformed(ActionEvent object)
{
if (object.getSource() == buttonLogoUpload)
{
JFileChooser fc = new JFileChooser();
fc.setFileFilter(new FileNameExtensionFilter("*.jpg;*.gif","jpg", "gif"));
int state = fc.showOpenDialog(editPanel);
if ( state == JFileChooser.APPROVE_OPTION ){
File file = fc.getSelectedFile();
BufferedImage bi;
try {
bi = ImageIO.read(file);
image_label.setIcon(new ImageIcon(bi));
} catch (IOException e1) {
e1.printStackTrace();
}
}
setVisible(true);
repaint();
}
if (object.getSource() == buttonCreateLayout)
{
cf.headerW = Integer.parseInt(headerWidth.getText()); //Daten auslesen
cf.headerH = Integer.parseInt(headerHeight.getText());
repaint(); //Zeichnen
cf.contentW = Integer.parseInt(contentWidth.getText());
cf.contentH = Integer.parseInt(contentHeight.getText());
repaint();
cf.footerW = Integer.parseInt(footerWidth.getText());
cf.footerH = Integer.parseInt(footerHeight.getText());
repaint();
}
if (object.getSource() == buttonFixForms)
{
cf.tile1W = Integer.parseInt(tile1Width.getText());
cf.tile1H = Integer.parseInt(tile1Height.getText());
repaint();
cf.tile2W = Integer.parseInt(tile2Width.getText());
cf.tile2H = Integer.parseInt(tile2Height.getText());
repaint();
cf.tile3W = Integer.parseInt(tile3Width.getText());
cf.tile3H = Integer.parseInt(tile3Height.getText());
repaint();
}
if (object.getSource() == buttonIndividualForms)
{
cf.bausteinW = Integer.parseInt(bausteinWidth.getText()); //Daten auslesen
cf.bausteinH = Integer.parseInt(bausteinHeight.getText()); //Daten auslesen
repaint();
}
if (object.getSource() == onlyborderRect)
{
repaint();
}
if (object.getSource() == filledRect)
{
repaint();
}
}
//variablen deklarieren
//.... (wird leider sonst zu lang zum posten)
}