import java.awt.color.ColorSpace;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.AdjustmentEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.filechooser.FileSystemView;
import javax.swing.text.DefaultStyledDocument;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.util.jar.JarFile;
import java.io.*;
import javax.swing.ImageIcon;
import java.awt.event.WindowEvent;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.awt.Window;
import javax.swing.JScrollPane;
import java.awt.Component;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import acm.io.*;
import acm.graphics.*;
import acm.program.*;
import acm.gui.*;
import acm.util.*;
import java.awt.Container;
import java.awt.PrintJob;
import java.awt.print.*;
/**
* @author Paul
* Begin Date: July 13, 2010
* End Date:
* Project Title: Church Hymn Book Program
* Description: Uses JComboBox to select all songs, shown in alphabetical order. Also, typing in a
* page number will automatically call the setSelected() method to the song with that number.
* Selecting a song will also automatically set the text in the pageNumber text area to that
* page number. There is another JComboBox that will choose colors. Also, there is another
* JTextArea that has verse numbers. That will only display that verse, unless "Display all"
* is checked in JCheckBox check. There will be no exit button, but the JMenuItem exit under the
* JMenu options under JMenuBar menuBar will allow the user to exit. Also, there will be a JComboBox
* for font types and font colors. There will be two more JMenuItem under JMenu options that will
* set the background color and the foreground color of the JPanel, to the color specified in each of the
* sub-items of those two JMenuItems.
*/
public class LivingHymns extends JFrame implements ActionListener,
ItemListener, MenuListener, Printable {
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
int[] pageBreaks;
String[] textLines;
Cursor cursor;
private void initTextLines() {
if (textLines == null) {
int numLines=200;
textLines = new String[numLines];
for (int i=0;i<numLines;i++) {
textLines[i]= "This is line number " + i;
}
}
}
JFileChooser chooser;
JLabel hayField, cottonField, wheatField;
JMenu menu, menu2, helpMenu;
ProgramMenuBar bar;
DefaultStyledDocument document;
JTextArea area;
JCheckBox box;
JComboBox songs, fonts, colors;
JScrollPane scrolls, scrolls2;
String[] songNames;
String[] fontTypes;
boolean printNow;
JMenuItem openHelpMenu;
JLabel clickOnMe;
JLabel cornField;
JLabel riceField;
JTextField beanField;
JScrollBar alphaAdjuster;
String[] colorSelector;
JMenuItem button, button2, button3, button4, button5, button6;
JMenuItem copy;
JTextField pageNumber, verseNumber;
JPanel panel;
String Bob;
JMenuItem print,save;
JFrame frame, frame2;
JRadioButton color, color2, color3, color4, color5, color6, color7, color8, color9, color10,
color11, color12, color13, color31, color32;
ButtonGroup group, group2, group3, group4;
Color red, green, blue, orange, yellow, pink, black, gray, lightGray, darkGray, magenta, cyan,
white, brown, purple;
JLabel background, textBackground, textForeground, pageNum;
JRadioButton color14, color15, color16, color17, color18, color19, color20, color21, color22,
color23, color24, color25, color26, color27, color28, color29, color30, color33, color34;
Choice choice;
PopupMenu popup;
JScrollBar redAdjuster, greenAdjuster, blueAdjuster;
ColorSpace space;
JPopupMenu lollipop, tootsiePop, allDaySucker;
boolean doPrint;
Font Aharoni, Andalus, AngsanaNew, AngsanaUPC, ArabicTypesetting, Arial, ArialBlack, ArialNarrow,
ArialUnicodeMS, Batang, BatangChe, BlackadderITC, BookAntiqua, BookmanOldStyle, BookshelfSymbol7,
BradleyHandITC, BrowalliaNew, BrowalliaUPC, Calibri, Cambria, CambriaMath, Candara, Century,
CenturyGothic, ComicSansMS, Consolas, Constantia, CopperplateGothicBold, CopperplateGothicLight,
Corbel, CordiaNew, CordiaUPC, CourierNew, CSD12, CurlzMT, DaunPenh, David, DFKaiSB, Dialog,
DialogInput, DilleniaUPC, DokChampa, Dotum, DotumChe, EdwardianScriptITC, EngraversMT, ErasDemiITC,
ErasLightITC, EstrangeloEdessa, EucrosiaUPC, Euphemia, Eurostile, FangSong, FelixTitling,
FranklinGothicBook, FranklinGothicDemi, FranklinGothicDemiCond, FranklinGothicHeavy, FranklinGothicMedium,
FranklinGothicMediumCond, FrankRuehl, FreesiaUPC, FreestyleScript, FrenchScriptMT, Garamond, Gautami,
Georgia, GiovanniITCTT, Gisha, Gulim, GulimChe, Gungsuh, GungsuhChe, Impact, IrisUPC, IskoolaPota,
JasmineUPC, Jokerman, JuiceITC, KaiTi, Kalinga, Kartika, KodchiangUPC, KristenITC, Latha, Leelawadee,
LevenimMT, LilyUPC, LucidaBlackletter, LucidaBright, LucidaCalligraphy, LucidaConsole, LucidaHandwriting,
LucidaSans, LucidaSansTypewriter, LucidaSansUnicode, MaiandraGD, MalgunGothic, Mangal, Marlett,
MatisseITC, Meiryo, MeiryoUI, MicrosoftHimalaya, MicrosoftJhengHei, MicrosoftSansSerif, MicrosoftUighur,
MicrosoftYaHei, MicrosoftYiBaiti, MingLiU, MingLiUExtB, MingLiU_HKSCS, MingLiU_HKSCSExtB, Miriam, MiriamFixed,
Mistral, MongolianBaiti, Monospaced, MonotypeCorsiva;
JMenuBar mBar;
PrinterJob job;
PageFormat format;
FileDialog saveDialog, loadDialog;
FileSystemView view;
JFrame saveFrame, openFrame;
FileWriter writer;
JarFile jar;
FileOutputStream river;
/*
1.) Aharoni
2.) Andalus
3.) Angsana New
4.) AngsanaUPC
5.) Arabic Typesetting
6.) Arial
7.) Arial Black
8.) Arial Narrow
9.) Arial Unicode MS
10.) Batang
11.) BatangChe
12.) Blackadder ITC
13.) Book Antiqua
14.) Bookman Old Style
15.) Bookshelf Symbol 7
16.) Bradley Hand ITC
17.) Browallia New
18.) BrowalliaUPC
19.) Calibri
20.) Cambria
21.) Cambria Math
22.) Candara
23.) Century
24.) Century Gothic
25.) Comic Sans MS
26.) Consolas
27.) Constantia
28.) Copperplate Gothic Bold
29.) Copperplate Gothic Light
30.) Corbel
31.) Cordia New
32.) CordiaUPC
33.) Courier New
34.) CSD12
35.) Curlz MT
36.) DaunPenh
37.) David
38.) DFKai-SB
39.) Dialog
40.) DialogInput
41.) DilleniaUPC
42.) DokChampa
43.) Dotum
44.) DotumChe
45.) Edwardian Script ITC
46.) Engravers MT
47.) Eras Demi ITC
48.) Eras Light ITC
49.) Estrangelo Edessa
50.) EucrosiaUPC
51.) Euphemia
52.) Eurostile
53.) FangSong
54.) Felix Titling
55.) Franklin Gothic Book
56.) Franklin Gothic Demi
57.) Franklin Gothic Demi Cond
58.) Franklin Gothic Heavy
59.) Franklin Gothic Medium
60.) Franklin Gothic Medium Cond
61.) FrankRuehl
62.) FreesiaUPC
63.) Freestyle Script
64.) French Script MT
65.) Garamond
66.) Gautami
67.) Georgia
68.) GiovanniITCTT
69.) Gisha
70.) Gulim
71.) GulimChe
72.) Gungsuh
73.) GungsuhChe
74.) Impact
75.) IrisUPC
76.) Iskoola Pota
77.) JasmineUPC
78.) Jokerman
79.) Juice ITC
80.) KaiTi
81.) Kalinga
82.) Kartika
83.) KodchiangUPC
84.) Kristen ITC
85.) Latha
86.) Leelawadee
87.) Levenim MT
88.) LilyUPC
89.) Lucida Blackletter
90.) Lucida Bright
91.) Lucida Calligraphy
92.) Lucida Console
93.) Lucida Handwriting
94.) Lucida Sans
95.) Lucida Sans Typewriter
96.) Lucida Sans Unicode
97.) Maiandra GD
98.) Malgun Gothic
99.) Mangal
100.) Marlett
101.) Matisse ITC
102.) Meiryo
103.) Meiryo UI
104.) Microsoft Himalaya
105.) Microsoft JhengHei
106.) Microsoft Sans Serif
107.) Microsoft Uighur
108.) Microsoft YaHei
109.) Microsoft Yi Baiti
110.) MingLiU
111.) MingLiU-ExtB
112.) MingLiU_HKSCS
113.) MingLiU_HKSCS-ExtB
114.) Miriam
115.) Miriam Fixed
116.) Mistral
117.) Mongolian Baiti
118.) Monospaced
119.) Monotype Corsiva
120.) MoolBoran
121.) MS Gothic
122.) MS Mincho
123.) MS PGothic
124.) MS PMincho
125.) MS Reference 1
126.) MS Reference 2
127.) MS Reference Sans Serif
128.) MS Reference Specialty
129.) MS UI Gothic
130.) MT Extra
131.) MV Boli
132.) Narkisim
133.) NSimSun
134.) Nyala
135.) OCR A Extended
136.) Palatino Linotype
137.) Papyrus
138.) Perpetua
139.) Plantagenet Cherokee
140.) PMingLiU
141.) PMingLiU-ExtB
142.) Poor Richard
143.) Pristina
144.) Raavi
145.) Rockwell
146.) Rockwell Extra Bold
147.) Rod
148.) SansSerif
149.) Segoe Print
150.) Segoe Script
151.) Segoe UI
152.) Serif
153.) Shruti
154.) SimHei
155.) Simplified Arabic
156.) Simplified Arabic Fixed
157.) SimSun
158.) SimSun-ExtB
159.) Sylfaen
160.) Symbol
161.) Tahoma
162.) Tempus Sans ITC
163.) Times New Roman
164.) Traditional Arabic
165.) Trebuchet MS
166.) Tunga
167.) Verdana
168.) Viner Hand ITC
169.) Vivaldi
170.) Vrinda
171.) Webdings
172.) Wingdings
173.) Wingdings 2
174.) Wingdings 3
*/
JFrame wenguinFrame;
File file;
/**
* @param arg0
*/
/**
*
*/
public LivingHymns() {
setTitle("Living Hymns Song Selection for Shooting Park Road Baptist Church");
wenguinFrame = new JFrame();
saveDialog = new FileDialog(wenguinFrame, "Save", FileDialog.SAVE);
openHelpMenu = new JMenuItem("Open Help Menu");
beanField = new JTextField(5);
saveFrame = new JFrame();
openFrame = new JFrame();
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);
popup = new PopupMenu("Help Menu");
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);
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";
fonts = new JComboBox(fontTypes);
fonts.setBackground(green);
redAdjuster.setBackground(red);
greenAdjuster.setBackground(green);
blueAdjuster.setBackground(blue);
alphaAdjuster.setBackground(green);
pageNumber = new JTextField(3);
pageNum = new JLabel("Enter page number");
panel = new JPanel();
// panel.add(saveDialog);
bar = new ProgramMenuBar();
helpMenu.add(openHelpMenu);
menu = new JMenu("File");
menu.add(save);
save.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
// saveDialog.setVisible(true);
file = new File("C:/hymns.jar");
chooser = new JFileChooser();
chooser.setBackground(Color.GREEN);
chooser.setVisible(true);
chooser.showSaveDialog(openFrame);
}
});
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);
print = new JMenuItem("Print");
menu.add(print);
printNow = false;
print.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
printNow = true;
job = PrinterJob.getPrinterJob();
job.setPrintable(new LivingHymns());
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.setSize(20, 30);
panel.add(popup);
panel.setVisible(true);
pageNum.setVisible(true);
pageNumber.setVisible(true);
panel.add(pageNum);
panel.add(pageNumber);
panel.add(lollipop);
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");
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("Box");
panel.add(box);
box.setVisible(true);
panel.setVisible(true);
panel.add(scrolls);
// frame.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);
// 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);
doPrint = false;
textForeground = new JLabel("Set Color of Text in Text Area");
panel.add(textForeground);
panel.add(colors);
area.setLineWrap(true);
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());
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);
}
}
});
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);
}
});
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);
}
});
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);
}
});
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);
}
});
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());
}
});
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);
}
});
clickOnMe.addMouseListener(
new MouseListener(){
@Override
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
lollipop.setVisible(true);
cornField.setBackground(green);
}
@Override
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
});
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());
}
});
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());
}
});
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
}});
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
} // end of method
});
getContentPane().add(scrolls2);
// TODO Auto-generated constructor stub
}
public void showGUI2(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,300);
setLocation(100,100);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
*/
@Override
public void itemStateChanged(ItemEvent e) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.swing.event.MenuListener#menuCanceled(javax.swing.event.MenuEvent)
*/
@Override
public void menuCanceled(MenuEvent e) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.swing.event.MenuListener#menuDeselected(javax.swing.event.MenuEvent)
*/
@Override
public void menuDeselected(MenuEvent e) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.swing.event.MenuListener#menuSelected(javax.swing.event.MenuEvent)
*/
@Override
public void menuSelected(MenuEvent e) {
// TODO Auto-generated method stub
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
LivingHymns hymn = new LivingHymns();
hymn.showGUI2();
}
@Override
public int print(Graphics g, PageFormat pf, int pageIndex)
throws PrinterException {
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;
}
}