This commit is contained in:
Yorick
2015-04-08 14:46:11 +02:00
+65 -10
View File
@@ -1,10 +1,14 @@
package Applicatie;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
@@ -16,25 +20,68 @@ import Objects.DrawObject;
public class WaypointPopup extends JFrame {
private static final long serialVersionUID = 1;
private JLabel title;
public WaypointPopup(DrawObject w, Panel panel)
public WaypointPopup(DrawObject w)
{
super("Artist editscreen!");
super("Edit WayPoint");
Waypoint wp = (Waypoint) w;
setDefaultCloseOperation(HIDE_ON_CLOSE);
JPanel content = new JPanel(new BorderLayout());
JPanel south = new JPanel(new FlowLayout());
JPanel center = new JPanel(new GridLayout(5,2));
JPanel north = new JPanel();
if(wp.getSelf() == 0)
{
title = new JLabel("Edit WayPoint");
}
else
{
title = new JLabel("Edit WayPoint " + wp.getSelf());
}
title.setFont(new Font("Dialog", Font.BOLD, 24));
north.add(title);
content.add(north, BorderLayout.NORTH);
JPanel center = new JPanel(new FlowLayout());
JPanel row1 = new JPanel();
row1.setLayout(new BoxLayout(row1, BoxLayout.Y_AXIS));
JPanel row2 = new JPanel();
row2.setLayout(new BoxLayout(row2, BoxLayout.Y_AXIS));
JPanel south = new JPanel();
content.add(south, BorderLayout.SOUTH);
content.add(center, BorderLayout.CENTER);
center.add(row1);
center.add(row2);
JPanel empty = new JPanel();
empty.add(Box.createRigidArea(new Dimension(0, 20)));
row2.add(empty);
JPanel panel1 = new JPanel();
JLabel name = new JLabel("Waypoint" + wp.getSelf());
JLabel name = new JLabel("Waypoint");
name.setFont(new Font("Dialog", Font.PLAIN, 20));
panel1.add(name);
center.add(panel1);
row1.add(panel1);
JTextField tf = new JTextField(5);
center.add(tf);
JTextField tf = new JTextField(10);
row2.add(tf);
JPanel panel2 = new JPanel();
JLabel options = new JLabel("Options");
options.setFont(new Font("Dialog", Font.PLAIN, 20));
panel2.add(options);
row1.add(panel2);
JPanel empty2 = new JPanel();
empty2.add(Box.createRigidArea(new Dimension(0, 5)));
row2.add(empty2);
JTextField tx = new JTextField(8);
row2.add(tx);
JPanel help = new JPanel();
JLabel example = new JLabel("example: '1-2-3'");
example.setFont(new Font("Dialog", Font.PLAIN, 12));
help.add(example);
row2.add(help);
JButton edit = new JButton("Done");
edit.addActionListener(new ActionListener()
@@ -44,15 +91,23 @@ public class WaypointPopup extends JFrame {
public void actionPerformed(ActionEvent e)
{
wp.setSelf(Integer.valueOf(tf.getText()));
panel.addWaypoint(wp);
dispose();
String options[] = tx.getText().split("-");
int ioptions[] = new int[options.length];
for(int i = 0; i < options.length; i++)
{
ioptions[i] = Integer.valueOf(options[i]);
System.out.println(ioptions[i]);
}
wp.setOptions(ioptions);
}
});
south.add(edit);
setContentPane(content);
setVisible(true);
setSize(500,320);
setSize(300,250);
}
}