package LoginSystem;
import java.awt.*;
import java.io.*;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.*;
public class Data
{
private MainFrame mainFrame;
public MainFrame getMain()
{
return mainFrame;
}
// public String[] imgURL = new String[500];
public String[] defaultPaths = new String[] {"http://www.javaprogrammingforums.com/images/indasupport.png",
"http://www.javaprogrammingforums.com/images/exit.jpg",
"http://www.javaprogrammingforums.com/images/createuser.jpg",
"http://www.javaprogrammingforums.com/images/terminateuser.jpg",
"http://www.javaprogrammingforums.com/images/admin.jpg",
"http://www.javaprogrammingforums.com/images/login.jpg",
"http://www.javaprogrammingforums.com/images/logout.jpg",
"http://www.javaprogrammingforums.com/images/unlocked.jpg",
"http://www.javaprogrammingforums.com/images/locked.jpg",
"http://www.javaprogrammingforums.com/images/changePassword.jpg",
"http://www.javaprogrammingforums.com/images/changeInterface.jpg",
"http://www.javaprogrammingforums.com/images/checked.jpg",
"http://www.javaprogrammingforums.com/images/unchecked.jpg",
"http://www.javaprogrammingforums.com/images/confirm.jpg",
"http://www.javaprogrammingforums.com/images/cancel.jpg",
"http://www.javaprogrammingforums.com/images/miniconfirm.jpg",
"http://www.javaprogrammingforums.com/images/minicancel.jpg",
"http://www.javaprogrammingforums.com/images/print.jpg",
"http://www.javaprogrammingforums.com/images/info.jpg",
"http://www.javaprogrammingforums.com/images/default.jpg",
"http://www.javaprogrammingforums.com/images/swedish.jpg",
"http://www.javaprogrammingforums.com/images/english.jpg"
};
//public String[] imgURLRollover = new String[500];
public String[] defaultPathsRollover = new String[] {"http://www.javaprogrammingforums.com/images/indasupport.png",
"http://www.javaprogrammingforums.com/images/exitRollover.jpg",
"http://www.javaprogrammingforums.com/images/createuserRollover.jpg",
"http://www.javaprogrammingforums.com/images/terminateuserRollover.jpg",
"http://www.javaprogrammingforums.com/images/adminRollover.jpg",
"http://www.javaprogrammingforums.com/images/loginRollover.jpg",
"http://www.javaprogrammingforums.com/images/logoutRollover.jpg",
"http://www.javaprogrammingforums.com/images/unlockedRollover.jpg",
"http://www.javaprogrammingforums.com/images/lockedRollover.jpg",
"http://www.javaprogrammingforums.com/images/changePasswordRollover.jpg",
"http://www.javaprogrammingforums.com/images/changeInterfaceRollover.jpg",
"http://www.javaprogrammingforums.com/images/checked.jpg",
"http://www.javaprogrammingforums.com/images/unchecked.jpg",
"http://www.javaprogrammingforums.com/images/confirmRollover.jpg",
"http://www.javaprogrammingforums.com/images/cancelRollover.jpg",
"http://www.javaprogrammingforums.com/images/miniconfirmRollover.jpg",
"http://www.javaprogrammingforums.com/images/minicancelRollover.jpg",
"http://www.javaprogrammingforums.com/images/print.jpg",
"http://www.javaprogrammingforums.com/images/infoRollover.jpg",
"http://www.javaprogrammingforums.com/images/defaultRollover.jpg",
"http://www.javaprogrammingforums.com/images/swedish.jpg",
"http://www.javaprogrammingforums.com/images/english.jpg"
};
//public String[] imgURLPressed = new String[500];
public String[] defaultPathsPressed = new String[] {"http://www.javaprogrammingforums.com/images/indasupport.png",
"http://www.javaprogrammingforums.com/images/exitPressed.jpg",
"http://www.javaprogrammingforums.com/images/createuserPressed.jpg",
"http://www.javaprogrammingforums.com/images/terminateuserPressed.jpg",
"http://www.javaprogrammingforums.com/images/adminPressed.jpg",
"http://www.javaprogrammingforums.com/images/loginPressed.jpg",
"http://www.javaprogrammingforums.com/images/logoutPressed.jpg",
"http://www.javaprogrammingforums.com/images/unlockedPressed.jpg",
"http://www.javaprogrammingforums.com/images/lockedPressed.jpg",
"http://www.javaprogrammingforums.com/images/changePasswordPressed.jpg",
"http://www.javaprogrammingforums.com/images/changeInterfacePressed.jpg",
"http://www.javaprogrammingforums.com/images/checked.jpg",
"http://www.javaprogrammingforums.com/images/unchecked.jpg",
"http://www.javaprogrammingforums.com/images/confirmPressed.jpg",
"http://www.javaprogrammingforums.com/images/cancelPressed.jpg",
"http://www.javaprogrammingforums.com/images/miniconfirmPressed.jpg",
"http://www.javaprogrammingforums.com/images/minicancelPressed.jpg",
"http://www.javaprogrammingforums.com/images/print.jpg",
"http://www.javaprogrammingforums.com/images/infoPressed.jpg",
"http://www.javaprogrammingforums.com/images/defaultPressed.jpg",
"http://www.javaprogrammingforums.com/images/swedish.jpg",
"http://www.javaprogrammingforums.com/images/english.jpg"
};
// 00 Logo
// 01 exit button
// 02 create user button
// 03 terminate user button
// 04 admin button
// 05 login button
// 06 logout button
// 07 logged in image
// 08 logged out image
// 09 change password button
// 10 change interface button
// 11 checkbox checked button
// 12 checkbox unchecked button
// 13 confirm button
// 14 cancel button
// 15 miniconfirm button
// 16 minicancel button
// 17 print button
// 18 info button
// 19 default button
// 20 swedish button
// 21 english button
String textFrameSwedish = "Välkommen till Inda Support!" + "\n"
+ "I det här programmet så kan du skapa ditt nya användarkonto genom att " + "\n"
+ "trycka på 'create account' nedan. Där blir du ombedd att fylla i ditt" + "\n"
+ "förnamn, efternamn och det lösenord som du vill ha. När du är klar så" + "\n"
+ "är det bara att trycka på enter, så kommer ditt nya konto att vara skapat." + "\n"
+ "\n"
+ "För att sedan logga in på ditt konto så trycker du på den lilla rutan som" + "\n"
+ "är till vänster om ditt namn, du hittar ditt konto i rutan till vänster." + "\n"
+ "Om du inte kan hitta ditt namn bland alla andra konton så behöver du nog scrolla" + "\n"
+ "ner lite grann först." + "\n"
+ "\n"
+ "När du tryckt på knappen så kommer en ny ruta upp, du trycker då helt enkelt på" + "\n"
+ "'Log in' knappen och skriver in ditt lösenord, så märker du att rutan till vänster" + "\n"
+ "om ditt konto har blivit grön för att signalera att du loggat in." + "\n"
+ "Stäng sedan ditt kontofönster genom att trycka på exit." + "\n"
+ "\n"
+ "När du sedan behöver logga ut för dagen så gör du precis likadant, tryck" + "\n"
+ "på knappen till vänster om ditt konto, tryck på logga ut knappen och skriv" + "\n"
+ "återigen in ditt lösenord. Stäng sedan ditt kontofönster genom att trycka på exit." + "\n";
String textFrameEnglish = "Welcome to Inda Support!" + "\n"
+ "In this program you will be able to create your new user account by" + "\n"
+ "pressing the 'create account' button below. There you will be asked to enter your" + "\n"
+ "first name, last name and the password that you want to use. When you are done" + "\n"
+ "all you need to do is press enter, and your new account will be created." + "\n"
+ "\n"
+ "To then log in you press the small button to the left of your name, which you can" + "\n"
+ "find in the left frame next to this one." + "\n"
+ "If you can not find your name amongst all of the other names you will probably have to" + "\n"
+ "scroll down a bit first.." + "\n"
+ "\n"
+ "When you've pressed the button a new frame will appear, then all you need to do is press the" + "\n"
+ "'Log in' button and enter your password, you will notice that the frame to your left of your account" + "\n"
+ "name has turned green to show that you're online." + "\n"
+ "When you're done you can close down your account frame by pressing exit." + "\n"
+ "\n"
+ "When you wish to log out for the day you proceed the same way as before, press" + "\n"
+ "the button to the left of your account, press the logout button and enter your password again." + "\n"
+ "Close your account frame by pressing exit." + "\n";
public String[] defaultEnglishTextMessages = new String[]{
textFrameEnglish, //00
"Welcome to Inda Support Login!", //01
"Users:", //02
"Enter password", //03
"Incorrect password", //04
"First name:", //05
"Last name:", //06
"Password:", //07
"Repeat password:", //08
"Are you sure you wish to cancel?", //09
"Admin password:", //10
"Toggle setting:", //11
"Admin functions:", //12
"Only admins can create new accounts.", //13
"Only admins can terminate accounts.", //14
"Only admins can change language.", //15
"Start date:", //16
"End date:", //17
"Please enter your current password as well as the new one:", //18
"Current password:", //19
"New password:", //20
"Repeat new password:", //21
};
public String[] defaultSwedishTextMessages = new String[]{
textFrameSwedish,
"Välkommen till Inda Support Login!",
"Användare:",
"Ange lösenord:",
"Inkorrekt lösenord!",
"Förnamn:",
"Efternamn:",
"Lösenrd:",
"Upprepa lösenord:",
"Är du säker på att du vill avbryta?",
"Admin lösenord:",
"Ändra inställningar:",
"Admin funktioner:", //12
"Endast admins kan skapa nya konton.",
"Endast admins kan ta bort konton.",
"Endast admins kan ändra språk.",
"Start datum:",
"Slut datum:",
"Var god och skriv in ditt nuvarande lösenord samt ditt nya:",
"Nuvarande lösenord:",
"Nytt lösenord:",
"Upprepa nytt lösenord:",
};
public String[] defaultMixedTextMessages = new String[]{
textFrameSwedish,
"Welcome to Inda Support Login!",
"Users:",
"Enter password",
"Incorrect password",
"First name:",
"Last name:",
"Password:",
"Repeat password:",
"Are you sure you wish to cancel?",
"Admin password:",
"Toggle setting:",
"Admin functions:", //12
"Only admins can create new accounts.",
"Only admins can terminate accounts.",
"Only admins can change language.",
"Start date:",
"End date:",
"Please enter your current password as well as the new one:",
"Current password:",
"New password:",
"Repeat new password:",
};
public String[] englishMessages = new String[500];
public String[] swedishMessages = new String[500];
public String[] mixedMessages = new String[500];
public String[] shownMessages = new String[500];
public int numberOfImagesUsed = defaultPaths.length;
public int numberOfTextMessagesUsed = defaultEnglishTextMessages.length;
URL imgURL[] = new URL[numberOfImagesUsed];
URL imgURLPressed[] = new URL[numberOfImagesUsed];
URL imgURLRollover[] = new URL[numberOfImagesUsed];
public int[] imageSizeX = new int[5000];
public int[] defaultImageSizeX = new int[]{ 225, // 00 Logo
188, // 01 Exit button
188, // 02 create user button
188, // 03 terminate user button
188, // 04 admin button
188, // 05 login button
188, // 06 logout button
30, // 07 logged in button
30, // 08 logged out button
112, // 09 change password button
112, // 10 change interface button
30, // 11 checkbox checked button
30, // 12 checkbox unckecked button
188, // 13 confirm button
188, // 14 cancel button
78, // 15 miniconfirm button
78, // 16 minicancel button
100, // 17 print button
30, // 18 info button
78, // 19 default button
30, // 20 swedish button
30 // 21 english button
};
public int[] imageSizeY = new int[5000];
public int[] defaultImageSizeY = new int[]{ 78, // 00 Logo
68, // 01 Exit button
68, // 02 create user button
68, // 03 terminate user button
68, // 04 admin button
68, // 05 login button
68, // 06 logout button
30, // 07 logged in button
30, // 08 logged out button
97, // 09 change password button
97, // 10 change interface button
30, // 11 checkbox checked button
30, // 12 checkbox unckecked button
68, // 13 confirm button
68, // 14 cancel button
48, // 15 miniconfirm button
48, // 16 minicancel button
80, // 17 print button
30, // 18 info button
48, // 19 default button
30, //20 swedish button
30 // 21 english button
};
public ImageIcon[] imageIcons = new ImageIcon[500];
public ImageIcon[] imageIconsRollover = new ImageIcon[500];
public ImageIcon[] imageIconsPressed = new ImageIcon[500];
public Data(MainFrame main)
{
mainFrame = main;
updateData();
}
public void updateData()
{
String temp = "";
try {
for(int i = 0; i < numberOfImagesUsed; i++)
{
if(imgURL[i] == null)
{
imgURL[i] = Data.class.getResource(defaultPaths[i]);
}
if(imgURLRollover[i] == null)
{
imgURLRollover[i] = Data.class.getResource(defaultPathsRollover[i]);
}
if(imgURLPressed[i] == null)
{
imgURLPressed[i] = Data.class.getResource(defaultPathsPressed[i]);
//JOptionPane.showMessageDialog(null,imgURLPressed[i]);
}
if(imageSizeX[i] == 0)
{
imageSizeX[i] = defaultImageSizeX[i];
}
if(imageSizeY[i] == 0)
{
imageSizeY[i] = defaultImageSizeY[i];
}
temp = temp + i + imgURL[i] + "\n";
Image oldImage = ImageIO.read(imgURL[i]);
Image newImage = oldImage.getScaledInstance(imageSizeX[i], imageSizeY[i], java.awt.Image.SCALE_SMOOTH);
imageIcons[i] = new ImageIcon();
imageIcons[i].setImage(newImage);
oldImage = ImageIO.read(imgURLRollover[i]);
newImage = oldImage.getScaledInstance(imageSizeX[i], imageSizeY[i], java.awt.Image.SCALE_SMOOTH);
imageIconsRollover[i] = new ImageIcon();
imageIconsRollover[i].setImage(newImage);
oldImage = ImageIO.read(imgURLPressed[i]);
newImage = oldImage.getScaledInstance(imageSizeX[i], imageSizeY[i], java.awt.Image.SCALE_SMOOTH);
imageIconsPressed[i] = new ImageIcon();
imageIconsPressed[i].setImage(newImage);
}
for(int i = 0; i < numberOfTextMessagesUsed; i++)
{
if(englishMessages[i] == "" || englishMessages[i] == null)
{
englishMessages[i] = defaultEnglishTextMessages[i];
}
if(swedishMessages[i] == "" || swedishMessages[i] == null)
{
swedishMessages[i] = defaultSwedishTextMessages[i];
}
if(mixedMessages[i] == "" || mixedMessages[i] == null)
{
mixedMessages[i] = defaultMixedTextMessages[i];
}
if(mainFrame.languageUsed == 0)
{
shownMessages[i] = englishMessages[i];
}else if(mainFrame.languageUsed == 1)
{
shownMessages[i] = swedishMessages[i];
}else if(mainFrame.languageUsed == 2)
{
shownMessages[i] = mixedMessages[i];
}
}
//JOptionPane.showMessageDialog(null,temp);
} catch (IOException e) {
e.printStackTrace();
}
}
}