change GUI controls layout
group 'Bar' by activity
This commit is contained in:
@@ -30,6 +30,7 @@ import javax.imageio.ImageIO;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JCheckBox;
|
||||
@@ -506,13 +507,76 @@ public class Display extends JFrame
|
||||
|
||||
private JPanel resizecontrol = null;
|
||||
|
||||
public MazeControler(MazeParams params)
|
||||
{
|
||||
super(new BorderLayout());
|
||||
controlPanel = new JPanel(new BorderLayout());
|
||||
settings = new MazeSettings(params);
|
||||
JButton button = new JButton(labels.getString("resolve"));
|
||||
button.addActionListener(new ActionListener()
|
||||
private void setMazeName(String pName)
|
||||
{
|
||||
MazeParamsFixed p = (MazeParamsFixed) params;
|
||||
p.setName(pName);
|
||||
}
|
||||
|
||||
private JPanel createSavingBar()
|
||||
{
|
||||
final JTextField saveName = new JTextField("newlaby ");
|
||||
final JButton savePngButton = new JButton(labels.getString("save") +" png");
|
||||
Action savePngAction = new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
//
|
||||
System.out.println("save png");
|
||||
setMazeName(saveName.getText());
|
||||
savePng();
|
||||
}
|
||||
};
|
||||
savePngButton.addActionListener(savePngAction);
|
||||
final JButton saveSvgButton = new JButton(labels.getString("save") +" svg");
|
||||
Action saveSvgAction = new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
writeSentence("save png");
|
||||
setMazeName(saveName.getText());
|
||||
saveSvg();
|
||||
}
|
||||
};
|
||||
saveSvgButton.addActionListener(saveSvgAction);
|
||||
final JButton saveButton = new JButton(labels.getString("save") +" raw");
|
||||
Action saveAction = new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
//
|
||||
System.out.println("save");
|
||||
setMazeName(saveName.getText());
|
||||
MazeParamsFixed p = (MazeParamsFixed) params;
|
||||
save(p,model);
|
||||
}
|
||||
};
|
||||
saveButton.addActionListener(saveAction);
|
||||
final JButton saveImcButton = new JButton(labels.getString("save") +" imc");
|
||||
Action saveImcAction = new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
//
|
||||
System.out.println("save imc");
|
||||
setMazeName(saveName.getText());
|
||||
saveImc();
|
||||
}
|
||||
};
|
||||
saveImcButton.addActionListener(saveImcAction);
|
||||
|
||||
JPanel savePanel = new JPanel(new FlowLayout());
|
||||
savePanel.add(saveName);
|
||||
savePanel.add(saveSvgButton);
|
||||
savePanel.add(savePngButton);
|
||||
savePanel.add(saveButton);
|
||||
savePanel.add(saveImcButton);
|
||||
|
||||
return savePanel;
|
||||
|
||||
}
|
||||
|
||||
private JPanel createResolveQuitBar()
|
||||
{
|
||||
JPanel resolveQuitBar = new JPanel(new FlowLayout());
|
||||
JButton resolveButton = new JButton(labels.getString("resolve"));
|
||||
resolveButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
@@ -522,7 +586,39 @@ public class Display extends JFrame
|
||||
}
|
||||
});
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
resolveQuitBar.add(resolveButton);
|
||||
|
||||
final JButton quitButton = new JButton(labels.getString("quit"));
|
||||
Action quitAction = new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
//
|
||||
System.out.println("quit");
|
||||
System.exit(0);
|
||||
}
|
||||
};
|
||||
quitButton.addActionListener(quitAction);
|
||||
|
||||
resolveQuitBar.add(quitButton);
|
||||
|
||||
return resolveQuitBar;
|
||||
|
||||
}
|
||||
|
||||
public MazeControler(MazeParams params)
|
||||
{
|
||||
// super(new BorderLayout());
|
||||
super();
|
||||
BoxLayout layout = new BoxLayout(this,BoxLayout.Y_AXIS);
|
||||
setLayout(layout);
|
||||
|
||||
add(createSavingBar());
|
||||
|
||||
add(createResolveQuitBar());
|
||||
|
||||
controlPanel = new JPanel(new BorderLayout());
|
||||
settings = new MazeSettings(params);
|
||||
@SuppressWarnings("serial")
|
||||
Action goNorth = new AbstractAction()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
@@ -571,7 +667,6 @@ public class Display extends JFrame
|
||||
};
|
||||
JButton south = addDirection(this, labels.getString("south"), "DOWN", goSouth);
|
||||
|
||||
controlPanel.add(button, BorderLayout.CENTER);
|
||||
controlPanel.add(north, BorderLayout.NORTH);
|
||||
controlPanel.add(west, BorderLayout.WEST);
|
||||
controlPanel.add(east, BorderLayout.EAST);
|
||||
@@ -606,83 +701,16 @@ public class Display extends JFrame
|
||||
setAutoSize( autoSlide.isSelected());
|
||||
}
|
||||
});
|
||||
final JTextField saveName = new JTextField("newlaby ");
|
||||
final JButton savePngButton = new JButton(labels.getString("save") +" png");
|
||||
Action savePngAction = new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
//
|
||||
System.out.println("save png");
|
||||
savePng();
|
||||
}
|
||||
};
|
||||
savePngButton.addActionListener(savePngAction);
|
||||
final JButton saveSvgButton = new JButton(labels.getString("save") +" svg");
|
||||
Action saveSvgAction = new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
writeSentence("save png");
|
||||
saveSvg();
|
||||
}
|
||||
};
|
||||
saveSvgButton.addActionListener(saveSvgAction);
|
||||
final JButton saveButton = new JButton(labels.getString("save") +" raw");
|
||||
Action saveAction = new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
//
|
||||
System.out.println("save");
|
||||
MazeParamsFixed p = (MazeParamsFixed) params;
|
||||
p.setName(saveName.getText());
|
||||
save(p,model);
|
||||
}
|
||||
};
|
||||
saveButton.addActionListener(saveAction);
|
||||
final JButton saveImcButton = new JButton(labels.getString("save") +" imc");
|
||||
Action saveImcAction = new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
//
|
||||
System.out.println("save imc");
|
||||
/*
|
||||
MazeParamsFixed p = (MazeParamsFixed) params;
|
||||
p.setName(saveName.getText());
|
||||
save(p,model);
|
||||
*/
|
||||
saveImc();
|
||||
}
|
||||
};
|
||||
saveImcButton.addActionListener(saveImcAction);
|
||||
|
||||
final JButton quitButton = new JButton(labels.getString("quit"));
|
||||
Action quitAction = new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
//
|
||||
System.out.println("quit");
|
||||
System.exit(0);
|
||||
}
|
||||
};
|
||||
quitButton.addActionListener(quitAction);
|
||||
|
||||
resizecontrol = new JPanel(new FlowLayout());
|
||||
resizecontrol.add(showAll);
|
||||
resizecontrol.add(slider);
|
||||
resizecontrol.add(autoSlide);
|
||||
|
||||
// todo dedicate a panel for save
|
||||
JPanel savePanel = resizecontrol;
|
||||
savePanel.add(saveName);
|
||||
savePanel.add(saveSvgButton);
|
||||
savePanel.add(savePngButton);
|
||||
savePanel.add(saveButton);
|
||||
savePanel.add(saveImcButton);
|
||||
|
||||
resizecontrol.add(quitButton);
|
||||
|
||||
add(controlDisplayPanel, BorderLayout.SOUTH);
|
||||
add(resizecontrol,BorderLayout.WEST);
|
||||
add(settings,BorderLayout.EAST);
|
||||
|
||||
}
|
||||
|
||||
private JPanel getMoveControl()
|
||||
|
||||
Reference in New Issue
Block a user