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 7707807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:27:12+00:00 2026-06-01T00:27:12+00:00

//calling class import javax.swing.JFrame; class jcheckkbox { public static void main(String args[]) { jRadio

  • 0
 //calling class
     import javax.swing.JFrame;
      class jcheckkbox {
          public static void main(String args[]) {
jRadio roof = new jRadio();
 roof.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 roof.setSize(300, 200);
 roof.setVisible(true);



               //secondary class
     import java.awt.*;
     import javax.swing.*;
     import java.awt.event.*;



     public class jcheckbox extends JFrame {
            private JCheckBox cd;
            private JCheckBox md;
            private JTextField vcd;

     public jcheckbox() {
   super("Beer bar");
setLayout(new FlowLayout());

vcd = new JTextField("this is a code", 20);
vcd.setFont(new Font("Serif", Font.PLAIN, 22));
vcd.setToolTipText("yahoo");
add(vcd);

cd = new JCheckBox("bold");
md = new JCheckBox("italic");
add(md);
add(cd);

handler dahandler = new handler();
 cd.addItemListener(dahandler);
 md.addItemListener(dahandler);

   }
      private class handler implements ItemListener {
         public void itemStateChanged(ItemEvent event) {
    Font cool = null;
    if (md.isSelected() && cd.isSelected())
     cool = new Font("Serif", Font.BOLD + Font.ITALIC, 25);
    else if (md.isSelected())
     cool = new Font("Serif", Font.BOLD, 30);
    else if (md.isSelected())
     cool = new Font("Sans_Serif", Font.ITALIC, 30);

     vcd.setFont(cool);

  }}}

how to write a program in just one class i mean no need calling class for setsize or defaultcloseoperation etc because two classes are harder to compile when making a .jar or .exe out of it,i know there is another way but i want to use this method as it is a lot more easier to make buttons,textfields comboboxes with this method

  • 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-06-01T00:27:14+00:00Added an answer on June 1, 2026 at 12:27 am

    If your whole program is within a couple of hundred lines then you can create multiple classes within a file. A file is typically used to host one class, but you can have static classes withing the file
    As per some of the comments it is bad practice to put everything in one class. A class should only do one thing and helps modularize your program.
    As per your code sample above you are obviously a beginner. I would strongly recommend that you go to the Java Tutorial and take a look around.
    If you have any further questions then Google for them, if they have not been answered, then feel free to post a question here.

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

Sidebar

Related Questions

import java.io.IOException; import java.util.*; public class calling { public static String s; public static
import java.io.IOException; import java.util.*; public class calling { public static int num1() { int
import java.lang.reflect.*; import java.util.Arrays; class Test { class Inner { public <T> Inner(T arg)
Does creating an object using reflection rather than calling the class constructor result in
I seem to be having a very frustrating time with an inherited class calling
I'm calling this linear class relationship , but correct me if I'm wrong. I'm
I have a problem in calling a template class I have. I declared a
What are the C++ rules for calling the base class constructor from a derived
When calling DirectoryInfo.GetDirectories(.) on an instance of a DirectoryInfo class which points to a
I'm calling some code that uses the BitmapData class from .NET. I've hit something

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.