I was reading and researching about adding color into my program. I found this code, which compiles perfectly, but does not show the desired outcome.

Here's the code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.Color;
import java.awt.Graphics;
public class Login extends JFrame implements ActionListener{
    private JTextField jcomp1;
    private JLabel jcomp2;
    private JPasswordField jcomp3;
    private JLabel jcomp4;
    private JButton jcomp5;
    private JLabel jcomp6;
    private JPanel login = new JPanel();
    public void paint(Graphics g){

    public Login() {
        jcomp1 = new JTextField ("kevin");
        jcomp2 = new JLabel ("Username:");
        jcomp3 = new JPasswordField ("shirleys");
        jcomp4 = new JLabel ("Password:");
        jcomp5 = new JButton ("Log in");
        jcomp6 = new JLabel ("Shirley's Coffee Shop");
        setPreferredSize (new Dimension (624, 413));
        setLayout (null);

        add (jcomp1);
        add (jcomp2);
        add (jcomp3);
        add (jcomp4);
        add (jcomp5);
        add (jcomp6);
        jcomp1.setBounds (285, 135, 100, 25);
        jcomp2.setBounds (215, 135, 100, 25);
        jcomp3.setBounds (285, 175, 100, 25);
        jcomp4.setBounds (215, 175, 100, 25);
        jcomp5.setBounds (285, 265, 100, 25);
        jcomp6.setBounds (265, 60, 145, 30);
        getContentPane().add (login);

    public static void main (String[] args) {
        Login frame = new Login();

     public void actionPerformed(ActionEvent e) {
        if(e.getSource()==jcomp5) {
            MainMenGra mainMenuG;
            mainMenuG = new MainMenGra();

masijade commented: didin't like that you were being told to [i]do[/i] something in your other thread? -2

Recommended Answers

Stick to original thread.

Closing this thread now.

Jump to Post

All 2 Replies

Nevermind, I finally figured it out.

Stick to original thread.

Closing this thread now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.