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.AbstractAction;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
@@ -506,13 +507,76 @@ public class Display extends JFrame
|
|||||||
|
|
||||||
private JPanel resizecontrol = null;
|
private JPanel resizecontrol = null;
|
||||||
|
|
||||||
public MazeControler(MazeParams params)
|
private void setMazeName(String pName)
|
||||||
{
|
{
|
||||||
super(new BorderLayout());
|
MazeParamsFixed p = (MazeParamsFixed) params;
|
||||||
controlPanel = new JPanel(new BorderLayout());
|
p.setName(pName);
|
||||||
settings = new MazeSettings(params);
|
}
|
||||||
JButton button = new JButton(labels.getString("resolve"));
|
|
||||||
button.addActionListener(new ActionListener()
|
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)
|
public void actionPerformed(ActionEvent evt)
|
||||||
{
|
{
|
||||||
@@ -521,8 +585,40 @@ public class Display extends JFrame
|
|||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
resolveQuitBar.add(resolveButton);
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
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()
|
Action goNorth = new AbstractAction()
|
||||||
{
|
{
|
||||||
public void actionPerformed(ActionEvent evt)
|
public void actionPerformed(ActionEvent evt)
|
||||||
@@ -570,8 +666,7 @@ public class Display extends JFrame
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
JButton south = addDirection(this, labels.getString("south"), "DOWN", goSouth);
|
JButton south = addDirection(this, labels.getString("south"), "DOWN", goSouth);
|
||||||
|
|
||||||
controlPanel.add(button, BorderLayout.CENTER);
|
|
||||||
controlPanel.add(north, BorderLayout.NORTH);
|
controlPanel.add(north, BorderLayout.NORTH);
|
||||||
controlPanel.add(west, BorderLayout.WEST);
|
controlPanel.add(west, BorderLayout.WEST);
|
||||||
controlPanel.add(east, BorderLayout.EAST);
|
controlPanel.add(east, BorderLayout.EAST);
|
||||||
@@ -605,84 +700,17 @@ public class Display extends JFrame
|
|||||||
{
|
{
|
||||||
setAutoSize( autoSlide.isSelected());
|
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 = new JPanel(new FlowLayout());
|
||||||
resizecontrol.add(showAll);
|
resizecontrol.add(showAll);
|
||||||
resizecontrol.add(slider);
|
resizecontrol.add(slider);
|
||||||
resizecontrol.add(autoSlide);
|
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(controlDisplayPanel, BorderLayout.SOUTH);
|
||||||
add(resizecontrol,BorderLayout.WEST);
|
add(resizecontrol,BorderLayout.WEST);
|
||||||
add(settings,BorderLayout.EAST);
|
add(settings,BorderLayout.EAST);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JPanel getMoveControl()
|
private JPanel getMoveControl()
|
||||||
|
|||||||
Reference in New Issue
Block a user