|
@@ -42,6 +42,12 @@ class Colours extends JPanel
|
|
{
|
|
{
|
|
private Model model;
|
|
private Model model;
|
|
private ArrayList<colourButton> colours;
|
|
private ArrayList<colourButton> colours;
|
|
|
|
+ private JButton chooserButton;
|
|
|
|
+ private JFrame chooserFrame;
|
|
|
|
+ private JPanel chooserPanel;
|
|
|
|
+ private JButton changeButton;
|
|
|
|
+ private JButton confirmButton;
|
|
|
|
+ private JColorChooser colourChooser;
|
|
|
|
|
|
public Colours(Model m)
|
|
public Colours(Model m)
|
|
{
|
|
{
|
|
@@ -57,8 +63,43 @@ class Colours extends JPanel
|
|
colours.add(new colourButton(Color.magenta));
|
|
colours.add(new colourButton(Color.magenta));
|
|
colours.add(new colourButton(Color.orange));
|
|
colours.add(new colourButton(Color.orange));
|
|
colours.add(new colourButton(Color.cyan));
|
|
colours.add(new colourButton(Color.cyan));
|
|
- colours.add(new colourButton(Color.gray));
|
|
|
|
|
|
+ //colours.add(new colourButton(Color.gray));
|
|
|
|
+
|
|
|
|
+ this.changeButton = new JButton();
|
|
|
|
+ changeButton.addActionListener(new ActionListener()
|
|
|
|
+ {
|
|
|
|
+ public void actionPerformed(ActionEvent e)
|
|
|
|
+ {
|
|
|
|
+ chooserFrame.pack();
|
|
|
|
+ chooserFrame.setVisible(true);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ this.chooserFrame = new JFrame("Chooser Window");
|
|
|
|
+ this.colourChooser = new JColorChooser();
|
|
|
|
+ this.confirmButton = new JButton("Select this colour?");
|
|
|
|
+ confirmButton.addActionListener(new ActionListener()
|
|
|
|
+ {
|
|
|
|
+ public void actionPerformed(ActionEvent e)
|
|
|
|
+ {
|
|
|
|
+ changeButton.setBackground(colourChooser.getColor());
|
|
|
|
+ model.changeColour(colourChooser.getColor());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ this.chooserPanel = new JPanel(new FlowLayout());
|
|
|
|
+ chooserFrame.getContentPane().add(chooserPanel);
|
|
|
|
+ chooserPanel.add(colourChooser);
|
|
|
|
+ chooserPanel.add(confirmButton);
|
|
|
|
+ this.add(changeButton);
|
|
|
|
|
|
|
|
+ // create jbutton
|
|
|
|
+// make a new frame
|
|
|
|
+// add action listener to button to pack and set frame visible
|
|
|
|
+// create colour chooser
|
|
|
|
+// create jbutton for confirm dialog
|
|
|
|
+// add action listener for it to change model colour
|
|
|
|
+// make new panel using flow
|
|
|
|
+// add panel to frame
|
|
|
|
+// add chooser and confirm button to panel
|
|
for(colourButton b: colours)
|
|
for(colourButton b: colours)
|
|
{
|
|
{
|
|
this.add(b);
|
|
this.add(b);
|
|
@@ -79,7 +120,6 @@ class colourButton extends JButton
|
|
|
|
|
|
public colourButton(Color c)
|
|
public colourButton(Color c)
|
|
{
|
|
{
|
|
- //this.setPreferredSize(new Dimension(140, 150));
|
|
|
|
this.setBackground(c);
|
|
this.setBackground(c);
|
|
this.setOpaque(true);
|
|
this.setOpaque(true);
|
|
}
|
|
}
|
|
@@ -126,15 +166,12 @@ class previewLine extends JPanel implements Observer
|
|
|
|
|
|
public previewLine(Model m)
|
|
public previewLine(Model m)
|
|
{
|
|
{
|
|
- //this.setMinimumSize(new Dimension(0, 150));
|
|
|
|
this.model = m;
|
|
this.model = m;
|
|
model.addObserver(this);
|
|
model.addObserver(this);
|
|
}
|
|
}
|
|
|
|
|
|
public void update(Object observable)
|
|
public void update(Object observable)
|
|
{
|
|
{
|
|
- //Color temp = model.getColour();
|
|
|
|
- //this.setBackground(new Color(255 - temp.getRed(), 255 - temp.getGreen(), 255 - temp.getBlue()));
|
|
|
|
newBackground();
|
|
newBackground();
|
|
revalidate();
|
|
revalidate();
|
|
repaint();
|
|
repaint();
|
|
@@ -171,3 +208,4 @@ class previewLine extends JPanel implements Observer
|
|
gtemp.drawLine((int)(this.getSize().width*.25), (this.getSize().height/2), (int)(this.getSize().width*.75), (this.getSize().height/2));
|
|
gtemp.drawLine((int)(this.getSize().width*.25), (this.getSize().height/2), (int)(this.getSize().width*.75), (this.getSize().height/2));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|