The given Java program is called the ColorDialog. When running, the ColorDialog has a menubar and 25 ColorButtons arranged in a 5x5 gird. Each of the 25 ColorButtons has a background color and a label. The ColorButtons have a set of ColorLabel objects to keep track of its current color. The starting values of the 25 ColorButtons are “RED” and the color is, of course, red.  When a ColorButton is clicked with a mouse, its color and label move to the next color in a sequence. The sequence is RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO and VIOLET. The menubar menu has two items: Reset and Save.  Reset puts all the ColorButtons back to RED. The Save menu item...well, does nothing. This is the task to be built for this assignment. The ColorDialog has an associated ColorDialogRecord.       When the ColorDialog Save menu item is selected,       Copy the information of the ColorDialog into the ColorDialogRecord o   The ColorDialogRecord will need a 5x5 array of strings, and a filename. o   Copy the current string from color label from the ColorDialog and its components into ColorDialogRecord. Use getters and setters as needed. o   Create a SAVE member function for ColorDialogRecord and have the save to file done in that Class. o   Save the row, the column, and the color in the file, with one set of button information per line.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

package colordialog;

 

import java.awt.Color;

import java.awt.Graphics;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.GradientPaint;

import javax.swing.JButton;



class ColorButton extends JButton implements ActionListener

{

    int indexColor;

    ColorLabel currColor;

    ColorLabel [] colorArray;

    

    ColorButton()

    {

        colorArray=new ColorLabel[7];

        colorArray[0]=new ColorLabel("RED"   ,new Color(255,  0,  0));//RED

        colorArray[1]=new ColorLabel("ORANGE",new Color(255,128,  0));//ORANGE

        colorArray[2]=new ColorLabel("YELLOW",new Color(255,255,  0));//YELLOW

        colorArray[3]=new ColorLabel("GREEN" ,new Color(  0,255,  0));//GREEN

        colorArray[4]=new ColorLabel("BLUE"  ,new Color(  0,  0,255));//Blue

        colorArray[5]=new ColorLabel("INDIGO",new Color(128,  0,255));//INDIGO

        colorArray[6]=new ColorLabel("VIOLET",new Color(192,  0,192));//PURPLE

        indexColor=0;

               

        currColor=colorArray[indexColor];

        

        setSize(50,50);   

        

        

        this.setForeground(Color.black);

        this.setText(currColor.getLabel());

        this.setBackground(currColor.getColor());

        this.addActionListener(this);

 

        

    }

 

    @Override

    public void actionPerformed(ActionEvent ae) {

        indexColor=(indexColor+1)%7;

        currColor=colorArray[indexColor];

 

           

        invalidate();

    }

    

    

    @Override

    public void paint(Graphics g)

    {

        float x1=0.0f;

        float y1=0.0f;

        Color color1=Color.white;

        float x2=0.0f;

        float y2=0.0f;

        Color color2=Color.black;

        java.awt.GradientPaint gp=new GradientPaint(x1,y1,color1,x2,y2,color2);

        this.setBackground(currColor.getColor());

        this.setText(currColor.getLabel());

        super.paint(g);

 

    }

    

    

    public String getColor()

    {

        return currColor.getLabel();

    }

    

    public void reset()

    {

        indexColor=0;

        currColor=colorArray[indexColor];

        invalidate();

    }

 

}






The given Java program is called the ColorDialog. When running, the ColorDialog has a menubar and 25 ColorButtons arranged in a 5x5 gird.

Each of the 25 ColorButtons has a background color and a label. The ColorButtons have a set of ColorLabel objects to keep track of its current color. The starting values of the 25 ColorButtons are “RED” and the color is, of course, red.  When a ColorButton is clicked with a mouse, its color and label move to the next color in a sequence. The sequence is RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO and VIOLET.

The menubar menu has two items: Reset and Save.  Reset puts all the ColorButtons back to RED. The Save menu item...well, does nothing. This is the task to be built for this assignment.

The ColorDialog has an associated ColorDialogRecord.

  •       When the ColorDialog Save menu item is selected,
  •       Copy the information of the ColorDialog into the ColorDialogRecord

o   The ColorDialogRecord will need a 5x5 array of strings, and a filename.

o   Copy the current string from color label from the ColorDialog and its components into ColorDialogRecord. Use getters and setters as needed.

o   Create a SAVE member function for ColorDialogRecord and have the save to file done in that Class.

o   Save the row, the column, and the color in the file, with one set of button information per line.

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education