package SongBook;
import Bible.*;
public class LivingHymns extends JFrame implements ActionListener,
ItemListener, MenuListener, Printable, Serializable {
int[] pageBreaks;
Point b, aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, ll, mm, nn, oo, pp, qq, rr, ss,tt,uu,vv,ww,xx,yy,zz;
String[] textLines;
Cursor cursor;
JFrame aFrame;
JLabel imageLabel;
JFileChooser chooser;
JLabel hayField, cottonField, wheatField;
JMenu menu, menu2, helpMenu;
// ProgramMenuBar bar;
DefaultStyledDocument document;
JTextArea area;
Polygon polygon;
JCheckBox box;
String[] songsChosen;
JComboBox songs, fonts, colors;
JScrollPane scrolls, scrolls2;
JMenuItem clear, clearSelection;
MenuItem clear2, clearSelection2;
String[] songNames;
String[] fontTypes;
Integer[] fontSizes;
boolean printNow;
JMenuItem openHelpMenu;
JLabel songChooserLabel;
JLabel songChoice;
JMenuItem selectAll;
JLabel clickOnMe;
JLabel cornField;
JLabel riceField;
Scanner input;
JMenuBar mBar;
PrinterJob job;
PageFormat format;
FileDialog saveDialog, loadDialog;
FileSystemView view;
JFrame saveFrame, openFrame;
FileWriter writer;
JarFile jar;
FileOutputStream river;
FileReader reader;
JEditorPane editor;
JTextField find, replace;
ProgressMonitor monitor;
JButton replace2;
JButton songChooserClassButton;
JMenu applications;
JMenuItem DataBaseMenuItem, SongChooserClassMenuItem, SongChooserNotepadMenuItem;
JSongChooser.Song[] s;
JMenu date;
private class JHorsePane extends JFrame
{
JLabel[] horses;
JPanel panel;
MyJMenuBar mjmb;
private class JHorseDictionary extends JFrame
{
JTextArea definitions;
JList list;
JTextField search;
JPanel panel;
public JHorseDictionary()
{
setTitle("Dictionary of horses");
setSize(200,200);
Dimension d = new Dimension(200,200);
setMaximumSize(d);
setMinimumSize(d);
panel = new JPanel();
}
}
public JHorsePane()
{
mjmb = new MyJMenuBar();
setJMenuBar(mjmb);
}
}
// inner class
private class SongChooserNotepad extends JFrame{
JPanel panel;
JTextPane tPane;
JScrollPane pane, pane2, pane3;
JMenuBar bar;
JMenu file, edit, helpMenu;
JMenuItem exit, copy, cut, paste, clear, selectAll, help;
JButton exitNotepad;
JPopupMenu sodaPop;
JLabel clickableLabel;
JTextArea area;
public SongChooserNotepad()
{
setTitle("Notepad");
panel = new JPanel();
sodaPop = new JPopupMenu("Choose a text color");
clickableLabel = new JLabel("Click me to change text color.");
tPane = new JTextPane();
exitNotepad = new JButton("Exit Notepad");
pane = new JScrollPane(tPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
pane2 = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
area = new JTextArea(300,300);
pane3 = new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
setBackground(Color.ORANGE);
setContentPane(pane2);
}
}
private class JSongChooser extends JFrame
{
TreeNode t;
TreeSet<String> t2;
private TreeMap m;
TreeSet<Object> t3;
JButton b;
JPanel panel;
JScrollPane pane;
private class Genre
{
private Song[] songs;
private String name;
private String description;
private int numOfSongs;
private ArrayList<Song> sList;
public Genre(Song[] songs, String name, String description, int numOfSongs )
{
songs = this.songs;
name = this.name;
setName(name);
description = this.description;
setDescription(description);
numOfSongs = this.numOfSongs;
setNumOfSongs(numOfSongs);
sList = new ArrayList<Song>();
}
public String getName()
{
return name;
}
public void setName(String name2)
{
name = name2;
}
public void setDescription(String description2)
{
description = description2;
}
public String getDescription()
{
return description;
}
public void setNumOfSongs(int numOfSongs2)
{
numOfSongs = numOfSongs2;
}
public int getNumOfSongs()
{
return numOfSongs;
}
public void add(Song song)
{
sList.add(song);
}
public String toString()
{
String str = "This genre is " + getName() + ". It has " + getNumOfSongs() + " songs. It's description is: " + getDescription() + ". It has songs ";
ArrayList<String> aList = new ArrayList<String>();
for (int i = 0; i < getNumOfSongs(); i++)
{
aList.add(sList.get(0).toString());
}
String str2 = aList.toString();
String str3 = str + str2 + ".";
return str3;
}
}
public class Song
{
private String name;
private String author;
private int pageNumber;
public Song(String name, String author, int pageNumber)
{
name = this.name;
author = this.author;
pageNumber = this.pageNumber;
setName(name);
setAuthor(author);
setPageNumber(pageNumber);
}
public String getName()
{
return name;
}
public String getAuthor()
{
return author;
}
public int getPageNumber()
{
return pageNumber;
}
public void setName(String name2)
{
name = name2;
}
public void setPageNumber(int pageNumber2)
{
pageNumber = pageNumber2;
}
public void setAuthor(String author2)
{
author = author2;
}
public String toString()
{
String str = "The name of this song is " + getName() + "." + "/n" + "The author of this song is " + getAuthor() + "." + "/n" + getName() + " is on page number" + getPageNumber() + ".";
return str;
}
public void sortByName(Song[] s)
{
}
}
public JSongChooser()
{
panel = new JPanel();
panel.setBackground(Color.BLUE);
pane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
setVisible(true);
t3 = new TreeSet<Object>();
b = new JButton("Button");
b.setVisible(true);
String str = "Song 1";
String str2 = "Song 2";
t2 = new TreeSet<String>();
panel.setVisible(true);
panel.add(b);
setTitle("Song Chooser Menu");
getContentPane().add(pane);
t2.add(str);
t2.add(str2);
System.out.println(t2.toString());
System.out.println(t3.toString());
}
}
/**
* @param arg0
*/
/**
* @throws IOException
*
*/
public LivingHymns() throws IOException {
setTitle("Living Hymns Song Selection for Shooting Park Road Baptist Church");
applications = new JMenu("Applications");
SongChooserClassMenuItem = new JMenuItem("Song Chooser Application");
s = new JSongChooser.Song[835];
wenguinFrame = new JFrame();
fontSizes = new Integer[100];
find = new JTextField(30);
replace = new JTextField(30);
editor = new JEditorPane();
monitorFrame = new JFrame("Progress of Task");
monitor = new ProgressMonitor(monitorFrame, "Progress", "Message", 50, 100);
// songChooserClassButton = new JButton("Song Chooser Menu");
SongChooserClassMenuItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
MyJMenuBar mb2 = new MyJMenuBar();
JSongChooser cho = new JSongChooser();
cho.setJMenuBar(mb2);
cho.t2.toString();
cho.t3.toString();
}});
for (int p =0; p < fontSizes.length; p++)
{
fontSizes[p] = p+1;
System.out.println(fontSizes[p]);
}
fontSizeSelector = new JComboBox(fontSizes);
plain = new JRadioButton("Plain");
bold = new JRadioButton("Bold");
italic = new JRadioButton("Italic");
boldItalic = new JRadioButton("Bold+Italic");
styleGroup = new ButtonGroup();
styleGroup.add(plain);
styleGroup.add(bold);
styleGroup.add(italic);
styleGroup.add(boldItalic);
saveDialog = new FileDialog(wenguinFrame, "Save", FileDialog.SAVE);
openHelpMenu = new JMenuItem("Open Help Menu");
elFrame = new JFrame();
beanField = new JTextField(5);
spiceField = new JLabel("Red value: ");
spiceField.setToolTipText("The amount of red in Red, Green, Blue color-configuration for color for background of text area.");
grainField = new JLabel("Green value: ");
grainField.setToolTipText("The amount of green in Red, Green, Blue color-configuration for color for background of text area.");
battleField = new JLabel("Blue value: ");
battleField.setToolTipText("The amount of blue in Red, Green, Blue color-configuration for color for background of text area.");
mineField = new JLabel("Alpha value:");
mineField.setToolTipText("The amount of alpha in Red, Green, Blue, Alpha color-configuration for color for background of text area.");
jalapenoField = new JLabel("Red Value: ");
jalapenoField.setToolTipText("The amount of red in Red, Green, Blue color-configuration for color for text color in text area.");
forceField = new JLabel("Green Value: ");
forceField.setToolTipText("The amount of green in Red, Green, Blue color-configuration for color for text color in text area.");
tobaccoField = new JLabel("Blue Value: ");
tobaccoField.setToolTipText("The amount of blue in Red, Green, Blue color-configuration for color for text color in text area.");
tomatoField = new JLabel("Alpha Value: ");
tomatoField.setToolTipText("The amount of alpha in Red, Green, Blue, Alpha color-configuration for color for text color in text area.");
saveFrame = new JFrame();
openFrame = new JFrame();
aFrame = new JFrame();
copy2 = new MenuItem("Copy");
cut2 = new MenuItem("Cut");
paste2 = new MenuItem("Paste");
selectAll2 = new MenuItem("Select all");
th = new TransferHandler("paste");
redAdjuster2 = new JScrollBar(JScrollBar.HORIZONTAL, 0, 0, 0, 255);
redAdjuster2.setToolTipText("Click here to change amount of red in Red, Green, Blue color-configuration for background color of text area");
greenAdjuster2 = new JScrollBar(JScrollBar.HORIZONTAL, 0, 0, 0, 255);
greenAdjuster2.setToolTipText("Click here to change amount of green in Red, Green, Blue color-configuration for background color of text area.");
blueAdjuster2 = new JScrollBar(JScrollBar.HORIZONTAL, 0, 0, 0, 255);
blueAdjuster2.setToolTipText("Click here to change amount of blue in Red, Green, Blue color-configuration for background color of text area.");
alphaAdjuster2 = new JScrollBar(JScrollBar.HORIZONTAL, 0, 0, 0, 255);
alphaAdjuster2.setToolTipText("Click here to change amount of alpha in Red, Green, Blue, Alpha color-configuration for background color of text area.");
redAdjuster3 = new JScrollBar(JScrollBar.HORIZONTAL, 0, 0, 0, 255);
redAdjuster3.setToolTipText("Click here to change amount of red in Red, Green, Blue color-configuration for color of words in text area.");
greenAdjuster3 = new JScrollBar(JScrollBar.HORIZONTAL, 0, 0, 0, 255);
greenAdjuster3.setToolTipText("Click here to change amount of green in Red, Green, Blue color-configuration for color of words in text area.");
blueAdjuster3 = new JScrollBar(JScrollBar.HORIZONTAL, 0, 0, 0, 255);
blueAdjuster3.setToolTipText("Click here to change amount of blue in Red, Green, Blue color-configuration for color of words in text area.");
alphaAdjuster3 = new JScrollBar(JScrollBar.HORIZONTAL, 0, 0, 0, 255);
alphaAdjuster3.setToolTipText("Click here to change amount of alpha in Red, Green, Blue, Alpha color-configuration for color of words in text area.");
redAdjuster = new JScrollBar(JScrollBar.HORIZONTAL, 0,0,0, 255);
redAdjuster.setToolTipText("Click here to change amount of red in Red, Green, Blue color-configuration for background color");
greenAdjuster = new JScrollBar(JScrollBar.HORIZONTAL, 0, 0, 0, 255);
greenAdjuster.setToolTipText("Click here to change amount of green in Red, Green, Blue color-configuration for background color");
blueAdjuster = new JScrollBar(JScrollBar.HORIZONTAL, 0, 0, 0, 255);
blueAdjuster.setToolTipText("Click here to change amount of blue in Red, Green, Blue color-configuration for background color");
alphaAdjuster = new JScrollBar(JScrollBar.HORIZONTAL, 0, 0, 0, 255);
alphaAdjuster.setToolTipText("Click here to change amount of alpha in Red, Green, Blue, Alpha color-configuration for background color");
cottonField = new JLabel("Blue: 0");
cottonField.setToolTipText("Blue value");
wheatField = new JLabel("Green: 0");
wheatField.setToolTipText("Green value");
riceField = new JLabel("Alpha: 0");
riceField.setToolTipText("Alpha, don't ask what alpha is, I don't know, value");
Aharoni = new Font("Aharoni", Font.BOLD + Font.ITALIC, 41);
Andalus = new Font("Andalus", Font.BOLD + Font.ITALIC, 41);
AngsanaNew = new Font("Angsana New", Font.BOLD + Font.ITALIC, 41);
scratchpad = new String("");
popup = new PopupMenu("Edit");
lollipop = new JPopupMenu("Help Menu");
button = new JMenuItem("Setting the Background Color");
button2 = new JMenuItem("Setting The Color of The Text Areas");
button3 = new JMenuItem("Selecting Fonts and Font Sizes and Font Styles");
button4 = new JMenuItem("Setting the Color of The Text");
button5 = new JMenuItem("Getting Songs from List or Getting Song By Entering Page Numbers");
button6 = new JMenuItem("Exit Menu");
cornField = new JLabel(" " + lollipop.getLabel());
cornField.setBackground(green);
cornField.setForeground(blue);
hayField = new JLabel("Red: 0");
hayField.setToolTipText("Red Value");
lollipop.add(cornField);
lollipop.addSeparator();
lollipop.add(button);
lollipop.addSeparator();
lollipop.add(button2);
lollipop.addSeparator();
lollipop.add(button3);
lollipop.addSeparator();
lollipop.add(button4);
lollipop.addSeparator();
lollipop.add(button5);
lollipop.addSeparator();
lollipop.add(button6);
save = new JMenuItem("Save");
menu2 = new JMenu("Edit");
helpMenu = new JMenu("Help Menu");
// menu.setBackground(Color.GREEN);
menu2.setBackground(Color.GREEN);
helpMenu.setBackground(Color.GREEN);
selectAll = new JMenuItem("Select all");
copy = new JMenuItem("Copy");
menu2.add(selectAll);
menu2.addSeparator();
menu2.add(copy);
document = new DefaultStyledDocument();
frame2 = new JFrame();
colorSelector = new String[15];
colorSelector[0] = "Red";
colorSelector[1] = "Green";
colorSelector[2] = "Blue";
colorSelector[3] = "Orange";
colorSelector[4] = "Yellow";
colorSelector[5] = "Pink";
colorSelector[6] = "Black";
colorSelector[7] = "Gray";
colorSelector[8] = "Light Gray";
colorSelector[9] = "Dark Gray";
colorSelector[10] = "Magenta";
colorSelector[11] = "Cyan";
colorSelector[12] = "White";
colorSelector[13] = "Purple";
colorSelector[14] = "Brown";
colors = new JComboBox(colorSelector);
fontTypes = new String[174];
fontTypes[0] = "Aharoni";
fontTypes[1] = "Andalus";
fontTypes[2] = "Angsana New";
fontTypes[3] = "AngsanaUPC";
fonts = new JComboBox(fontTypes);
fonts.setBackground(green);
redAdjuster.setBackground(red);
greenAdjuster.setBackground(green);
blueAdjuster.setBackground(blue);
alphaAdjuster.setBackground(green);
clear = new JMenuItem("Clear");
clear.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e)
{
// clears text
area.setText("");
}
});
clear2 = new MenuItem("Clear");
clear2.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e)
{
area.setText("");
}
});
pBar = new JProgressBar();
pageNumber = new JTextField(3);
pageNum = new JLabel("Enter page number");
panel = new JPanel();
monitor.setProgress(1);
panel.add(pBar);
pBar.setVisible(true);
pBar.setValue(0);
pBar.setBackground(green);
pBar.setForeground(green);
replace2 = new JButton("Replace");
about = new JMenuItem("About");
helpMenu.add(openHelpMenu);
helpMenu.addSeparator();
helpMenu.add(about);
menu = new JMenu("File");
exit = new JMenuItem("Exit");
load = new JMenuItem("Load");
menu.add(save);
menu.addSeparator();
menu.add(load);
mBar = new JMenuBar();
mBar.add(menu);
mBar.add(menu2);
mBar.add(helpMenu);
mBar.setVisible(true);
menu.setBackground(Color.GREEN);
mBar.setBackground(Color.GREEN);
// bar.init();
panel.add(mBar);
setJMenuBar(mBar);
print = new JMenuItem("Print");
menu.addSeparator();
menu.add(print);
menu.addSeparator();
menu.add(exit);
printNow = false;
mBar.add(applications);
print.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
printNow = true;
job = PrinterJob.getPrinterJob();
try {
job.setPrintable(new LivingHymns());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
format = job.pageDialog(job.defaultPage());
doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException e) {
/* The job did not successfully complete */
}
}
}
});
panel.add(hayField);
hayField.setVisible(true);
panel.add(redAdjuster);
redAdjuster.setVisible(true);
panel.add(wheatField);
wheatField.setVisible(true);
panel.add(greenAdjuster);
greenAdjuster.setVisible(true);
panel.add(cottonField);
cottonField.setVisible(true);
panel.add(blueAdjuster);
blueAdjuster.setVisible(true);
panel.add(riceField);
riceField.setVisible(true);
panel.add(alphaAdjuster);
alphaAdjuster.setVisible(true);
panel.add(beanField);
beanField.setVisible(false);
panel.add(fonts);
fonts.setToolTipText("Choose a font.");
panel.add(fontSizeSelector);
fontSizeSelector.setToolTipText("Choose a font size.");
panel.add(popup);
panel.setVisible(true);
pageNum.setVisible(true);
pageNumber.setVisible(true);
panel.add(pageNum);
panel.add(pageNumber);
panel.add(lollipop);
panel.add(plain);
plain.setBackground(panel.getBackground());
panel.add(bold);
bold.setBackground(panel.getBackground());
panel.add(italic);
italic.setBackground(panel.getBackground());
panel.add(boldItalic);
boldItalic.setBackground(panel.getBackground());
System.out.println(lollipop.getLabel());
lollipop.setLightWeightPopupEnabled(true);
System.out.println(lollipop.isVisible());
verseNumber = new JTextField(3);
// lollipop.add(verseNumber);
System.out.println(panel.isShowing());
panel.setLocation(10, 20);
clickOnMe = new JLabel("Click on me to get help menu");
panel.add(clickOnMe);
clickOnMe.setLocation(300, 200);
clickOnMe.setVisible(true);
frame = new JFrame();
background = new JLabel("Set Background Color");
color = new JRadioButton("Red");
color2 = new JRadioButton("Green");
color3 = new JRadioButton("Blue");
color4 = new JRadioButton("Orange");
color5 = new JRadioButton("Yellow");
color6 = new JRadioButton("Pink");
color7 = new JRadioButton("Black");
color8 = new JRadioButton("Gray");
color9 = new JRadioButton("Light Gray");
color10 = new JRadioButton("Dark Gray");
color11 = new JRadioButton("Magenta");
color12 = new JRadioButton("Cyan");
color13 = new JRadioButton("White");
color14 = new JRadioButton("Red");
color15 = new JRadioButton("Green");
color16 = new JRadioButton("Blue");
color17 = new JRadioButton("Orange");
color18 = new JRadioButton("Yellow");
color19 = new JRadioButton("Pink");
color20 = new JRadioButton("Black");
color21 = new JRadioButton("Gray");
color22 = new JRadioButton("Light Gray");
color23 = new JRadioButton("Dark Gray");
color24 = new JRadioButton("Magenta");
color25 = new JRadioButton("Cyan");
color26 = new JRadioButton("White");
color27 = new JRadioButton("Brown");
color28 = new JRadioButton("Purple");
color29 = new JRadioButton("Brown");
color30 = new JRadioButton("Purple");
color31 = new JRadioButton("Lighter");
color32 = new JRadioButton("Darker");
color33 = new JRadioButton("Lighter");
color34 = new JRadioButton("Darker");
group = new ButtonGroup();
group.add(color);
group.add(color2);
group.add(color3);
group.add(color4);
group.add(color5);
group.add(color6);
group.add(color7);
group.add(color8);
group.add(color9);
group.add(color10);
group.add(color11);
group.add(color12);
group.add(color13);
group.add(color27);
group.add(color28);
group3 = new ButtonGroup();
group3.add(color31);
group3.add(color32);
button.setBackground(green);
button2.setBackground(green);
button3.setBackground(green);
button4.setBackground(green);
button5.setBackground(green);
button6.setBackground(green);
group2 = new ButtonGroup();
group2.add(color14);
group2.add(color15);
group2.add(color16);
group2.add(color17);
group2.add(color18);
group2.add(color19);
group2.add(color20);
group2.add(color21);
group2.add(color22);
group2.add(color23);
group2.add(color24);
group2.add(color25);
group2.add(color26);
group2.add(color29);
group2.add(color30);
background.setVisible(true);
int x = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
int y = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
int z = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
area = new JTextArea(65, 110);
scrolls = new JScrollPane(area, x, z);
panel.add(scrolls);
scrolls2 = new JScrollPane(panel, x, y);
pageNumber.setText("0");
popup.add(cut2);
popup.addSeparator();
popup.add(copy2);
popup.addSeparator();
popup.add(paste2);
popup.addSeparator();
popup.add(selectAll2);
area.addMouseListener(
new MouseListener() {
@Override
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
popup.show(area, area.getX(), area.getY());
}
@Override
public void mouseEntered(MouseEvent arg0) {
}
@Override
public void mouseExited(MouseEvent arg0) {
}
@Override
public void mousePressed(MouseEvent arg0) {
}
@Override
public void mouseReleased(MouseEvent arg0) {
}
});
panel.add(background);
panel.add(color);
panel.add(color2);
panel.add(color3);
panel.add(color4);
panel.add(color5);
panel.add(color6);
panel.add(color7);
panel.add(color8);
panel.add(color9);
panel.add(color10);
panel.add(color11);
panel.add(color12);
panel.add(color13);
panel.add(color27);
panel.add(color28);
panel.add(color31);
panel.add(color32);
panel.setVisible(true);
scrolls.setVisible(true);
scrolls2.setVisible(true);
songNames = new String[835];
box = new JCheckBox("Warshed");
box.addItemListener(
new ItemListener() {
@Override
public void itemStateChanged(ItemEvent arg0) {
// TODO Auto-generated method stub
if (arg0.getSource() == box)
{
if (arg0.getStateChange() == ItemEvent.SELECTED)
{
String garyA = " ";
area.setText(garyA);
}
}
}
});
char a = '"';
if (box instanceof Serializable)
{
System.out.println("The check box is Serializable");
}
if (scrolls instanceof Serializable )
{
System.out.println("Scrolls on JTextArea are Serializable");
}
if (scrolls2 instanceof Serializable)
{
System.out.println("The scrolls on the JPanel are Serializable");
}
box.setToolTipText("Click here to get song " + a + "Are you warshed in the blood of the lamb" + a + "." );
panel.add(box);
panel.add(editor);
editor.add(find);
editor.add(replace);
box.setVisible(true);
panel.setVisible(true);
panel.add(scrolls);
panel.setName("Bob");
frame.setTitle("Bob 2");
panel.add(scrolls);
red = Color.RED;
green = Color.GREEN;
blue = Color.BLUE;
orange = Color.ORANGE;
yellow = Color.YELLOW;
black = Color.BLACK;
pink = Color.PINK;
gray = Color.GRAY;
lightGray = Color.LIGHT_GRAY;
darkGray = Color.DARK_GRAY;
magenta = Color.MAGENTA;
white = Color.WHITE;
brown = new Color(102, 51, 0 );
purple = new Color(102, 0, 102);
imageLabel = new JLabel();
// copy = new JButton("Copy");
// panel.add(copy);
// copy.setVisible(true);
textBackground = new JLabel("Set Background Color of Text Area");
panel.add(textBackground);
panel.add(color14);
panel.add(color15);
panel.add(color16);
panel.add(color17);
panel.add(color18);
panel.add(color19);
panel.add(color20);
panel.add(color21);
panel.add(color22);
panel.add(color23);
panel.add(color24);
panel.add(color25);
panel.add(color26);
panel.add(color29);
panel.add(color30);
panel.add(redAdjuster2);
panel.add(greenAdjuster2);
panel.add(blueAdjuster2);
panel.add(alphaAdjuster2);
doPrint = false;
textForeground = new JLabel("Set Color of Text in Text Area");
panel.add(textForeground);
panel.add(colors);
area.setLineWrap(true);
area.setWrapStyleWord(true);
System.out.println("Component Count:");
System.out.println(area.getComponentCount());
System.out.println(panel.getComponentCount());
menu2.addSeparator();
Object object;
object = new Object();
applications.add(SongChooserClassMenuItem);
sourceCode = new JMenuItem("Source Code");
applications.add(sourceCode);
sourceCode.setBackground(Color.GREEN);
sourceCode.setForeground(Color.RED);
applications.addSeparator();
sourceCode.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
try {
jsc = new JSourceCode();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
jsc.setVisible(true);
}
});
SongChooserClassMenuItem.setBackground(Color.GREEN);
SongChooserClassMenuItem.setForeground(Color.RED);
cut = new JMenuItem("Cut");
menu2.add(cut);
menu2.addSeparator();
paste = new JMenuItem("Paste");
menu2.add(paste);
print.setToolTipText("This one doesn't work quite well.");
save.setToolTipText("This one saves but you can never load it anywehre" + "\n" +
" and it doesn't save quite the way it's supposed to either.");
load.setToolTipText("This one doesn't load properly.");
if (area instanceof Serializable)
{
System.out.println("Is serializable");
}
if (area.getText() instanceof Serializable)
{
System.out.println("This is too");
}
if (scrolls instanceof Serializable)
{
System.out.println("Wenguin woo");
}
if (scrolls.getVerticalScrollBar() instanceof Serializable)
{
System.out.println("Woo hoo!");
}
if (panel instanceof Serializable)
{
System.out.println("Great!");
}
if (button6 instanceof Serializable)
{
System.out.println("Go wenguins!");
}
if (mBar instanceof Serializable)
{
System.out.println("Rock on!");
}
hayField.setText("Red: " + panel.getBackground().getRed() + " ");
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen() + " ");
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue() + " ");
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha() + " ");
alphaAdjuster.setValue(panel.getBackground().getAlpha());
area.add(popup);
cut2.addActionListener(this);
copy2.addActionListener(this);
paste2.addActionListener(this);
selectAll2.addActionListener(this);
b = color.getLocation();
bb = color2.getLocation();
menu2.addSeparator();
menu2.add(clear);
popup.addSeparator();
popup.add(clear2);
copy.setToolTipText("Copies selected text, can be pasted in other files");
paste.setToolTipText("Pastes text, that was copied or pasted from this program, and this program only, to text area.");
cut.setToolTipText("Cuts texts and puts it on clipboard , can be pasted in other files");
selectAll.setToolTipText("Selects all the text in the text area.");
lollipop.setOpaque(true);
lollipop.setBackground(green);
copy.setBackground(green);
selectAll.setBackground(green);
selectAll.setForeground(red);
cut.setBackground(green);
paste.setBackground(green);
copy.setForeground(red);
paste.setForeground(red);
cut.setForeground(red);
clear.setBackground(green);
clear.setForeground(red);
exit.setBackground(green);
exit.setForeground(red);
save.setBackground(green);
save.setForeground(red);
about.setBackground(green);
about.setForeground(red);
openHelpMenu.setBackground(green);
openHelpMenu.setForeground(red);
load.setBackground(green);
load.setForeground(red);
print.setBackground(green);
print.setForeground(red);
popup.setLabel("Edit Menu");
SongChooserNotepadMenuItem = new JMenuItem("Song Chooser Notepad");
applications.add(SongChooserNotepadMenuItem);
SongChooserNotepadMenuItem.setBackground(green);
SongChooserNotepadMenuItem.setForeground(red);
SongChooserNotepadMenuItem.addActionListener( new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
SongChooserNotepad np = new SongChooserNotepad();
np.setVisible(true);
}
});
openHelpMenu.setText("Open help menu(h or F1 or click on label)");
openHelpMenu.setToolTipText("Click to open help menu.");
clickOnMe.setToolTipText(clickOnMe.getText());
color.addComponentListener(
new ComponentListener() {
@Override
public void componentHidden(ComponentEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void componentMoved(ComponentEvent arg0) {
// TODO Auto-generated method stub
System.out.println("The component Red has moved to " + color.getLocationOnScreen());
}
@Override
public void componentResized(ComponentEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void componentShown(ComponentEvent arg0) {
// TODO Auto-generated method stub
}
});
System.out.println("Line Count: " + area.getLineCount());
pBar.setToolTipText("Progress: " + pBar.getValue() + "%");
pageNumber.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e)
{
int m = Integer.parseInt(pageNumber.getText());
if (m == 1)
{
String song1 = "1.) My Faith Has Found a Resting Place" + "\n" +
"By Lidie H. Edmunds, Norse Air, Arr. by William J. Kirkpatrick" + "\n" + "\n" +
"1.) My faith has found a resting place, not in device nor creed;" + "\n" +
" I trust the Everliving One, His wounds for me shall plead." + "\n" +
"Chorus: I need no other arguement, I need no other plea," + "\n" +
" It is enough that Jesus died, and that he died for me." + "\n" + "\n" +
"2.) Enough for me that Jesus saves, this ends my fear and doubt;" + "\n" +
" A sinful soul I come to Him, He'll never cast me out." + "\n" +
"Chorus: I need no other arguement, I need no other plea," + "\n" +
" It is enough that Jesus died, and that he died for me." + "\n" + "\n" +
"3.) My heart is leaning on the Word, the written Word of God," + "\n" +
" Salvation by my Saviour's name, salvation thro' His blood." + "\n" +
"Chorus: I need no other arguement, I need no other plea," + "\n" +
" It is enough that Jesus died, and that he died for me." + "\n" + "\n" +
"4.) My great Physician heals the sick, the lost He came to save;" + "\n" +
" For me His precious blood He shed, for me His Life he gave." + "\n" +
"Chorus: I need no other arguement, I need no other plea," + "\n" +
" It is enough that Jesus died, and that he died for me." + "\n" + "\n";
area.setText(song1);
}
else if (m == 2)
{
String song2 = "2.) Come Thou Almighty King" + "\n" +
"By Anon. and Felice de Giagdini" + "\n" + "\n" +
"1.) Come, Thou almighty King, help us Thy Name to sing," + "\n" +
" Help us to praise! Father all glorious, O'er all victorious," + "\n" +
" Come and reign over us, Ancient of Days!" + "\n" + "\n" +
"2.) Come Thou Incarnate Word, gird of Thy mighty sword," + "\n" +
" Our pray'r attend; come, and Thy people bless and give Thy" + "\n" +
" word success; Spirit of holiness, on us descend!" + "\n" + "\n" +
"3.) Come, Holy Comforter, Thy sacred witness bear," + "\n" +
" In this glad hour: Thou who almighty art, now rule in" + "\n" +
" every heart, And ne'er from us depart, Spirit of power!" + "\n" + "\n" +
"4.) To Thee, great One in Three, eternal praises be" + "\n" +
" Hence, evermore: Thy sov'reign magesty, may we in" + "\n" +
" glory see, And to eternity Love and adore!" + "\n" + "\n";
area.setText(song2);
}
else if (m == 3)
{
String song3 = "3.) Praise The Savior, Ye Who Know Him!" + "\n" +
" By Thomas Kelly. Traditional German Melody" + "\n" + "\n" +
"1.) Praise the Savior, ye who know Him!" + "\n" +
" Who can tell how much we owe Him?" + "\n" +
" Gladly let us render to Him all we are and have." + "\n" + "\n" +
"2.) Jesus is the name that charms us;" + "\n" +
" He for conflict fits and arms us;" + "\n" +
" Nothing moves and nothing harms us while we trust in Him." + "\n" +"\n" +
"3.) Trust in Him, ye saints, forever;" + "\n" +
" He is faithful, changing never;" + "\n" +
" Neither force nor guile can sever those He loves from Him." + "\n" + "\n" +
"4.) Keep us, Lord, oh keep us cleaving;" + "\n" +
" to Thyself and still still believing," + "\n" +
" Till the hour of our receiving promised joys with Thee." + "\n" + "\n" +
"5.) Then we shall be where we would be," + "\n" +
" then we shall be what we should be;" + "\n" +
" Things that are not now, nor could be, soon shall be our own." + "\n" + "\n";
area.setText(song3);
}
else if (m == 365)
{
String song365 = "365.) A Child of The King" + "\n" +
" By Hattie E. Buell and Rev. John B. Sumner" + "\n" + "\n" +
"1.) My Father is rich in houses and lands," + "\n" +
" He holdeth the wealth of the world in His hands!" + "\n" +
" Of rubies and diamonds, of silver and gold, His coffers are full," + "\n" +
" He has riches untold." + "\n" +
"Chorus: I'm a child of the King, a child of the King:" + "\n" +
" With Jesus my Saviour I'm a child of the King." + "\n" + "\n" +
"2.) My Father's own Son, the Saviour of men," + "\n" +
" once wandered on earth as the poorest of them;" + "\n" +
" but now He is pleading our pardon on high, that we may be His" + "\n" +
" when He comes by and by." + "\n" +
"Chorus: I'm a child of the King, a child of the King:" + "\n" +
" With Jesus my Saviour I'm a child of the King." + "\n" + "\n" +
"3.) I once was an outcast stranger on earth," + "\n" +
" a sinner by choice and an alien by birth;" + "\n" +
" but I've been adopted, my name's written down," + "\n" +
" an heir to a mansion, a robe, and a crown." + "\n" +
"Chorus: I'm a child of the King, a child of the King:" + "\n" +
" With Jesus my Saviour I'm a child of the King." + "\n" + "\n" +
"4.) A tent or a cottage, why should I care?" + "\n" +
" They're building a palace for me over there;" + "\n" +
" tho' exiled from home, yet, still I may sing:" + "\n" +
" all glory to God, I'm a child of the King." + "\n" +
"Chorus: I'm a child of the King, a child of the King:" + "\n" +
" With Jesus my Saviour I'm a child of the King." + "\n" + "\n";
area.setText(song365);
}
else if (m == 505)
{
String song505 = "505.) A Charge to Keep I Have" + "\n" +
" By Charles Wesley and Lowell Mason" + "\n" + "\n" +
"1.) A charge to keep I have, A God to glorify;" + "\n" +
" A never-dying soul to save, and fit it for the sky." + "\n" + "\n" +
"2.) To serve the present age, my calling to fulfill,-" + "\n" +
" O may it all my powers engage to do my Master's will." + "\n" + "\n" +
"3.) Arm me with jealous care, as in Thy sight to live;" + "\n" +
" And O Thy servant, Lord, prepare a strict account to give." + "\n" + "\n" +
"4.) Help me to watch and pray, and on Thyself rely," + "\n" +
" assured, if I my trust betray, I shall forever die." + "\n"+ "\n";
area.setText(song505);
}
}
});
redAdjuster.addAdjustmentListener(
new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent arg0) {
// TODO Auto-generated method stub
hayField.setText("Red: " + arg0.getValue()+ " ");
repaint();
Color pretty = new Color(arg0.getValue(), panel.getBackground().getGreen(), panel.getBackground().getBlue());
panel.setBackground(pretty);
color.setBackground(pretty);
color2.setBackground(pretty);
color3.setBackground(pretty);
color4.setBackground(pretty);
color5.setBackground(pretty);
color6.setBackground(pretty);
color7.setBackground(pretty);
color8.setBackground(pretty);
color9.setBackground(pretty);
box.setBackground(pretty);
color10.setBackground(pretty);
color11.setBackground(pretty);
color12.setBackground(pretty);
color13.setBackground(pretty);
color14.setBackground(pretty);
color15.setBackground(pretty);
color16.setBackground(pretty);
color17.setBackground(pretty);
color18.setBackground(pretty);
color19.setBackground(pretty);
color20.setBackground(pretty);
color21.setBackground(pretty);
color22.setBackground(pretty);
color23.setBackground(pretty);
color24.setBackground(pretty);
color25.setBackground(pretty);
color26.setBackground(pretty);
color27.setBackground(pretty);
color28.setBackground(pretty);
color29.setBackground(pretty);
color30.setBackground(pretty);
color31.setBackground(pretty);
color32.setBackground(pretty);
color33.setBackground(pretty);
color34.setBackground(pretty);
plain.setBackground(pretty);
bold.setBackground(pretty);
italic.setBackground(pretty);
boldItalic.setBackground(pretty);
}
});
greenAdjuster.addAdjustmentListener(
new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent arg0) {
// TODO Auto-generated method stub
wheatField.setText("Green: " + arg0.getValue()+ " ");
repaint();
Color pretty2 = new Color(panel.getBackground().getRed(), arg0.getValue(), panel.getBackground().getBlue());
panel.setBackground(pretty2);
color.setBackground(pretty2);
color2.setBackground(pretty2);
color3.setBackground(pretty2);
color4.setBackground(pretty2);
color5.setBackground(pretty2);
color6.setBackground(pretty2);
color7.setBackground(pretty2);
color8.setBackground(pretty2);
color9.setBackground(pretty2);
box.setBackground(pretty2);
color10.setBackground(pretty2);
color11.setBackground(pretty2);
color12.setBackground(pretty2);
color13.setBackground(pretty2);
color14.setBackground(pretty2);
color15.setBackground(pretty2);
color16.setBackground(pretty2);
color17.setBackground(pretty2);
color18.setBackground(pretty2);
color19.setBackground(pretty2);
color20.setBackground(pretty2);
color21.setBackground(pretty2);
color22.setBackground(pretty2);
color23.setBackground(pretty2);
color24.setBackground(pretty2);
color25.setBackground(pretty2);
color26.setBackground(pretty2);
color27.setBackground(pretty2);
color28.setBackground(pretty2);
color29.setBackground(pretty2);
color30.setBackground(pretty2);
color31.setBackground(pretty2);
color32.setBackground(pretty2);
color33.setBackground(pretty2);
color34.setBackground(pretty2);
plain.setBackground(pretty2);
bold.setBackground(pretty2);
italic.setBackground(pretty2);
boldItalic.setBackground(pretty2);
}
});
blueAdjuster.addAdjustmentListener(
new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent arg0) {
// TODO Auto-generated method stub
cottonField.setText("Blue: " + arg0.getValue()+ " ");
repaint();
Color pretty3 = new Color(panel.getBackground().getRed(), panel.getBackground().getGreen(), arg0.getValue());
panel.setBackground(pretty3);
color.setBackground(pretty3);
color2.setBackground(pretty3);
color3.setBackground(pretty3);
color4.setBackground(pretty3);
color5.setBackground(pretty3);
color6.setBackground(pretty3);
color7.setBackground(pretty3);
color8.setBackground(pretty3);
color9.setBackground(pretty3);
box.setBackground(pretty3);
color10.setBackground(pretty3);
color11.setBackground(pretty3);
color12.setBackground(pretty3);
color13.setBackground(pretty3);
color14.setBackground(pretty3);
color15.setBackground(pretty3);
color16.setBackground(pretty3);
color17.setBackground(pretty3);
color18.setBackground(pretty3);
color19.setBackground(pretty3);
color20.setBackground(pretty3);
color21.setBackground(pretty3);
color22.setBackground(pretty3);
color23.setBackground(pretty3);
color24.setBackground(pretty3);
color25.setBackground(pretty3);
color26.setBackground(pretty3);
color27.setBackground(pretty3);
color28.setBackground(pretty3);
color29.setBackground(pretty3);
color30.setBackground(pretty3);
color31.setBackground(pretty3);
color32.setBackground(pretty3);
color33.setBackground(pretty3);
color34.setBackground(pretty3);
plain.setBackground(pretty3);
bold.setBackground(pretty3);
italic.setBackground(pretty3);
boldItalic.setBackground(pretty3);
}
});
alphaAdjuster.addAdjustmentListener(
new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent arg0) {
// TODO Auto-generated method stub
riceField.setText("Alpha: " + arg0.getValue()+ " ");
repaint();
Color pretty4 = new Color(panel.getBackground().getRed(), panel.getBackground().getGreen(), panel.getBackground().getBlue(), arg0.getValue());
panel.setBackground(pretty4);
color.setBackground(pretty4);
color2.setBackground(pretty4);
color3.setBackground(pretty4);
color4.setBackground(pretty4);
color5.setBackground(pretty4);
color6.setBackground(pretty4);
color7.setBackground(pretty4);
color8.setBackground(pretty4);
color9.setBackground(pretty4);
box.setBackground(pretty4);
color10.setBackground(pretty4);
color11.setBackground(pretty4);
color12.setBackground(pretty4);
color13.setBackground(pretty4);
color14.setBackground(pretty4);
color15.setBackground(pretty4);
color16.setBackground(pretty4);
color17.setBackground(pretty4);
color18.setBackground(pretty4);
color19.setBackground(pretty4);
color20.setBackground(pretty4);
color21.setBackground(pretty4);
color22.setBackground(pretty4);
color23.setBackground(pretty4);
color24.setBackground(pretty4);
color25.setBackground(pretty4);
color26.setBackground(pretty4);
color27.setBackground(pretty4);
color28.setBackground(pretty4);
color29.setBackground(pretty4);
color30.setBackground(pretty4);
color31.setBackground(pretty4);
color32.setBackground(pretty4);
color33.setBackground(pretty4);
color34.setBackground(pretty4);
plain.setBackground(pretty4);
bold.setBackground(pretty4);
italic.setBackground(pretty4);
boldItalic.setBackground(pretty4);
}
});
openHelpMenu.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
lollipop.setVisible(true);
}
});
color.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
panel.setBackground(red);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
}
});
color2.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
panel.setBackground(green);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
color.setBackground(green);
color2.setBackground(green);
color3.setBackground(green);
color4.setBackground(green);
color5.setBackground(green);
color6.setBackground(green);
color7.setBackground(green);
color8.setBackground(green);
color9.setBackground(green);
color10.setBackground(green);
color11.setBackground(green);
color12.setBackground(green);
color13.setBackground(green);
color14.setBackground(green);
color15.setBackground(green);
color16.setBackground(green);
color17.setBackground(green);
color18.setBackground(green);
color19.setBackground(green);
color20.setBackground(green);
color21.setBackground(green);
color22.setBackground(green);
color23.setBackground(green);
color24.setBackground(green);
color25.setBackground(green);
color26.setBackground(green);
color27.setBackground(green);
color28.setBackground(green);
color29.setBackground(green);
color30.setBackground(green);
color31.setBackground(green);
color32.setBackground(green);
color33.setBackground(green);
color34.setBackground(green);
box.setBackground(green);
if (panel.getBackground() == Color.GREEN)
{
panel.getGraphics().setColor(pink);
}
}
});
copy.addActionListener(this);
paste.addActionListener(this);
selectAll.addActionListener(this);
cut.addActionListener(this);
date = new JMenu("Just shows the date");
mBar.add(date);
JMenu timeMenu = new JMenu("Shows the time program was started.");
mBar.add(timeMenu);
date.setBackground(green);
timeMenu.setBackground(green);
int weekday = Calendar.DAY_OF_WEEK;
int monthDay = Calendar.DAY_OF_MONTH;
int month = Calendar.MONTH;
int year = Calendar.YEAR;
date.setToolTipText("This is the date when the program was opened, which usually will be the same day as today.");
Font aFont= date.getFont();
Font anotherFont = aFont.deriveFont(Font.BOLD);
date.setFont(anotherFont);
if (month == Calendar.JANUARY)
{
if (weekday ==0)
{
date.setText("Sunday January " + monthDay + "," + year);
}
else if (weekday ==1)
{
date.setText("Monday January " + monthDay + "," + year);
}
else if (weekday ==2)
{
date.setText("Tuesday January " + monthDay + "," + year);
}
else if (weekday ==3)
{
date.setText("Wednesday January " + monthDay + "," + year);
}
else if (weekday ==4)
{
date.setText("Thursday January " + monthDay + "," + year);
}
else if (weekday ==5)
{
date.setText("Friday January " + monthDay + "," + year);
}
else
date.setText("Saturday January " + monthDay + "," + year);
}
else if (month == Calendar.FEBRUARY)
{
if (weekday ==0)
{
date.setText("Sunday February " + monthDay + "," + year);
}
else if (weekday ==1)
{
date.setText("Monday February " + monthDay + "," + year);
}
else if (weekday ==2)
{
date.setText("Tuesday February " + monthDay + "," + year);
}
else if (weekday ==3)
{
date.setText("Wednesday February " + monthDay + "," + year);
}
else if (weekday ==4)
{
date.setText("Thursday February " + monthDay + "," + year);
}
else if (weekday ==5)
{
date.setText("Friday February " + monthDay + "," + year);
}
else
date.setText("Saturday February " + monthDay + "," + year);
}
else if (month == Calendar.MARCH)
{
if (weekday ==0)
{
date.setText("Sunday March " + monthDay + "," + year);
}
else if (weekday ==1)
{
date.setText("Monday March " + monthDay + "," + year);
}
else if (weekday ==2)
{
date.setText("Tuesday March " + monthDay + "," + year);
}
else if (weekday ==3)
{
date.setText("Wednesday March " + monthDay + "," + year);
}
else if (weekday ==4)
{
date.setText("Thursday March " + monthDay + "," + year);
}
else if (weekday ==5)
{
date.setText("Friday March " + monthDay + "," + year);
}
else
date.setText("Saturday March " + monthDay + "," + year);
}
else if (month == Calendar.APRIL)
{
if (weekday ==0)
{
date.setText("Sunday April " + monthDay + "," + year);
}
else if (weekday ==1)
{
date.setText("Monday April " + monthDay + "," + year);
}
else if (weekday ==2)
{
date.setText("Tuesday April " + monthDay + "," + year);
}
else if (weekday ==3)
{
date.setText("Wednesday April " + monthDay + "," + year);
}
else if (weekday ==4)
{
date.setText("Thursday April " + monthDay + "," + year);
}
else if (weekday ==5)
{
date.setText("Friday April " + monthDay + "," + year);
}
else
date.setText("Saturday April " + monthDay + "," + year);
}
else if (month == Calendar.MAY)
{
if (weekday ==0)
{
date.setText("Sunday May " + monthDay + "," + year);
}
else if (weekday ==1)
{
date.setText("Monday May " + monthDay + "," + year);
}
else if (weekday ==2)
{
date.setText("Tuesday May " + monthDay + "," + year);
}
else if (weekday ==3)
{
date.setText("Wednesday May " + monthDay + "," + year);
}
else if (weekday ==4)
{
date.setText("Thursday May " + monthDay + "," + year);
}
else if (weekday ==5)
{
date.setText("Friday May " + monthDay + "," + year);
}
else
date.setText("Saturday May " + monthDay + "," + year);
}
else if (month== Calendar.JUNE)
{
if (weekday ==0)
{
date.setText("Sunday June " + monthDay + "," + year);
}
else if (weekday ==1)
{
date.setText("Monday June " + monthDay + "," + year);
}
else if (weekday ==2)
{
date.setText("Tuesday June " + monthDay + "," + year);
}
else if (weekday ==3)
{
date.setText("Wednesday June " + monthDay + "," + year);
}
else if (weekday ==4)
{
date.setText("Thursday June " + monthDay + "," + year);
}
else if (weekday ==5)
{
date.setText("Friday June " + monthDay + "," + year);
}
else
date.setText("Saturday June " + monthDay + "," + year);
}
else if (month == Calendar.JULY)
{
if (weekday ==0)
{
date.setText("Sunday July " + monthDay + "," + year);
}
else if (weekday ==1)
{
date.setText("Monday July " + monthDay + "," + year);
}
else if (weekday ==2)
{
date.setText("Tuesday July " + monthDay + "," + year);
}
else if (weekday ==3)
{
date.setText("Wednesday July " + monthDay + "," + year);
}
else if (weekday ==4)
{
date.setText("Thursday July " + monthDay + "," + year);
}
else if (weekday ==5)
{
date.setText("Friday July " + monthDay + "," + year);
}
else
date.setText("Saturday July " + monthDay + "," + year);
}
else if (month == Calendar.AUGUST)
{
if (weekday ==0)
{
date.setText("Sunday August " + monthDay + "," + year);
}
else if (weekday ==1)
{
date.setText("Monday August " + monthDay + "," + year);
}
else if (weekday ==2)
{
date.setText("Tuesday August " + monthDay + "," + year);
}
else if (weekday ==3)
{
date.setText("Wednesday August " + monthDay + "," + year);
}
else if (weekday ==4)
{
date.setText("Thursday August " + monthDay + "," + year);
}
else if (weekday ==5)
{
date.setText("Friday August " + monthDay + "," + year);
}
else
date.setText("Saturday August " + monthDay + "," + year);
}
else if (month ==Calendar.SEPTEMBER)
{
if (weekday ==0)
{
date.setText("Sunday September " + monthDay + "," + year);
}
else if (weekday ==1)
{
date.setText("Monday September " + monthDay + "," + year);
}
else if (weekday ==2)
{
date.setText("Tuesday September " + monthDay + "," + year);
}
else if (weekday ==3)
{
date.setText("Wednesday September " + monthDay + "," + year);
}
else if (weekday ==4)
{
date.setText("Thursday September " + monthDay + "," + year);
}
else if (weekday ==5)
{
date.setText("Friday September " + monthDay + "," + year);
}
else
date.setText("Saturday September " + monthDay + "," + year);
}
else if (month== Calendar.OCTOBER)
{
if (weekday ==0)
{
date.setText("Sunday October " + monthDay + "," + year);
}
else if (weekday ==1)
{
date.setText("Monday October " + monthDay + "," + year);
}
else if (weekday ==2)
{
date.setText("Tuesday October " + monthDay + "," + year);
}
else if (weekday ==3)
{
date.setText("Wednesday October " + monthDay + "," + year);
}
else if (weekday ==4)
{
date.setText("Thursday October " + monthDay + "," + year);
}
else if (weekday ==5)
{
date.setText("Friday October " + monthDay + "," + year);
}
else
date.setText("Saturday October " + monthDay + "," + year);
}
else if (month==Calendar.NOVEMBER)
{
if (weekday ==0)
{
date.setText("Sunday November " + monthDay + "," + year);
}
else if (weekday ==1)
{
date.setText("Monday November " + monthDay + "," + year);
}
else if (weekday ==2)
{
date.setText("Tuesday November " + monthDay + "," + year);
}
else if (weekday ==3)
{
date.setText("Wednesday November " + monthDay + "," + year);
}
else if (weekday ==4)
{
date.setText("Thursday November " + monthDay + "," + year);
}
else if (weekday ==5)
{
date.setText("Friday November " + monthDay + "," + year);
JOptionPane.showMessageDialog(null, "Year is:" + year);
}
else
date.setText("Saturday November " + monthDay + "," + year);
}
else
{
if (weekday ==0)
{
date.setText("Sunday December " + monthDay + "," + year);
}
else if (weekday ==1)
{
date.setText("Monday December " + monthDay + "," + year);
}
else if (weekday ==2)
{
date.setText("Tuesday December " + monthDay + "," + year);
}
else if (weekday ==3)
{
date.setText("Wednesday December " + monthDay + "," + year);
}
else if (weekday ==4)
{
date.setText("Thursday December " + monthDay + "," + year);
}
else if (weekday ==5)
{
date.setText("Friday December " + monthDay + "," + year);
}
else
date.setText("Saturday December " + monthDay + "," + year);
}
JMenuItem horsePane = new JMenuItem("Horse Stuff");
applications.addSeparator();
applications.add(horsePane);
horsePane.setBackground(green);
horsePane.setForeground(red);
horsePane.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
JHorsePane hPane = new JHorsePane();
hPane.setVisible(true);
}
});
System.out.println(weekday + " " + monthDay + "," + year);
color3.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
panel.setBackground(blue);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
}
});
color4.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
panel.setBackground(orange);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
}
});
color5.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
panel.setBackground(yellow);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
}
});
color6.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
panel.setBackground(pink);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
}
});
color7.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
panel.setBackground(black);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
}
});
color8.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
panel.setBackground(gray);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
}
});
color9.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
panel.setBackground(lightGray);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
}
});
color10.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
panel.setBackground(darkGray);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
}
});
color11.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
panel.setBackground(magenta);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
}
});
color12.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
panel.setBackground(cyan);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
}
});
color13.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
panel.setBackground(white);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
}
});
color14.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
area.setBackground(red);
pageNumber.setBackground(red);
}
});
color15.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
area.setBackground(green);
pageNumber.setBackground(green);
}
});
color16.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
area.setBackground(blue);
pageNumber.setBackground(blue);
}
});
color17.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
area.setBackground(orange);
pageNumber.setBackground(orange);
}
});
color18.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
area.setBackground(yellow);
pageNumber.setBackground(yellow);
}
});
color19.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
area.setBackground(pink);
pageNumber.setBackground(pink);
}
});
color20.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
area.setBackground(black);
pageNumber.setBackground(black);
}
});
color21.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
area.setBackground(gray);
pageNumber.setBackground(gray);
}
});
color22.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
area.setBackground(lightGray);
pageNumber.setBackground(lightGray);
}
});
color23.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
area.setBackground(darkGray);
pageNumber.setBackground(darkGray);
}
});
color24.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
area.setBackground(magenta);
pageNumber.setBackground(magenta);
}
});
color25.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
area.setBackground(cyan);
pageNumber.setBackground(cyan);
}
});
color26.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
area.setBackground(white);
pageNumber.setBackground(white);
}
});
color27.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
panel.setBackground(brown);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
}
});
color28.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e)
{
panel.setBackground(purple);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
}
});
color29.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e)
{
area.setBackground(brown);
pageNumber.setBackground(brown);
}
});
color30.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e)
{
area.setBackground(purple);
pageNumber.setBackground(purple);
repaint();
}
});
clickOnMe.addMouseListener(
new MouseListener(){
@Override
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
lollipop.setVisible(true);
cornField.setBackground(green);
}
});
color31.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent f)
{
Color c = panel.getBackground().brighter();
panel.setBackground(c);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
repaint();
}
});
color32.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent a)
{
Color d = panel.getBackground().darker();
panel.setBackground(d);
hayField.setText("Red: " + panel.getBackground().getRed());
redAdjuster.setValue(panel.getBackground().getRed());
wheatField.setText("Green: " + panel.getBackground().getGreen());
greenAdjuster.setValue(panel.getBackground().getGreen());
cottonField.setText("Blue: " + panel.getBackground().getBlue());
blueAdjuster.setValue(panel.getBackground().getBlue());
riceField.setText("Alpha: " + panel.getBackground().getAlpha());
alphaAdjuster.setValue(panel.getBackground().getAlpha());
repaint();
}
});
colors.addItemListener(
new ItemListener() {
public void itemStateChanged(ItemEvent e)
{ // beginning of method
if (e.getSource() == colors)
{ // beginning of if
if (colors.getSelectedItem() == "Red")
{ // beginning of if
if(e.getStateChange() == ItemEvent.SELECTED)
{ // beginning of if
area.setForeground(red);
pageNumber.setForeground(red);
} // end of if
if (e.getStateChange() == ItemEvent.DESELECTED)
{ // beginning of if
// do nothing
} // end of if
} // end of if
if (colors.getSelectedItem() == "Green")
{// beginning of if
if(e.getStateChange() == ItemEvent.SELECTED)
{ // beginning of if
area.setForeground(green);
pageNumber.setForeground(green);
} // end of if
if (e.getStateChange() == ItemEvent.DESELECTED)
{ // beginning of if
// do nothing
} // end of if
} // end of if
if (colors.getSelectedItem() == "Blue")
{// beginning of if
if(e.getStateChange() == ItemEvent.SELECTED)
{ // beginning of if
area.setForeground(blue);
pageNumber.setForeground(blue);
} // end of if
if (e.getStateChange() == ItemEvent.DESELECTED)
{ // beginning of if
// do nothing
} // end of if
} // end of if
if (colors.getSelectedItem() == "Orange")
{// beginning of if
if(e.getStateChange() == ItemEvent.SELECTED)
{ // beginning of if
area.setForeground(orange);
pageNumber.setForeground(orange);
} // end of if
if (e.getStateChange() == ItemEvent.DESELECTED)
{ // beginning of if
// do nothing
} // end of if
} // end of if
if (colors.getSelectedItem() == "Yellow")
{// beginning of if
if(e.getStateChange() == ItemEvent.SELECTED)
{ // beginning of if
area.setForeground(yellow);
pageNumber.setForeground(yellow);
} // end of if
if (e.getStateChange() == ItemEvent.DESELECTED)
{ // beginning of if
// do nothing
} // end of if
} // end of if
if (colors.getSelectedItem() == "Pink")
{// beginning of if
if(e.getStateChange() == ItemEvent.SELECTED)
{ // beginning of if
area.setForeground(pink);
pageNumber.setForeground(pink);
} // end of if
if (e.getStateChange() == ItemEvent.DESELECTED)
{ // beginning of if
// do nothing
} // end of if
} // end of if
if (colors.getSelectedItem() == "Black")
{// beginning of if
if(e.getStateChange() == ItemEvent.SELECTED)
{ // beginning of if
area.setForeground(black);
pageNumber.setForeground(black);
} // end of if
if (e.getStateChange() == ItemEvent.DESELECTED)
{ // beginning of if
// do nothing
} // end of if
} // end of if
if (colors.getSelectedItem() == "Gray")
{// beginning of if
if(e.getStateChange() == ItemEvent.SELECTED)
{ // beginning of if
area.setForeground(gray);
pageNumber.setForeground(gray);
} // end of if
if (e.getStateChange() == ItemEvent.DESELECTED)
{ // beginning of if
// do nothing
} // end of if
} // end of if
if (colors.getSelectedItem() == "Light Gray")
{// beginning of if
if(e.getStateChange() == ItemEvent.SELECTED)
{ // beginning of if
area.setForeground(lightGray);
pageNumber.setForeground(lightGray);
} // end of if
if (e.getStateChange() == ItemEvent.DESELECTED)
{ // beginning of if
// do nothing
} // end of if
} // end of if
if (colors.getSelectedItem() == "Dark Gray")
{// beginning of if
if(e.getStateChange() == ItemEvent.SELECTED)
{ // beginning of if
area.setForeground(darkGray);
pageNumber.setForeground(darkGray);
} // end of if
if (e.getStateChange() == ItemEvent.DESELECTED)
{ // beginning of if
// do nothing
} // end of if
} // end of if
if (colors.getSelectedItem() == "Magenta")
{// beginning of if
if(e.getStateChange() == ItemEvent.SELECTED)
{ // beginning of if
area.setForeground(magenta);
pageNumber.setForeground(magenta);
} // end of if
if (e.getStateChange() == ItemEvent.DESELECTED)
{ // beginning of if
// do nothing
} // end of if
} // end of if
if (colors.getSelectedItem() == "Cyan")
{// beginning of if
if(e.getStateChange() == ItemEvent.SELECTED)
{ // beginning of if
area.setForeground(cyan);
pageNumber.setForeground(cyan);
} // end of if
if (e.getStateChange() == ItemEvent.DESELECTED)
{ // beginning of if
// do nothing
} // end of if
} // end of if
if (colors.getSelectedItem() == "White")
{// beginning of if
if(e.getStateChange() == ItemEvent.SELECTED)
{ // beginning of if
area.setForeground(white);
pageNumber.setForeground(white);
} // end of if
if (e.getStateChange() == ItemEvent.DESELECTED)
{ // beginning of if
// do nothing
} // end of if
} // end of if
if (colors.getSelectedItem() == "Brown")
{
if (e.getStateChange() == ItemEvent.SELECTED)
{
area.setForeground(brown);
pageNumber.setForeground(brown);
}
}
if(colors.getSelectedItem() == "Purple")
{
if (e.getStateChange() == ItemEvent.SELECTED)
{
area.setForeground(purple);
pageNumber.setForeground(purple);
}
}
} // end of if
repaint();
}});
panel.setLayout(new BoxLayout(panel, 1));
addWindowListener(
new WindowListener(){
@Override
public void windowActivated(WindowEvent window) {
// TODO Auto-generated method stub
}
@Override
public void windowClosed(WindowEvent window) {
// TODO Auto-generated method stub
}
@Override
public void windowClosing(WindowEvent window) {
// TODO Auto-generated method stub
Object[] closing= {"Yes" , "No"};
int a = JOptionPane.showOptionDialog(frame2,
"Exit.",
"Are you sure you want to exit?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, closing, closing[0]);
frame2.setBackground(green);
frame2.setForeground(green);
frame2.setFont(Aharoni);
// frame2.setVisible(true);
if (a == JOptionPane.YES_OPTION)
{
System.exit(0);
}
else if (a == JOptionPane.NO_OPTION)
{ // beginning of else if
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
} // end of else if
}
@Override
public void windowDeactivated(WindowEvent window) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent window) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
String str = "Welcome to the hymn book song selector. Choose from" + "\n" +
" different options to set background color, text area color, font color, and font type." + "\n" +
" Chose the songs from the list or enter page number to get songs. It will show all verses as I don't" + "\n" +
" have time to set it to do it for each verse so you have to scroll down to get to the next verses.";
JOptionPane.showMessageDialog(null, str, "Welcome", JOptionPane.INFORMATION_MESSAGE);
}
});
setFocusable(true);
addKeyListener(
new KeyListener() {
@Override
public void keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
if (arg0.getKeyCode() == KeyEvent.VK_ESCAPE)
{
Object[] Esc= {"Yes" , "No"};
int a = JOptionPane.showOptionDialog(frame2,
"Exit.",
"Are you sure you want to exit?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, Esc, Esc[0]);
if (a == JOptionPane.YES_OPTION)
{
System.exit(0);
}
else if (a == JOptionPane.NO_OPTION)
{ // beginning of else if
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
} // end of else if
}
if (arg0.getKeyCode() == KeyEvent.VK_H || arg0.getKeyCode() == KeyEvent.VK_F1)
{
lollipop.show(null, 100, 100);
lollipop.setVisible(true);
}
}
@Override
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
}
});
button6.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
Object[] leavingMenu= {"Yes" , "No"};
int a = JOptionPane.showOptionDialog(frame2,
"Exit Menu.",
"Are you sure you want to exit?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, leavingMenu, leavingMenu[0]);
if (a == JOptionPane.YES_OPTION)
{
lollipop.setVisible(false);
}
else if (a == JOptionPane.NO_OPTION)
{ // beginning of else if
lollipop.setVisible(true);
} // end of else if
}
});
fonts.addItemListener(
new ItemListener() {
public void itemStateChanged(ItemEvent e)
{ // beginning of method
if (e.getSource() == fonts)
{ // beginning of if
if (fonts.getSelectedItem() == "Aharoni")
{ // beginning of if
if(e.getStateChange() == ItemEvent.SELECTED)
{ // beginning of if
area.setFont(Aharoni);
} // end of if
} // end of if
if (fonts.getSelectedItem() == "Andalus")
{ // beginning of if
if (e.getStateChange() == ItemEvent.SELECTED)
{ // beginning of if
area.setFont(Andalus);
} // end of if
} // end of if
} // end of if
repaint();
} // end of method
});
save.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
// saveDialog.setVisible(true);
chooser = new JFileChooser();
chooser.setApproveButtonToolTipText("Click here to save File");
chooser.setBackground(Color.GREEN);
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
chooser.setVisible(true);
chooser.showSaveDialog(saveFrame);
System.out.println(chooser.getSelectedFile());
file = chooser.getSelectedFile();
String bob3 = chooser.getSelectedFile().getName();
System.out.println(file.getFreeSpace());
file.setReadable(true);
try {
river = new FileOutputStream(file);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
objectStream = new ObjectOutputStream(river);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("obj class=" + panel.getClass()); // show objects class before writing it
try {
objectStream.writeObject(scrolls);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
load.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e)
{
chooser2 = new JFileChooser();
chooser2.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
chooser2.setVisible(true);
chooser2.showOpenDialog(openFrame);
System.out.println(chooser2.getSelectedFile());
file2 = chooser2.getSelectedFile();
chooser2.setApproveButtonToolTipText("Click here to open " + file2);
System.out.println(chooser.getApproveButtonText());
String bob = file2.getName() + " doesn't exist!";
String bob2 = file2.getName() + " does exist.";
if (file2.exists() == true)
{
JOptionPane.showMessageDialog(null, "File exists", bob2, JOptionPane.INFORMATION_MESSAGE);
}
else if (file2.exists() == false)
{
JOptionPane.showMessageDialog(null, "File not found", bob, JOptionPane.ERROR_MESSAGE);
}
try {
creek = new FileInputStream(file2);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
inputStream = new ObjectInputStream(creek);
} catch (IOException e1) {
e1.printStackTrace();
}
try {
creek.read();
} catch (IOException e1) {
e1.printStackTrace();
}
try {
creek.getFD();
} catch (IOException e1) {
e1.printStackTrace();
}
try {
System.out.println(creek.getFD());
} catch (IOException e1) {
e1.printStackTrace();
}
try {
inputStream.readObject();
} catch (IOException e2) {
e2.printStackTrace();
} catch (ClassNotFoundException e2) {
e2.printStackTrace();
try {
Object thingy = (JTextArea) inputStream.readObject();
} catch (IOException e1) {
e1.printStackTrace();
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
Component thingy = null;
try {
thingy = (JTextArea) inputStream.readObject();
} catch (IOException e1) {
e1.printStackTrace();
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
panel.add(thingy);
}
/*try {
System.out.println(inputStream.readObject());
} catch (IOException e1) {
e1.printStackTrace();
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
} */
System.out.println(inputStream.getClass());
System.out.println(creek.getChannel());
System.out.println(creek.getChannel().isOpen());
System.out.println(file2.canRead());
System.out.println(file2.canExecute());
System.out.println(file2.getTotalSpace());
file2.setExecutable(true);
}
});
exit.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e)
{
Object[] closing= {"Yes" , "No"};
int a = JOptionPane.showOptionDialog(frame2,
"Exit.",
"Are you sure you want to exit?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, closing, closing[0]);
frame2.setBackground(green);
frame2.setForeground(green);
frame2.setFont(Aharoni);
if (a == JOptionPane.YES_OPTION)
{
System.exit(0);
}
else if (a == JOptionPane.NO_OPTION)
{ // beginning of else if
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
} // end of else if
}
});
int c = 0;
for (c = 0; c < panel.getComponentCount() -1; c++)
{
if (panel.getComponent(c) instanceof Serializable )
{
System.out.println("The Component " + panel.getComponent(c) + " is Serializable.");
}
else
{
System.out.println("The Component " + panel.getComponent(c) + " isn't Serializable.");
}
}
System.out.println("Line Count: " + area.getLineCount());
getContentPane().add(scrolls2);
}
public void showGUI2(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,300);
setLocation(100,100);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand() == "Copy")
{
scratchpad = area.getSelectedText();
area.copy();
}
else if (e.getActionCommand() == "Cut")
{
scratchpad = area.getSelectedText();
area.cut();
// area.replaceRange("", area.getSelectionStart(), area.getSelectionEnd());
}
else if (e.getActionCommand() == "Paste")
{
area.insert(scratchpad, area.getCaretPosition());
}
else if (e.getActionCommand() == "Select all")
{
area.selectAll();
}
}
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
LivingHymns hymn = new LivingHymns();
hymn.showGUI2();
}
@Override
public int print(Graphics g, PageFormat pf, int pageIndex)
throws PrinterException {
panel.printComponents(g);
area.print();
panel.print(g);
Font font = new Font("Serif", Font.PLAIN, 10);
FontMetrics metrics = g.getFontMetrics(font);
int lineHeight = metrics.getHeight();
if (pageBreaks == null) {
initTextLines();
int linesPerPage = (int)(pf.getImageableHeight()/lineHeight);
int numBreaks = (textLines.length-1)/linesPerPage;
pageBreaks = new int[numBreaks];
for (int b=0; b<numBreaks; b++) {
pageBreaks[b] = (b+1)*linesPerPage;
}
}
if (pageIndex > pageBreaks.length) {
return NO_SUCH_PAGE;
}
/* User (0,0) is typically outside the imageable area, so we must
* translate by the X and Y values in the PageFormat to avoid clipping
* Since we are drawing text we
*/
Graphics2D g2d = (Graphics2D)g;
g2d.translate(pf.getImageableX(), pf.getImageableY());
/* Draw each line that is on this page.
* Increment 'y' position by lineHeight for each line.
*/
int y = 0;
int start = (pageIndex == 0) ? 0 : pageBreaks[pageIndex-1];
int end = (pageIndex == pageBreaks.length)
? textLines.length : pageBreaks[pageIndex];
for (int line=start; line<end; line++) {
y += lineHeight;
g.drawString(textLines[line], 0, y);
}
// tell the caller that this page is part of the printed document
return PAGE_EXISTS;
}
public void initTextLines() {
try {
textLines[0] = area.getText(area.getLineEndOffset(1), area.getLineEndOffset(1) - area.getLineStartOffset(1));
} catch (BadLocationException e) {
e.printStackTrace();
}
if (textLines == null) {
textLines = new String[200];
for (int i=0;i<200;i++) {
textLines[i]= "This is line number " + i;
}
}
}
public void paint(Graphics gr)
{
super.paint(gr);
System.out.println(color.getLocation());
System.out.println(color.getX());
System.out.println(color.getY());
if (panel.getBackground() == Color.GREEN)
{
gr.setColor(pink);
}
int[] xPoints = new int[12];
int[] yPoints = new int[12];
int[] xPoints2 = new int[12];
int[] yPoints2 = new int[12];
int[] xPoints3 = new int[12];
int[] yPoints3 = new int[12];
Rectangle rect = new Rectangle(3*color.getWidth(), 15*color.getHeight());
gr.drawRect(color.getX(), color.getY()+30, 2*color.getWidth(), color32.getY() - 25 - color.getY());
//gr.fillRect(color.getX(), color.getY(), 2*color.getWidth(), color32.getY() - color.getY());
xPoints[0] = 500;
yPoints[0] = 500;
xPoints[1] = 520;
yPoints[1] = 500;
xPoints[2] = 520;
yPoints[2] = 480;
xPoints[3] = 540;
yPoints[3] = 480;
xPoints[4] = 540;
yPoints[4] = 500;
xPoints[5] = 560;
yPoints[5] = 500;
xPoints[6] = 560;
yPoints[6] = 510;
xPoints[7] = 540;
yPoints[7] = 510;
xPoints[8] = 540;
yPoints[8] = 560;
xPoints[9] = 520;
yPoints[9] = 560;
xPoints[10] = 520;
yPoints[10] = 510;
xPoints[11] = 500;
yPoints[11] = 510;
xPoints2[0] = 600;
yPoints2[0] = 500;
xPoints2[1] = 620;
yPoints2[1] = 500;
xPoints2[2] = 620;
yPoints2[2] = 480;
xPoints2[3] = 640;
yPoints2[3] = 480;
xPoints2[4] = 640;
yPoints2[4] = 500;
xPoints2[5] = 660;
yPoints2[5] = 500;
xPoints2[6] = 660;
yPoints2[6] = 510;
xPoints2[7] = 640;
yPoints2[7] = 510;
xPoints2[8] = 640;
yPoints2[8] = 560;
xPoints2[9] = 620;
yPoints2[9] = 560;
xPoints2[10] = 620;
yPoints2[10] = 510;
xPoints2[11] = 600;
yPoints2[11] = 510;
xPoints3[0] = 700;
yPoints3[0] = 500;
xPoints3[1] = 720;
yPoints3[1] = 500;
xPoints3[2] = 720;
yPoints3[2] = 480;
xPoints3[3] = 740;
yPoints3[3] = 480;
xPoints3[4] = 740;
yPoints3[4] = 500;
xPoints3[5] = 760;
yPoints3[5] = 500;
xPoints3[6] = 760;
yPoints3[6] = 510;
xPoints3[7] = 740;
yPoints3[7] = 510;
xPoints3[8] = 740;
yPoints3[8] = 560;
xPoints3[9] = 720;
yPoints3[9] = 560;
xPoints3[10] = 720;
yPoints3[10] = 510;
xPoints3[11] = 700;
yPoints3[11] = 510;
gr.setColor(brown);
gr.drawPolygon(xPoints, yPoints, 12);
gr.fillPolygon(xPoints, yPoints, 12);
gr.drawPolygon(xPoints2, yPoints2, 12);
gr.fillPolygon(xPoints2, yPoints2, 12);
gr.drawPolygon(xPoints3, yPoints3, 12);
gr.fillPolygon(xPoints3, yPoints3, 12);
gr.drawLine(500, 300, 900, 300);
gr.drawLine(500, 300, 500, 450);
gr.drawLine(500, 450, 900, 450);
gr.drawLine(900, 450, 900, 300);
gr.drawString("WELCOME TO LIVING HYMNS SONG SELECTOR", 560, 380);
gr.drawOval(520, 370, 15, 15);
gr.fillOval(520, 370, 15, 15);
gr.drawLine(530, 385, 530, 350);
gr.drawOval(850, 370, 15, 15);
gr.fillOval(850, 370, 15, 15);
gr.drawLine(860, 385, 860, 350);
gr.drawLine(530, 350, 860, 350);
gr.drawLine(530, 361, 860, 361);
if (gr instanceof Serializable)
{
System.out.println("Perhaps the graphics are ok");
}
else
{
System.out.println("The graphics aren't serializing");
}
}
private void writeObject(java.io.ObjectOutputStream stream)
throws IOException{
}
}