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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:30:36+00:00 2026-05-27T18:30:36+00:00

To get right directly to my question. How do you do large scale GUI

  • 0

To get right directly to my question.

How do you do large scale GUI projects. I have not done any larger GUI projects in java so far but what i am working on now grew pretty fast and pretty big and now i am stuck whit a huge pile of code that is really annoying and messy.

Since i come from field of web development i am used to MVC frameworks so i have 3 packages in my projects Model where i keep classes that interact whit files or db, Views where i keep my classes for Forms or GUI and Controller package where i keep the majority of my logic.

I have been told to separate my logic as well keep actions in one class and listeners in another class but i have no idea how to link all that up.

So far i only have 1 Controller class where i execute all the methods regarding whats happening on the GUI once its invoked.

package pft.controller;


import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JTree;
import java.awt.event.*;
import javax.swing.JProgressBar;
import pft.view.Invoke_GUI;
import pft.model.Events;
import pft.model.Parse;

public class Tower_Controller {

    public Tower_Controller() {
    }
    //Global variables
    String isSelected = null;
    int hasModules = 0;
    int cap = 0;
    int cpu = 0;
    int shield = 0;
    int armor = 0;

    public void setName(String name){
        this.isSelected = name;
    }

    public String getName(){
        return this.isSelected;
    }

    public void setCap(int cap){
        this.cap = cap;
    }

    public int getCap(){
        return this.cap;
    }

    public void setCpu(int cpu){
        this.cpu = cpu;
    }

    public int getCpu(){
        return this.cpu;
    }

    public void setShield(int shield){
        this.shield = shield;
    }

    public int getShield(){
        return this.shield;
    }

    public void setArmor(int armor){
        this.armor = armor;
    }

    public int getArmor(){
        return this.armor;
    }


    public void invoke() throws IOException {
        Invoke_GUI runnable = new Invoke_GUI();
        final JLabel tower_name = runnable.tower_name;
        final JComboBox tower_select = runnable.tower_select;
        final JTree module_browser = runnable.module_browser;
        final JTree selected_modules = runnable.selected_modules;

        final JProgressBar cap_bar = runnable.cap_bar;
        final JProgressBar cpu_bar = runnable.cpu_bar;

        final JLabel em_res = runnable.em;
        final JLabel th_res = runnable.thermic;
        final JLabel ki_res = runnable.kinetic;
        final JLabel ex_res = runnable.explosive;

        setTowerName(tower_name, tower_select);
        removeTower(tower_name);
        runnable.setVisible(true);       

    }

    public void removeTower(final JLabel tower_name) {
        tower_name.addMouseListener(new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (hasModules == 1 & isSelected != null) {
                    Events evt = new Events();
                    evt.towerHasModules();
                } else if (isSelected == null) {
                } else {
                    tower_name.setText("No Control Tower selected");
                    isSelected = null;
                }
            }

            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }
        });
    }

    public void updateVariables(String name) throws IOException{
        Parse tower = new Parse();
        String data[] = tower.towerData(name);
        Integer x = Integer.valueOf(data[1]).intValue();
        setCap(x);
    }

    public void setTowerName(final JLabel tower_name, final JComboBox tower_select) {
        tower_select.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (isSelected != null) {
                    Events evt = new Events();
                    evt.towerSelected(isSelected);
                } else {
                    tower_name.setText(tower_select.getSelectedItem().toString());
                    setName(tower_name.toString());
                    try {
                        updateVariables(tower_name.toString());
                    } catch (IOException ex) {
                        Logger.getLogger(Tower_Controller.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        });
    }


}

There are a lot of tutorials and examples how to do small usually single class Java GUI but no tutorials or examples on how to do projects that are bit larger than a single class.

Thanks in advance for all the help and
advice.

  • 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-27T18:30:37+00:00Added an answer on May 27, 2026 at 6:30 pm

    Here is my advice for Swing development in general. It does discuss the importance of using Controllers to bridge the needs of the view and the interace of the model.

    GUI guidelines for swing

    Last Swing project I did I designed a MVC framework that used Spring for defining the model of the program and Controllers, then used annotations in the Controller to wire up events dispatched by the view onto methods in the controller. The view had access to the event dispatcher which was an event bus, and events sent over the bus called methods on the Controller through the annotations. This allowed any Controller to respond to events from the View. So as a Controller got too large it was super simple to refactor each set of methods into another Controller, and the view or model didn’t have to change.

    The beauty of the event bus was it could be shared with the model as well so the model could dispatch asynchronous events the Controller could register for as well. It looked something like:

    public class SomeController {
    
       private AuthenticationModel authenticationModel;
    
       private LoginService loginService;
    
       private MyApp view;
    
       @Listener( event = "login" )
       public void login( LoginEvent event ) {
           view.showWaitDialog();
           loginService.login( event.getUserName(), event.getPassword() )
           .onResult( new Callback<User>() {
               public void onResult( User user ) {
                   authenticationModel.setUser( user );
                   view.hideWaitDialog();
                   view.showStartScreen(user);
               }
           });
       }
    
    }
    

    Once this framework was in place it was amazing how fast we could get things done. And it held up pretty well as we added features. I’ve done my fair share of large Swing projects (3 to date), and this architecture made a huge difference.

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

Sidebar

Related Questions

I have this design which I cannot seem to get right, I would like
I've been battling to get this right...basically I have the following HTML setup: <div
I think this must be simple but I can't get it right... I have
I'm not sure I am using ad-get-args and ad-get-arg right. For example, the following
Some variants of this question have been asked before, but not this exact one.
I have a corba releated question. In my Java app I use typedef sequence
I have question on usage java nio and hope someone who has a lot
This question is directly related to StackOverFlow while counting digits . I have lifted
I have a basic newbie binding question, which isn't necessarily directly related to the
I'll get right to the point. This is what a browser request looks like

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.