Login Applet Help

Hello
I am trying to write a applet that allows me to login to a particular page on my site. I am new to java and have looked some books on the subject. I thought I would be able to manage it myself but I cant for the life of me do it.
Here is the code I have written:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
<applet code="pass" width=300 height=80>
</applet>
public class pass extends Applet implements ActionListener{
     Label lbl1;
     Button btn1;
     TextField txa1;
     public void init(){
          lbl1= new Label("Please enter your password!");
          btn1= new Button("ok");
          txa1= new TextField("",20);
          add(txa1);
          add(btn1);
          add(lbl1);
          btn1.addActionListener(this);
     public void actionPerformed(ActionEvent ae){
          if(txa1 == 'will'){
          lbl1.setText("Password Accepted");
          //**GOTO A CORRECT URL
          else{
          lbl1.setText("Password Incorrect");
          //**GOTO REJECT URL
How can I get it to check the password entered? Also how the hell do get it to go to a URL???
Any help would be appreciated.
Regards
Jimmy

(1) Use the getText() method of TextField to get the data typed into the TextField. Returns a String
(2) Use the equals() method of class String to compare the String returned by the above with the password
(3) Use the Applet method getAppletContext() to return a reference to the browser.
(4) Use the AppletContext method showDocument() to redirect the browser to a new page.
public void actionPerformed(ActionEvent ae)
if(txa1.getText().equals("will"))
    lbl1.setText("Password Accepted");
    try
        URL url = new URL("http://www.thePageIwantToView.com");
        getAppletContext.showDocument(url);
    catch (MalformedUrlException muex)
       System.out.println(muex.toString());

Similar Messages

  • Help creating a login applet with JDBC

    Hi, I'm trying to create a login applet using a table from a database (created with Microsoft Access). The bottom line is that I have very little knowledge of ActionListeners. I do know some things about JDBC, but most of it is through notes and lots of reading. I was wondering how to go about looking through a table (with two columns, user and password), to see if it matches what is typed into a JTextField and a JPasswordField. Just a sample piece of code would be helpful. Thank you very much in advanced. Also, I have the GUI done for what I need, just no ActionListeners or JDBC functionality implemented. Here it is:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.sql.*;
    public class login extends JFrame /*implements ActionListener*/ {
         private Container container;
         private GridBagLayout layout;
         private GridBagConstraints gbc;
         public login()
              super("Login");
              setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            setSize(300,130);
            setLocationRelativeTo(null);
              container = getContentPane();
              layout = new GridBagLayout();
              container.setLayout(layout);
              gbc = new GridBagConstraints();
              labelUser = new JLabel("Username:");
              gbc.insets = new Insets(2,2,2,2);
              container.add(labelUser, gbc);
              textUser = new JTextField(15);
              gbc.gridx = 1;
              gbc.gridwidth = 3;
              container.add(textUser, gbc);
              labelPassword = new JLabel("Password:");
              gbc.gridy = 1;
              gbc.gridx = 0;
              gbc.gridwidth = 1;
              container.add(labelPassword, gbc);
              textPassword = new JPasswordField(15);
              gbc.gridx = 1;
              gbc.gridwidth = 3;
              container.add(textPassword, gbc);
              button1 = new JButton("Login");
              gbc.gridy = 2;
              gbc.gridx = 1;
              gbc.gridwidth = 1;
              container.add(button1, gbc);
              button2 = new JButton("Cancel");
              gbc.gridx = 2;
              container.add(button2, gbc);
         public static void main(String args[]) {
            new login().setVisible(true);
        private JButton button1, button2;
        private JLabel labelUser, labelPassword;
        private JTextField textUser;
        private JPasswordField textPassword;
    }Thank you again in advanced.

    Sir,
    Much of your question makes middling sense to me. You say applet but you have JFrame for example. I would caution you right now an applet with access for a DB is asking for trouble. Never minding the various security issues Access is not really intended for this sort of operation.
    Now none of that actually seems to be your question but I just thought I'd address that before you go too far down a road fraught with peril.
    As far as what I think you are asking assuming our table looks like this.
    tblUser
    username VARCHAR (access text field) primary key
    password VARCHAR (again known in access as text)then the code would look something like this...
    Connection c; //create your connection
    PreparedStatement ps = c.prepareStatement("SELECT username FROM tblUser WHERE username=? AND password=?");
    ps.setString(1,usernameVariable);
    ps.setString(2,passwordVariable);
    ResultSet rs = ps.executeQuery();
    if(rs.next()){
      // login successful
    }else{
      // login failed!
    rs.close();
    ps.close();
    c.close();Also duffymo will be unhappy if I don't mention that you will really want to give second thought to mixing your database code with your GUI code. Please take a gander through http://java.sun.com/blueprints/patterns/MVC.html
    Sincerely,
    Slappy

  • Login Applet

    Hi,
    I m new to Java and was working on creating a login Applet. I have put event handler on submit button . it will check and validate the user name & password with hardcoded one. to login user name is "test' and password is "password".
    if i try with some other user name, it gives message "Wrong user...." as per logic. But when i try to connect with "test" it still gives same error.
    in event handler it is going in else section where i am comapring the user name with "test" however, it should go in true section and validate password.
    given below is my login applet code.. will anybody help me where i am wrong.
    public class login extends java.applet.Applet
         Button submit = new Button("Connect to Server");
         TextField user = new TextField(20);
         TextField pass = new TextField(20);
         Label result_label = new Label("Pls input User Name and Password to Login");
         String user_name = "";
         String pass1 = "";
         public void init()
              user.setEditable(true);
              pass.setEditable(true);
              String result = "";
              GridBagLayout grid = new GridBagLayout();
              GridBagConstraints cons = new GridBagConstraints();
              setLayout(grid);
              setFont(new Font("Times New Roman",Font.PLAIN,12));
              setBackground(Color.orange);
              setForeground(Color.black);
              cons.weightx = 1.0;
              cons.weighty = 0.0;
              cons.anchor = GridBagConstraints.CENTER;
              cons.fill = GridBagConstraints.NONE;
              cons.gridwidth = GridBagConstraints.REMAINDER;
              add(new Label("User Name: "));
              grid.setConstraints(user, cons);
              add(user);
              add(new Label("Password: "));
              grid.setConstraints(pass, cons);
              add(pass);
              result_label.setFont(new Font("Times New Roman", Font.BOLD, 12));
              result_label.setForeground(Color.blue);
              grid.setConstraints(result_label, cons);
              add(result_label);
              grid.setConstraints(submit, cons);
              add(submit);
              cons.weighty = 1.0;
              show();
         public boolean handleEvent(Event evt)
              if (evt.target ==user)
                   char c = (char) evt.key;
                   if (c == '\n')
                        user_name = user.getText();
                        return(true);
                   else
                        return(false);
              if (evt.target == pass )
                   char c = (char) evt.key;
                   if (c == '\n')
                        pass1 = pass.getText();
                        return(true);
                   else
                        return(false);
              if (evt.target == submit)
                   char c = (char) evt.key;
                   if ( c == '\n')
                        double i;
                        i = 1;
                        result_label.setText("Verifing ..............");
                        do { i = i + 0.0001; }while (i <= 8000);
                        user_name = user.getText();
                        if (user_name == "test" )
                             pass1 = pass.getText();
                             if (pass1 == "password")
                                  result_label .setText("Login Sucessfull!!! Connecting to Server...");
                                  return(true);
                             else
                                  result_label .setText("Invalid Password...");
                                  return(false);
                        else
                             String text1 = "Invalid user " + user_name + " Access Not allowed";
                             result_label.setText( text1);
                             return(false);
                   else
                        return(false);
              else
              {     return(false);
         public void destroy()
              try
                   //cons.close();
              catch (Exception e)
                   e.printStackTrace();
                   System.out.println(e.getMessage());
    }

    Use the equals() methods to compare strings.
    if(pass1.equals( "password"))

  • A java login applet

    has anyone created a java login applet (source code) that I could use as an example when I attempt to make one. Thank you.

    What are you logging into? What credentials need to be there?
    Normally in these (sometimes unforgiving) forums you need to post a question, some code, a problem, and then the many fine folks here will help you find the answer.
    What part of your code are you having problems with?
    For tutorials check out the sun tutorials. They are very good.
    Peace

  • Login applet digital signature

    Hello,
    The digital signature of the login applet is only valid from: Wed Sep 01
    02:00:00 CEST 2004 to Fri Sep 02 01:59:59 CEST 2005, so I get a warning
    when I login via Webbrowser. I'm using SGD EE 4.1. Is there an update
    available, or do I have to migrate to 4.2?
    Sincerely,
    Robert Niess

    I am also having a problem with the SGD login applet signature being outdated? Is there any patch to this issue? It may be related to another issue I am having.

  • My computer was trying to connect to my Bluetooth mouse but I accidentally hit cancel so now my computer won't connect to my mouse. I turned my computer off. When I turned it back on it still won't connect and I can't login! Help!

    NEED URGENT HELP!
    My computer was trying to connect to my Bluetooth mouse but I accidentally hit cancel so now my computer won't connect to my mouse. I turned my computer off. When I turned it back on it still won't connect and I can't login! Help!

    Reset the SMC.
    Barry

  • Simple button applet help

    ok, i'm working on a project involving buttons, and i finished it and it compiles fine, but when i run the applet (using textpad), nothign shows up.
    i decided to make a new applet of only the frame and buttons, and i got the same problem. here is the simple one.
    import java.util.*;
    import java.applet.Applet;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    public class framek extends JApplet
         public static final int WIDTH = 600;
         public static final int HEIGHT = 300;
         public void framek()
              JFrame myWindow = new JFrame();
              myWindow.setSize(WIDTH, HEIGHT);
         Container contentPane = myWindow.getContentPane();
              contentPane.setBackground(Color.blue);
              contentPane.setLayout(new BorderLayout());
              JPanel button = new JPanel();
              button.setLayout(new FlowLayout());
              JButton convert = new JButton("Translate");
              button.add(convert);
              JButton delete = new JButton("Delete");
              button.add(delete);
              contentPane.add(button, BorderLayout.SOUTH);
    i might have made some mistakes in the shortening of my project (such as variables that arent used) but i just need help with getting the buttons and background things to show. I used very similar programs in a textbook and on the web to check and they worked fine on textpad, and this doesnt. its probably a very simple thing that i forgot but i cant find it yet, as i am fairly new to swing.
    any help is appreciated thanks

    /*  <applet code="HelloApplet" width="600" height="300"></applet>
    *  use: >appletviewer HelloApplet.java
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class HelloApplet extends JApplet
        public static final int WIDTH = 600;
        public static final int HEIGHT = 300;
        public void init()
            Container contentPane = getContentPane();
            contentPane.setBackground(Color.blue);
            contentPane.setLayout(new BorderLayout());
            JPanel button = new JPanel();
            button.setLayout(new FlowLayout());
            JButton convert = new JButton("Translate");
            button.add(convert);
            JButton delete = new JButton("Delete");
            button.add(delete);
            contentPane.add(button, BorderLayout.SOUTH);
        /** this is a convenience method */
        public static void main(String[] args)
            JApplet applet = new HelloApplet();
            JFrame myWindow = new JFrame();
            myWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            myWindow.add(applet);
            myWindow.setSize(WIDTH, HEIGHT);
            myWindow.setLocation(200,200);
            applet.init();
            myWindow.setVisible(true);
    }

  • New Users Not Appearing On Login List - Help!

    Hello Mac geniuses,
    I run a 10.3.9 network in an elementary school, and I since returning from summer vacation I have had problems with many of my client eMacs not displaying the names of users I have added in WGM. These eMacs are also still displaying the names of accounts I have deleted.
    If anyone is kind enough to help a stranger, I have copied below the transcripts of my email exchanges with an Apple tech, in my struggle to get my school functioning again. (I have placed them in the correct order so the 1st email is on top and the last on bottom. The tech's name is John and I am using "Jon" to make it slightly less confusing!).
    My very grateful thanks in advance to anyone who can help me.
    Jon
    On Sep 5, 2006, at 3:28 PM, Jon T wrote:
    Hi John,
    After deleting and adding users in WGM, some login screens still show deleted users and do not display the new users.
    I tried deleting the MCX cache via NetInfoManager on the clients, and even restarted the server, but it has not affected several machines.
    Any advice?
    Server: Dual 1Ghz G4 (Mirror Door) running Panther Server 10.3.9
    Clients: eMacs running 10.3.9
    Thanks in advance.
    On Sep 5, 2006, at 3:47 PM, John G wrote:
    Jon,
    Go into the client as the admin account.
    Delete /Library/Preferences/Directory Service
    Restart and setup Directory Access in Utilities
    Let me know if that works.
    John
    On Sep 6, 2006, at 9:08 AM, Jon T wrote:
    Hi John,
    Thanks for replying. unfortunately, that didn't work either . . . 
    Jon
    On Sep 6, 2006, at 2:03 PM, John G wrote:
    Jon,
    Are you sure the machine is on the network and talking to your
    server?
    Go into Dir Access and uncheck LDAP and readd the server.
    On Sep 6, 2006, at 4:07 PM, Jon T wrote:
    Hi John,
    Yeah, they're on the network, students can log in using the "Other" option, I can connect to the server and mount shared folders, etc.
    I did as you said, rebooted, still no updated list.
    Jon
    On Sep 6, 2006, at 8:57 PM, John G wrote:
    Jon,
    Netinfo is probably corrupt.
    Follow these directions to blow out Netinfo to create a new one.
    Bind back to server.
    <OS X frozen while booting.pdf>:
    AFP548.com: Articles: NetInfo Recovery Techniques
    NetInfo Recovery Techniques
    Joel Rennich, [email protected]
    4 June 2002
    When working with NetInfo, which we are and hope to have some more articles on in the near future, it is important to know
    how to back up to a previous version of your database.
    1. First, the most brutal way of recovering from a nonfunctional database.
    Boot into single user mode by holding down the "s" key while starting up. Follow the handy instructions Apple gives you at the end of the startup sequence and run fsck. Then mount the system root disk as read/write with:
    mount -uw /
    Now you can get on with recreating your database in a very brutal way. Remove your current database with:
    rm -rf /var/db/netinfo/local.nidb
    Now remove the file that prevents the Setup Assistant from running:
    m /var/db/.AppleSetupDone
    And now reboot to get things rolling.
    reboot
    This will cause the Setup Assistant to launch, complete with music and bouncing blue blobs. If you remember which account you set up first when you last saw this screen, set up that account now. Otherwise, go with whatever you want for your first
    Administrator account. If you match it up with the original Administrator account, all of your permissions should be groovy.
    Otherwise, get familiar with chown and chmod and you will be able to set things right.
    The above method is rather draconian and isn't for times when you need to replace a complicated NetInfo setup, but should work perfectly well for an essentially single user machine. However that probably rules out most Servers.
    On Sep 7, 2006, at 8:15 AM, Jon T wrote:
    Hi John,
    I performed that protocol, but even that didn't fix the problem!
    I know I've heard someone once suggest (in a moment of resignation) that I just use the blank name and password fields at login, but this is not really an option in elementary school. I only have 478 users in WGM, so I can't believe that would be too taxing for OS X Server!
    Thanks again for your thoughts on this.
    Regards,
    Jon
    On Sep 7, 2006, at 9:53 PM, John G wrote:
    Jon,
    The last resort is to reimage.
    Are you managing computers by Guest computers or
    computer groups?
    John, we're talking about 23 computers here - re-imaging is not an option for me alone unless I have some technical assistance (I don't know how to 'ghost' images across a network).
    I was managing the users by Groups though I did have a list of the computers called "lab computers". I just noticed that when I try accessing the Computers tab in WGM (whether on my teacher's station or on the server itself) I get the same error message:
    Got Unexpected Errror
    Error of type -14136 on line 432 of
    ComputerListPluginView.mm
    Please advise!
    Thank you again,
    Jon

    The list of users is a plist file and should be at at /Library/Preferences/com.apple.loginwindow.plist on the clients. See this thread for more information:
    http://discussions.apple.com/thread.jspa?messageID=2368769&#2368769
    If you've got a good plist from a client that sees the right users, you should be able to copy it over. If not, try backing up the file from one client and then deleting it and restarting.

  • Cant figure out whats wrong with my applet, help pls??

    this applet checks a string against one in a database then if passwords match, a new url is opened. the applet loads in webpage with no problems. it just doesnt seem to work. have granted full access to code base in policy file.
    heres the code:
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.applet.*;
    import java.sql.*;
    import java.net.*;
    public class LoginApplet extends Applet implements ActionListener
        Panel top;
        Panel bottom;
        TextField nameField;
        TextField passField;
        Label userNameLabel;
        Label passwordLabel;
        Button loginButton;
        public void init()
            setSize(230,200);
            setBackground(Color.white);
            // Create panels, labels, and text fields
            top                = new Panel(new FlowLayout(FlowLayout.LEFT));
            bottom                = new Panel(new FlowLayout(FlowLayout.LEFT));
            nameField           = new TextField(15);
            passField           = new TextField(15);
            userNameLabel      = new Label("User Name:", Label.LEFT);
            passwordLabel      = new Label("Password:   ", Label.LEFT);
            loginButton          = new Button("Login:");
            loginButton.addActionListener(this);
            // Mask the input so that people looking over your shoulder
            // won't be able to see the password
            passField.setEchoChar('*');
            // Add items to their panels
            top.add(userNameLabel);
            top.add(nameField);
            top.add(passwordLabel);
            top.add(passField);
            bottom.add(loginButton);
            // Set the applet layout
            setLayout(new GridLayout(3,3));
            // Add the panels to the applet (skip this
            // part and you won't see the panels on screen)
            add(top);
            add(bottom);
        public void actionPerformed(ActionEvent e)
                   String name      = nameField.getText();
                   String pass      = passField.getText();
                   try
                        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                        // set this to a MS Access DB
                        String filename = "e:/iain/College/Y4/SWP/Program/website/database/loginDetails.mdb";
                        String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
                        database+= filename.trim() + ";DriverID=22;READONLY=true}"; // add on to the end
                        // now we can get the connection from the DriverManager
                        Connection con = DriverManager.getConnection( database ,"","");
                        Statement s = con.createStatement();
                        s.execute(" SELECT [password] FROM logindetails WHERE [username] = '" + name + "' "); // select the data from the table
                        ResultSet rs = s.getResultSet(); // get any ResultSet that came from our query
                        if (rs != null) // if rs == null, then there is no ResultSet to view
                             while ( rs.next() ) // this will step through our data row-by-row
                                  String passtmp = "";
                                  passtmp = passtmp + rs.getString(1);
                                  if(passtmp.equals(pass))
                                       String url = "E:/iain/College/Y4/SWP/Program/website";
                                       Runtime rt = Runtime.getRuntime();
                                       String[] callAndArgs = {"\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"", url };
                                       try
                                            Process child = rt.exec(callAndArgs);
                                            nameField.setText("");
                                            passField.setText("");
                                       catch (Exception eee)
                                            eee.printStackTrace(System.err);
                                  else
                                       System.out.println("Invalid Password " +name);
                                  s.close(); // close the Statement to let the database know we're done with it
                                 con.close(); // close the Connection to let the database know we're done with it
                   catch (Exception ee)
                        System.out.println("Error: " + ee);
    }

    this is the initial error, when applet is run:
    java.security.policy: error adding Entry:
    java.net.MalformedURLException: unknown
    unknown protocol: eI don't know where that's from that code, but e isn't a protocol. If it's a file, you should append "file:///" to the full path.
    then when trying to read from db:
    Error: java.security.AccessControlException: access
    denied (java.lang.RuntimePer
    mission accessClassInPackage.sun.jdbc.odbc)
    didnt think of running it through applet viewer.
    the whole thing will be running on the same server
    using IIS over a LANYou don't connect to a local file system thru an applet without a signed applet. Period.

  • Unexpected Error on login, PLEASE HELP!

    PLEASE HELP!!
    Everytime I try to login to Muse since Beta 7 I get this screen:
    I have already submitted a report and emailed support but I have gotten no answer.
    How can I fix this? I have allowed Muse through my firewall but that doesnt make any difference.

    Pleae try disabling your firewall as suggested here: http://forums.adobe.com/thread/987242

  • Windows 8.1 crashing before login. Help needed.

    I just installed Boot Camp from a Windows 8.1 .iso on a USB drive. I ran all Windows updates, installed AVG free and Google Chrome. Nothing else. Everything was running smoothly during all the restarts and updates. Now, when I reboot from OS X and hold option, I select Windows. The Windows spinning dots start happening, and then it crashes, restarting the machine. Sometimes, it will get all the way to the login screen. If, however, I'm in OS X and shut down the computer, wait a few seconds, hold option, and select Windows, Windows boots up fine. It's a workaround, but before I install everything else (Steam library, Minecraft files, etc.) and use Winclone to back it up, I want rather have it working as it should. 
    Things I've tried:
    1) Starting from scratch: removing the Boot Camp partition and doing a fresh install of everything.
    2) Running CHKDSK from within Windows; everything seems okay.
    3) Reinstalling Boot Camp Utility from within Windows. No change. 
    4) Frowning, grunting, and swearing. 
    It's a mid-2014 MBPr, 2.8 Ghz Intel Core i7 with 16 GB of Ram, a 1 TB hd, and the NVIDIA GeForce GT 750M (2 GB of video RAM), if that helps. 
    I've read more forums and articles than I can count, and the only thing I found was the suggestion to shut it down and reboot that way. Any ideas from folks who know more than I do? Thanks in advance!

    We do need the actual DMP file as it contains the only record of the sequence of events leading up to the crash, what drivers were loaded, and what was responsible.  
    We prefer at least 2 DMP files to spot trends and confirm the cause.
    Please follow our instructions for finding and uploading the files we need to help you fix your computer. They can be found here
    If you have any questions about the procedure please ask
    Wanikiya and Dyami--Team Zigzag

  • Using my new GUI component in an applet :Help!!!

    I am seeking help for the following
    Define class MyColorChooser as a new component so it can be reused in other applications or applets. We want to use the new GUI component as part of an applet that displays the current Color value.
    The following is the code of MyColorChooser class
    * a) We define a class called MyColorChooser that provides three JSlider
    * objects and three JTextField objects. Each JSlider represents the values
    * from 0 to 255 for the red, green and blue parts of a color.
    * We use wred, green and blue values as the arguments to the Color contructeur
    * to create a new Color object.
    * We display the current value of each JSlider in the corresponding JTextField.
    * When the user changes the value of the JSlider, the JTextField(s) should be changed
    * accordingly as weel as the current color.
    * b)Define class MyColorChooser so it can be reused in other applications or applets.
    * Use your new GUI component as part of an applet that displays the current
    * Color value.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.event.*;
    import java.text.DecimalFormat;
    public class MyChooserColor extends JFrame{
         private int red, green, blue;  // color shade for red, green and blue
         private static Color myColor;  // color resultant from red, green and blue shades
         private JSlider mySlider [];      
         private JTextField textField [];
    // Panels for sliders, textfields and button components
         private JPanel mySliderPanel, textFieldPanel, buttonPanel;
    // sublcass objet of JPanel for drawing purposes
         private CustomPanel myPanel;
         private JButton okButton, exitButton;
         public MyChooserColor ()     
              super( "HOME MADE COLOR COMPONENT; composition of RGB values " );
    //       setting properties of the mySlider array and registering the events
              mySlider = new JSlider [3];
              ChangeHandler handler = new ChangeHandler();
              for (int i = 0; i < mySlider.length; i++)
              {     mySlider[i] = new JSlider( SwingConstants.HORIZONTAL,
                               0, 255, 255 );
                   mySlider.setMajorTickSpacing( 10 );
                   mySlider[i].setPaintTicks( true );
    //      register events for mySlider[i]
                   mySlider[i].addChangeListener( handler);                     
    //      setting properties of the textField array           
              textField = new JTextField [3];          
              for (int i = 0; i < textField.length; i++)
              {     textField[i] = new JTextField("100.00%", 5 );
                   textField[i].setEditable(false);
                   textField[i].setBackground(Color.white);
    // initial Background color of each slider and foreground for each textfield
    // accordingly to its current color shade
              mySlider[0].setBackground(
                        new Color ( mySlider[0].getValue(), 0, 0 ) );
              textField[0].setForeground(
                        new Color ( mySlider[0].getValue(), 0, 0 ) );           
              mySlider[1].setBackground(
                        new Color ( 0, mySlider[1].getValue(), 0 ) );
              textField[1].setForeground(
                        new Color ( 0, mySlider[1].getValue(), 0 ) );
              mySlider[2].setBackground(
                        new Color ( 0, 0, mySlider[2].getValue() ) );
              textField[2].setForeground(
                        new Color ( 0, 0, mySlider[2].getValue() ) );
    // initialize myColor to white
              myColor = Color.WHITE;
    // instanciate myPanel for drawing purposes          
              myPanel = new CustomPanel();
              myPanel.setBackground(myColor);
    // instanciate okButton with its inanymous class
    // to handle its related events
              okButton = new JButton ("OK");
              okButton.setToolTipText("To confirm the current color");
              okButton.setMnemonic('o');
              okButton.addActionListener(
                   new ActionListener(){
                        public void actionPerformed (ActionEvent e)
                        {     // code permetting to transfer
                             // the current color to the parent
                             // component backgroung color
                             //System.exit( 0 );     
    //      instanciate exitButton with its inanymous class
    //      to handle its related events           
              exitButton = new JButton("Exit");
              exitButton.setToolTipText("Exit the application");
              exitButton.setMnemonic('x');
              exitButton.addActionListener(
                        new ActionListener(){
                             public void actionPerformed (ActionEvent e)
                             {     System.exit( 0 );     
    // define the contentPane
              Container c = getContentPane();
              c.setLayout( new BorderLayout() );
    //     panel as container for sliders
              mySliderPanel = new JPanel(new BorderLayout());
    //      panel as container for textFields           
              textFieldPanel = new JPanel(new FlowLayout());
    //      panel as container for Jbuttons components           
              buttonPanel = new JPanel ();
              buttonPanel.setLayout( new BoxLayout( buttonPanel, BoxLayout.Y_AXIS ) );
    //add the Jbutton components to buttonPanel           
              buttonPanel.add(okButton);
              buttonPanel.add(exitButton);
    //     add the mySlider components to mySliderPanel
              mySliderPanel.add(mySlider[0], BorderLayout.NORTH);
              mySliderPanel.add(mySlider[1], BorderLayout.CENTER);
              mySliderPanel.add(mySlider[2], BorderLayout.SOUTH);
    //add the textField components to textFieldPanel     
              for (int i = 0; i < textField.length; i++){
                   textFieldPanel.add(textField[i]);
    // add the panels to the container c          
              c.add( mySliderPanel, BorderLayout.NORTH );
              c.add( buttonPanel, BorderLayout.WEST);
              c.add( textFieldPanel, BorderLayout.SOUTH);
              c.add( myPanel, BorderLayout.CENTER );
              setSize(500, 300);          
              show();               
    //     inner class for mySlider events handling
         private class ChangeHandler implements ChangeListener {          
              public void stateChanged( ChangeEvent e )
    // start by collecting the current color shade
    // for red , forgreen and for blue               
                   setRedColor(mySlider[0].getValue());
                   setGreenColor(mySlider[1].getValue());
                   setBlueColor(mySlider[2].getValue());
    //The textcolor in myPanel (subclass of JPanel for drawing purposes)
                   myPanel.setMyTextColor( ( 255 - getRedColor() ),
                             ( 255 - getGreenColor() ), ( 255 - getBlueColor() ) );
    //call to repaint() occurs here
                   myPanel.setThumbSlider1( getRedColor() );
                   myPanel.setThumbSlider2( getGreenColor() );
                   myPanel.setThumbSlider3( getBlueColor() );
    // display color value in the textFields (%)
                   DecimalFormat twoDigits = new DecimalFormat ("0.00");
                   for (int i = 0; i < textField.length; i++){
                        textField[i].setText("" + twoDigits.format(
                                  100.0* mySlider[i].getValue()/255) + " %") ;
    // seting the textcolor for each textField
    // and the background color for each slider               
                   textField[0].setForeground(
                             new Color ( getRedColor(), 0, 0 ) );
                   mySlider[0].setBackground(
                             new Color ( getRedColor(), 0, 0) );
                   textField[1].setForeground(
                             new Color ( 0, getGreenColor() , 0 ) );
                   mySlider[1].setBackground(
                             new Color ( 0, getGreenColor(), 0) );
                   textField[2].setForeground(
                             new Color ( 0, 0, getBlueColor() ) );
                   mySlider[2].setBackground(
                             new Color ( 0, 0, getBlueColor() ) );
    // color of myPanel background
                   myColor = new Color (getRedColor(),
                             getGreenColor(), getBlueColor());
                   myPanel.setBackground(myColor);               
    // set methods to set the basic color shade
         private void setRedColor (int r){
              red = ( (r >= 0 && r <= 255) ? r : 255 );
         private void setGreenColor (int g){
              green = ( (g >= 0 && g <= 255) ? g : 255 );
         private void setBlueColor (int b){
              blue = ( (b >= 0 && b <= 255) ? b : 255 );
    // get methods (return the basic color shade)
         private int getRedColor (){
              return red ;
         private int getGreenColor (){
              return green;
         private int getBlueColor (){
              return blue;
         public static Color getMyColor (){
              return myColor;
    // main method                
         public static void main (String args []){
              MyChooserColor app = new MyChooserColor();
              app.addWindowListener(
                        new WindowAdapter() {
                             public void windowClosing( WindowEvent e )
                             {     System.exit( 0 );
    // inner class CustomPanel for drawing purposes
         private class CustomPanel extends JPanel {
              private int thumbSlider1 = 255;
              private int thumbSlider2 = 255;
              private int thumbSlider3 = 255;
              private Color myTextColor;
              public void paintComponent( Graphics g )
                   super.paintComponent( g );
                   g.setColor(myTextColor);
                   g.setFont( new Font( "Serif", Font.TRUETYPE_FONT, 12 ) );
                   DecimalFormat twoDigits = new DecimalFormat ("0.00");
                   g.drawString( "The RGB values of the current color are : "
                             + "( "     + thumbSlider1 + " , " + thumbSlider2 + " , "
                             + thumbSlider3 + " )", 10, 40);
                   g.drawString( "The current background color is composed by " +
                             "the folllowing RGB colors " , 10, 60);
                   g.drawString( "Percentage of RED from slider1 : "
                        + twoDigits.format(thumbSlider1*100.0/255), 10, 80 );
                   g.drawString( "Percentage of GREEN from slider2 : "
                        + twoDigits.format(thumbSlider2*100.0/255), 10, 100 );
                   g.drawString( "Percentage of BLUE from slider3 : "
                        + twoDigits.format(thumbSlider3*100.0/255), 10, 120 );
    // call to repaint occurs here     
              public void setThumbSlider1(int th){
                   thumbSlider1 = (th >= 0 ? th: 255 );
                   repaint();
              public void setThumbSlider2(int th){
                   thumbSlider2 = (th >= 0 ? th: 255 );
                   repaint();
              public void setThumbSlider3(int th){
                   thumbSlider3 = (th >= 0 ? th: 255 );
                   repaint();
              public void setMyTextColor(int r, int g, int b){
                   myTextColor = new Color(r, g, b);
                   repaint();
    //The following method is used by layout managers
              public Dimension getPreferredSize()
              {     return new Dimension( 150, 100 );
    The following is the code of application that tests the component
    //Application used to demonstrating
    // the homemade GUI MyChooserColor component
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class ShowMyColor extends JFrame {
         private JButton changeColor;
         private Color color = Color.lightGray;
         private Container c;
         MyChooserColor colorComponent;
         public ShowMyColor()
         {     super( "Using MyChooserColor" );
              c = getContentPane();
              c.setLayout( new FlowLayout() );
              changeColor = new JButton( "Change Color" );
              changeColor.addActionListener(
                        new ActionListener() {
                             public void actionPerformed( ActionEvent e )
                             {     colorComponent = new MyChooserColor ();
                                  colorComponent.show();
                                  color = MyChooserColor.getMyColor();
                                  if ( color == null )
                                       color = Color.lightGray;
                                  c.setBackground( color );
                                  c.repaint();
              c.add( changeColor );
              setSize( 400, 130 );
              show();
         public static void main( String args[] )
         {     ShowMyColor app = new ShowMyColor();
              app.addWindowListener(
                        new WindowAdapter() {
                             public void windowClosing( WindowEvent e )
                             {  System.exit( 0 );

    Yes, I want help for the missing code to add in actionPerformed method below. As a result, when you confirm the selected color (clicking the OK button), it will be transferred to a variable color of class ShowMyColor.
    // instanciate okButton with its inanymous class
    // to handle its related events
              okButton = new JButton ("OK");
              okButton.setToolTipText("To confirm the current color");
              okButton.setMnemonic('o');
              okButton.addActionListener(
                   new ActionListener(){
                        public void actionPerformed (ActionEvent e)
                        {     // code permetting to transfer
                             // the current color to the parent
                             // component backgroung color
                             //System.exit( 0 );     
              );

  • IMac trouble login - need help badly

    I need real big help here. My wife iMac decided to act up this morning, out of no reason. She didn't download and anything from website or new apps. This is what happening now.
    As usual, we type in the password and click login. It started as normal and show the desktop but almost immediately (2 seconds), it goes back to the same login password screen. We type the password again and again and it does the samething. We restart same thing. We shut down and let it sit and start again, same thing.
    Now, we have so many important files and memories in this machine!!! Can anyone advise how we can get it started again normally without reinstallation?
    MANY THANKS.

    If you have the install disc, boot from it and use
    Disk Utility
       1. Insert the Mac OS X Install disc that came with your computer, then restart the computer while holding the C key.
       2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu. (In Mac OS X 10.4 or later, you must select your language first.)
          Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.
       3. Click the First Aid tab.
       4. Click the disclosure triangle to the left of the hard drive icon to display the names of your hard disk volumes and partitions.
       5. Select your Mac OS X volume.
       6. Click Repair. Disk Utility checks and repairs the disk.
    Then reboot from your internal drive and repair permissions.

  • Cant login please help

    Running power mac, latest version of Tiger
    When it boots and login screen appears I cant. The mouse and keyboard work fine, but the computer will not click the user names to bring up the password box. When I mouse over the login names its like they are not there. So I cant use the computer at all. I tried keyboard also and it wont work. Same results booting up in safe mode. Its like it gets to the point of login and locks up. Please help
    TIA
    Mac Pro   Mac OS X (10.4.8)  

    Also in the login interface the , RESTART, SHUT OFF, SLEEP buttons will not work...

  • Certificates in lieu of Oracle connection Manager for our Applets -- Help!!

    I support an application named IDEA out of New York. The IDEA application is an INTRANET application for use within our company Firewall.
    Currently, the IDEA application's front end resides on a Windows 2000 Server running IIS 5 and JRun 3.0. The back-end runs on Oracle 8.1.7 database on a UNIX Database Hosting Utility (DHU). Our applets communicate with the back-end database using Oracle Connection Manager that is installed on the Web Host.
    We are trying to migrate to the DWeb environment (Linux cluster). The linux cluster is running Apache Tomcat. We have been told that installing Oracle connection manager is not a viable solution (our company does not support it). Because of this our applets cannot communicate with our database. Below is a brief description of this limitation and also the work-around.
    ====================================================================================================================================================
    Connecting to the Database through the Applet
    The most common task of an applet using the JDBC driver is to connect to and query a database. Because of applet security restrictions, unless particular steps are taken an applet can open TCP/IP sockets only to the host from which it was downloaded (this is the host on which the Web server is running). This means that without these steps, your applet can connect only to a database that is running on the same host as the Web server.
    If your database and Web server are running on the same host, then there is no issue and no special steps are required. You can connect to the database as you would from an application.
    As with connecting from an application, there are two ways in which you can specify the connection information to the driver. You can provide it in the form of host:port:sid or in the form of a TNS keyword-value syntax.
    For example, if the database to which you want to connect resides on host prodHost, at port 1521, and SID ORCL, and you want to connect with user name scott with password tiger, then use either of the two following connect strings:
    using host:port:sid syntax:
    String connString="jdbc:oracle:thin:@prodHost:1521:ORCL";
    conn = DriverManager.getConnection(connString, "scott", "tiger");
    using TNS keyword-value syntax:
    String connString = "jdbc:oracle:thin:@(description=(address_list=
    (address=(protocol=tcp)(port=1521)(host=prodHost)))
    (connect_data=(sid=ORCL)))";
    conn = DriverManager.getConnection(connString, "scott", "tiger");
    If you use the TNS keyword-value pair to specify the connection information to the JDBC Thin driver, then you must declare the protocol as TCP.
    However, a Web server and an Oracle database server both require many resources; you seldom find both servers running on the same machine. Usually, your applet connects to a database on a host other than the one on which the Web server runs. There are two possible ways in which you can work around the security restriction:
    You can connect to the database by using the Oracle8 Connection Manager.
    or:
    You can use a signed applet to connect to the database directly.
    These options are discussed in the next section, "Connecting to a Database on a Different Host Than the Web Server".
    Connecting to a Database on a Different Host Than the Web Server
    If you are connecting to a database on a host other than the one on which the Web server is running, then you must overcome applet security restrictions. You can do this by using either the Oracle8 Connection Manager or signed applets. ====================================================================================================================================================
    It was suggested that we implement signed applets (it is our only alternative at this time). This is where, hopefully, you can help me. We are unfamiliar with using certificates and signing applets. We need to obtain certificates that will allow our applets to connect to our oracle database on the DHU. What kind of certificates do we use? Are their coding examples of how to use these certificates? We have a CA within our company but they cannot tell us what kind of certificates we need. How many certificates do we need? Do we install any certificates on the backend database server? Any information would be greatly appreciated. We are basically trying to get our applet to work outside the sandbox by establishing a connection to the database server.Thanks in advance for your time.

    or:
    You can use a signed applet to connect to the database directly.
    These options are discussed in the next section, "Connecting to a Database on a Different Host Than the Web Server".
    If you want to connect to the database from the applet there is a third option.
    Since this is an intranet application you have control over the desktops using this
    application. In our company the jre ignores signed applets (as it should) because
    it gives control to the user to run potentially harmfull applets from the Internet.
    The way to dish out special privileges to applets is the policy, put a policy file on
    you intranet and have the jre use it by specifying its URL in the java.security.
    Here is some more info about security configuration of the jre:
    http://forum.java.sun.com/thread.jspa?threadID=646161&tstart=45
    reply 3
    We use Oracle jinitiator to run Oracle forms but I am not involved in that project
    and do not know a lot about it. It does perform quite good though.

Maybe you are looking for

  • IPhone 5s won't sync music from iTunes

    I have an iPhone 5s that is less than a year old. For the past month now I have not been able to sync music from my computer onto the phone. I can transfer music and playlists and apps etc from my phone to iTunes on my computer but not vice versa. I

  • Step for User Decision

    Hi All, I have a scenario and two solutions for it. Please give me the input for which is a better solution and why. Scenario - Approver have to either Approve/ Reject a particular request made. The user decision has to come from Java front end  and

  • Twit this html snippet for iWeb blog?

    Anybody have a text-only HTML snippet for TwitThis that works on an iWeb blog? If you use the one on the TwitThis website, it points to just the HTML snippet, not the entire page. Here's their snippet, FWIW: <!-- Begin TwitThis (<a class="jive-link-e

  • How to use "csscan" on RAC 10g environment

    Hi all, I have a 10g RAC database whose character set is US7ASCII, and needs to converted to WE8ISO8859P1. I need to run "CSSCAN" to get the information regarding possible issues for this charset conversion. Per Oracle Doc, cluster_database should be

  • TS3297 I can't make Purchases on iTunes with my Credit Card.

    I recently got a new Credit Card because the old one expired.  My account was set up so that I could make purchases with my credit card.  Now when I try to update my billing info with my new credit card info it says to contact iTunes support.  Though