/**
* @author Scott
* @description
* This class is the jframe of the edit button
*/
package me.scotth0828.main.EditFrame;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import me.scotth0828.main.Window.Window;
import me.scotth0828.main.Window.textareamanagement.textInfo;
public class editFrame extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
textInfo t; // textarea that is selected
private Dimension size = new Dimension(Window.WINDOW_WIDTH, Window.WINDOW_HEIGHT / 2); // window dimensions
private final String Button_BGColor_Text = "Set Background Color", Button_TextColor_Text = "Set Text Color"; // button text
public editFrame(textInfo t) { // constructor
this.t = t;
this.setPreferredSize(size); // WINDOW SIZE
this.setMinimumSize(size);
this.setMaximumSize(size);
this.setResizable(true);
///////
this.setLayout(new GridLayout(10, 1));
JLabel label_bgColor = new JLabel("Background Color"); // buttons and labels created
JLabel label_textColor = new JLabel("Text Color");
JButton Button_BGColor = new JButton();
Button_BGColor.setText(Button_BGColor_Text);
JButton Button_TextColor = new JButton(Button_TextColor_Text);
Button_BGColor.addActionListener(this);
Button_TextColor.addActionListener(this);
this.add(label_bgColor); // button and labels added into jframe
this.add(Button_BGColor);
this.add(label_textColor);
this.add(Button_TextColor);
/////
this.setUndecorated(false);
this.setLocationRelativeTo(null);
this.pack();
this.setFocusable(true);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) { // action event listener for clicks
Color color;
if (e.getActionCommand().equals(Button_BGColor_Text)) { // background color button
color = JColorChooser.showDialog(this, "Choose a background color", Color.WHITE);
t.setBackground(color);
} else if (e.getActionCommand().equals(Button_TextColor_Text)) { // text color button
color = JColorChooser.showDialog(this, "Choose a text color", Color.WHITE);
t.setForeground(color);
}
}
}