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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:52:42+00:00 2026-06-11T05:52:42+00:00

I’m trying to create a custom timer that will record cumulative time passage separated

  • 0

I’m trying to create a custom timer that will record cumulative time passage separated by days. I have a custom JPanel that does all of the timer work for me. I would like to have a GUI interace with this JPanel represented 7 times. However, when I add more than one custom JPanel to either a JPanel or a JFrame, they don’t show up. I’ve tried setting the layout and setting them to everything I can think of, but nothing works.

This is the basic setup of the Panel:

public class TimerPane extends JPanel{
    private static JButton button = new JButton("Start");
    private static JLabel label = new JLabel("Time elapsed:");
    private static JLabel tLabel = new JLabel("0:0:0");
    private static JLabel title = new JLabel("Timer");

    public TimerPane(){
        button.addActionListener(new ButtonListener());

        this.add(title);
        this.add(label);
        this.add(tLabel);
        this.add(button);
        this.setOpaque(false);

        this.setPreferredSize(new Dimension(100,100));
        this.setMaximumSize(new Dimension(100,100));
    }
}

This is my latest attempt at getting the JPanel to display multiple times (just twice here):

public static void main(String[] args){
    JFrame frame = new JFrame("Timer");
    JPanel panel = new JPanel();
    frame.setPreferredSize(new Dimension(700,110));

    panel.setLayout(new BorderLayout());

    panel.add(new TimerPane(), BorderLayout.EAST);
    panel.add(new TimerPane(), BorderLayout.WEST);

    frame.getContentPane().add(panel);


    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}

The GUI that executes after this is 700×110 of which only 100×100 on the far left is used for exactly one of my TimerPane panels. I have also tried GridLayout on the same code, but then only the TimerPane in the second “spot” shows up. Any suggestions?

  • 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-11T05:52:44+00:00Added an answer on June 11, 2026 at 5:52 am

    First of all, please remove the static from the member variables: button, label, tLabel and title. Otherwise, having them static, it means they are shared by all the TimerPane instances.
    You will see 2 timer panels now.

    Next, you can change the BorderLayout to a FlowLayout for instance and add several instances of TimerPane.

    panel.setLayout(new FlowLayout(FlowLayout.LEFT));
    
    panel.add(new TimerPane());
    panel.add(new TimerPane());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.