Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7493073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:44:18+00:00 2026-05-29T16:44:18+00:00

We are not allowed to use IDE’s in class this is being done in

  • 0

We are not allowed to use IDE’s in class this is being done in text pad. I am writing a traffic light program that when I click on the associated traffic light color it fills the color and makes it look like that light is active.

I cannot currently get the second panel with the radio buttons on it to show. I have it instantiated and added.

They are supposed to be separate panels.

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;



public class Lab4Frame extends JFrame {

    Lab4Frame(){
        setTitle("Lab 4 - Application #1");
        Lab4Panel p = new Lab4Panel();
        Lab4RadioButtonPanel p2 = new Lab4RadioButtonPanel();
        setLayout(new GridLayout(1,2));
        add(p);
        add(p2);
    }

    public static void main(String[] args){

            Lab4Frame frame = new Lab4Frame();
            frame.setTitle("Lab4 Application # 1");
            frame.setLocationRelativeTo(null);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(600, 600);
            frame.setVisible(true);
    }

}

class Lab4RadioButtonPanel extends JPanel implements MouseListener {

    public Lab4RadioButtonPanel() {
        JRadioButton jrbRed = new JRadioButton("Red", true);
        JRadioButton jrbYellow = new JRadioButton("Yellow");
        JRadioButton jrbGreen = new JRadioButton("Green");
        ButtonGroup group = new ButtonGroup();
        group.add(jrbRed);
        group.add(jrbYellow);
        group.add(jrbGreen);

        jrbRed.setMnemonic('E');
        jrbGreen.setMnemonic('G');
        jrbYellow.setMnemonic('Y');
    }




            public void mouseClicked(MouseEvent e)
                {
                    /*if (e.getSource() == red){

                    }

                    else if (e.getSource() == yellow){

                    }

                    else if (e.getSource() == green){

                    }*/



                }

        public void mouseExited(MouseEvent e){}
        public void mouseReleased(MouseEvent e){}
        public void mousePressed(MouseEvent e){}
        public void mouseMoved(MouseEvent e){}
        public void mouseEntered(MouseEvent e){}
}

class Lab4Panel extends JPanel{


    public Lab4Panel(){
    }



    int height, width;
    int radius = 5;
    int x = -1;
    int y = -1;

    protected void paintComponent(Graphics g){
        if (x<0 || y<0) {
            x = getWidth() / 2 - radius;
            y = getHeight() / 2 - radius;
        }
        super.paintComponent(g);
        g.drawRect(x - 10,y - 90, 40, 120);
        //g.drawOval(x,y - 80, 4 * radius, 4 * radius);
        //g.drawOval(x,y - 40, 4 * radius, 4 * radius);
        //g.drawOval(x,y, 4 * radius, 4 * radius);
        g.drawRect(x - 5,y - 90, 40, 120);
        g.setColor(Color.RED);
        g.fillOval(x,y - 80, 4 * radius, 4 * radius);
        g.setColor(Color.YELLOW);
        g.fillOval(x,y - 40, 4 * radius, 4 * radius);
        g.setColor(Color.GREEN);
        g.fillOval(x,y, 4 * radius, 4 * radius);

    }


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T16:44:28+00:00Added an answer on May 29, 2026 at 4:44 pm

    The JRadioButtons are never added to a container.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to preface this with we are not allowed to use IDE's in
I am trying to create a traffic light for class. We are not allowed
I need to preface this with I am not allowed to use an IDE
I need to preface this with I am not allowed to use an IDE
I need to preface this with I am not allowed to use an IDE
I need to preface this with I am not allowed to use an IDE
Okay, so I have this Silverlight client program. I'm not allowed to use the
Using VS2008, why is this OK (not allowed to use 2010). void assert(int exp,
I'm writing a MS paint-like application (I'm not allowed to use opengl primitives). So
In XHTML Strict, it seems that you're not allowed to use the <u> tag

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.