Designing a smart Swing GUI with design patterns

Hi !
I have to build a quite big Swing GUI from
scratch. I would like to use smart design patterns to :
* ensure reusability of some components
* offer a framework-like set of solid classes
to deal with generic problems
* try to respect MVC pattern as close as possible
from the real MVC spirit (not the half MVC
pattern Swing is build upon)
Could somebody give me any link towards ressources/docs/articles dealing with how
to build such a smart Swing GUI ?
Thanx a lot !

Hi !
I have to build a quite big Swing GUI from
scratch. I would like to use smart design patterns to :
* ensure reusability of some components
* offer a framework-like set of solid classes
to deal with generic problems
* try to respect MVC pattern as close as possible
from the real MVC spirit (not the half MVC
pattern Swing is build upon)
Could somebody give me any link towards ressources/docs/articles dealing with how
to build such a smart Swing GUI ?
Thanx a lot !

Similar Messages

  • (Youtube-) Video in a Swing GUI

    Hey everyone,
    I'm currently trying to play a video in my Swing GUI with JMF but I really can't get it to work.
    With the help of google I got this far:
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.io.IOException;
    import java.net.MalformedURLException;
    import java.net.URL;
    import javax.media.CannotRealizeException;
    import javax.media.Manager;
    import javax.media.NoPlayerException;
    import javax.media.Player;
    import javax.swing.JFrame;
    public class MediaPanel extends JFrame {
        public MediaPanel() {
            setLayout(new BorderLayout()); // use a BorderLayout
            // Use lightweight components for Swing compatibility
            Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);
            URL mediaURL = null;
            try {
                mediaURL = new URL("http://www.youtube.com/watch?v=Q7_Z_mQUBa8");
            } catch (MalformedURLException ex) {
                System.err.println(ex);
            try {
                // create a player to play the media specified in the URL
                Player mediaPlayer = Manager.createRealizedPlayer(mediaURL);
                // get the components for the video and the playback controls
                Component video = mediaPlayer.getVisualComponent();
                Component controls = mediaPlayer.getControlPanelComponent();
                if (video != null) {
                    add(video, BorderLayout.CENTER); // add video component
                if (controls != null) {
                    add(controls, BorderLayout.SOUTH); // add controls
                mediaPlayer.start(); // start playing the media clip
            } // end try
            catch (NoPlayerException noPlayerException) {
                System.err.println("No media player found");
            } // end catch
            catch (CannotRealizeException cannotRealizeException) {
                System.err.println("Could not realize media player");
            } // end catch
            catch (IOException iOException) {
                System.err.println("Error reading from the source");
            } // end catch
        } // end MediaPanel constructor
    }But all I get is errors:
    Warning: The URL may not exist. Please check URL
    No media player found
    Can you please please help me get this working? I would really appreciate a little walkthrough
    Best regards,
    Patrick
    Edited by: 954807 on Aug 24, 2012 6:52 AM

    Just use \ tags. People don't like to go to external sites.
    I really advise you to consider using JavaFX 2 here. Swing is old and not really supported anymore, JMF is also old and absolutely not supported anymore.                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to run Java Swing GUI on embedded ARM Linux platform?

    The object is:
    A touch panel, running Java Swing GUI, with a 25 fps 320x320 mono JPEG image animation and other control buttons.
    What I have now:
    A Developing Board with: ARM926 CPU at 266MHz, 128M RAM, 64M ROM, ported with arm-linux and MiniGUI.
    My plan is:
    1. installing a X-window system to the platform, discarding the MiniGUI.
    2. install j2re-1.3.1-RC1-linux-arm.tar.bz2 to the platform.
    3. run my program developed on a PC.
    My concerns are:
    1. Both X and Java is resource consuming, can a 266MHz ARM CPU meet my requirement?
    2. Is the X a must to run Java Swing GUI? If yes, how can I configure it to minimize the footprint, I mean, install only necessary modules.
    3. Can J2RE 1.3.1, the only port for arm linux, support Swing classes?
    4. Are there other options, such as CDC + PP(AGUI?), how to do it?
    Thanks alot!

    3. Can J2RE 1.3.1, the only port for arm linux, support Swing classes?I'm not entirely sure from your post: is this a J2SE port? If so it will support Swing, but probably needs Qt.

  • What is recommended / preferred design pattern for Swing?

    I have been confused by the apparent variety of design patterns used when putting together a Swing GUI application. For example, one pattern does this:
    public class myclass extends JFrame {
    myclass() {
    // do all the stuff here
    public static void main(String args[]) {
    // instantiate class here
    while another pattern goes like this:
    public class myclass extends JFrame {
    myclass() {
    super("title");
    public static void main(String args[]) {
    // do all the stuff here
    Is there a preferred way to do this stuff, or is it a matter of personal preference?

    Hi
    I txnk there are no choice : the only valid aproach is (1)
    because :
    main is a "know" entry point just for instantiate some classes
    the event thread is alive after main is completed, so your app have a GUI elements who responds to some events via some classes (the listeners for these events).
    Of course you can add listeners at main level but, what hapen if
    you need these GUI in other app (the main func is only called when you invoke the JVM to an start class)
    Normally the JFrame have some member funct or some internals classes to respond some events (at this point there are some alternatives)
    Hope this help
    Bye

  • Design Pattern for Role-based GUI

    Hi,
    I'm looking for a java design pattern to provide different GUI according to the user role.
    For example, If logon user has general user role, the GUI would disable some administrator related menu items...
    I think, this kind of functionality is now in use at many applications..
    Thanks in advance..
    Habin

    Hi
    I try to explain with some more detail (sorry for my bad english) :
    I write a complete hotel reservation app with Java+Bd (relational). This app is used by diferent users types.
    The administrator has all privileges (can do every action) and other users can do only some actions (make a reservation, check-in, check-out etc but not modify a
    room price for example).
    The app is a MDI app, there are a menu and menuitems
    and when a user do an actionEvent over a menuItem an InternalFrame is activated and so on. These InternalFrame make possible some actions at app level (ex. : do a check-in).
    The menuItems set is controled by the App (is the Controller in MVC design pattern) and the model is represented by a set of user possible actions; so there are a class (UserConfig) with these set of possible actions.
    the Controller ask UserConfig abouth the posible action
    set and do the enable/disable job. There are a 1 to 1
    relationship : each possible actions has a menuItem. And
    there are a M to N relationship from User/Action perspective.
    With this design (I think is an MVC design) the Controler mantain a UserConfig (via a Relational Database) and the Administrator (via the App) can create or modify the UserConfig objects.
    At implementation level, each menu item has a name, and
    for each registered user there are the name/id_user pair
    of actions. These info (stored in BD) is used to create
    the UserConfig objects (via username/password).
    Bye

  • Producer/Consumer Design Pattern with Classes

    I'm starting a new project which involves acquiring data from various pieces of equipment using a GPIB port.  I thought this would be a good time to start using Classes.  I created a GPIB class which contains member data of:  Address, Open State, Error; with member vis such as Set Address, Get Address, Open, Close...general actions that all GPIB devices need to do.  I then created a child class for a specific instrument (Agilent N1912 Power Meter for this example) which inherits from the GPIB class but also adds member data such as Channel A power and Channel B power and the associated Member Functions to obtain the data from the hardware.  This went fine and I created a Test vi for verfication utilizing a typical Event Structure architecture. 
    However, in other applications (without classes) I  typically use the Producer/Consumer Design Pattern with Event Structure so that the main loop is not delayed by any hardware interaction.  My queue data is a cluster of an "action" enum and a variant to pass data.  Is it OK to use this pattern with classes?  I created a vi and it works fine and attached is a png (of 1 case) of it.
    Are there any problems doing it this way?
    Jason

    JTerosky wrote:
    I'm starting a new project which involves acquiring data from various pieces of equipment using a GPIB port.  I thought this would be a good time to start using Classes.  I created a GPIB class which contains member data of:  Address, Open State, Error; with member vis such as Set Address, Get Address, Open, Close...general actions that all GPIB devices need to do.  I then created a child class for a specific instrument (Agilent N1912 Power Meter for this example) which inherits from the GPIB class but also adds member data such as Channel A power and Channel B power and the associated Member Functions to obtain the data from the hardware.  This went fine and I created a Test vi for verfication utilizing a typical Event Structure architecture. 
    However, in other applications (without classes) I  typically use the Producer/Consumer Design Pattern with Event Structure so that the main loop is not delayed by any hardware interaction.  My queue data is a cluster of an "action" enum and a variant to pass data.  Is it OK to use this pattern with classes?  I created a vi and it works fine and attached is a png (of 1 case) of it.
    Are there any problems doing it this way?
    Including the error cluster as part of the  private data is something I have never seen done and ... well I'll have to think about that one.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Software reuse with Java design patterns

    Anyone have any suggestions on how software can be reused with Java design patterns? Any concrete examples?

    Buy the GoF book. Lot's of examples there.

  • Design pattern for unprotecting and reprotecting sheets with VBA?

    Many macros can't run when a worksheet is protected, so when I develop an Excel workbook that has protected worksheets, I have to unprotect worksheets when macros are called and then reprotect the worksheets once the macro has completed.
    The current design pattern I use for this is the following:
    I look at each procedure individually and consider which sheets need to be unprotected for it to run. Then in each procedure I write:
    Sub Test()
    Dim bSheet1Protected as boolean
    Dim bSheet2Protected as boolean
    bSheet1Protected = Sheet1.ProtectContents
    bSheet2Protected = Sheet1.ProtectContents
    bSheet1Protected.Unprotect
    bSheet2Protected.Unprotect
    '''The rest of my code
    if bSheet1Protected then Sheet1.Protect
    if bSheet2Protected then Sheet2.Protect
    End Sub
    But I imagine that maybe there are better ways of doing this. What is your preferred design pattern for unprotecting and reprotecting sheets with VBA?

    Hi JP3O,
    I think it is a good practice to unprotect the worksheet before execute some code and protect it back after the code execute finished.
    >>But I imagine that maybe there are better ways of doing this. What is your preferred design pattern for unprotecting and reprotecting sheets with VBA?<<
    I am not able to find a better way since we always need to unproect the worksheet if some code didn't not executed successful when the worksheet is proected.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • ETL design pattern with Data Integrator

    Hi all
    I have searched a lot on the SAP website and also on the Google to find a reliable document about ETL design pattern which applies to BO Data Integrator, but it was not successful. Most of the links I found was for  SSIS and Informatica,....
    I would be grateful if you could guide me to a good link about ETL design pattern.
    Thanks.

    I would start with these two:
    https://wiki.sdn.sap.com:443/wiki/display/BOBJ/ETLProjectGuidelines
    https://wiki.sdn.sap.com:443/wiki/pages/viewpage.action?pageId=49414406

  • Possible design patterns for base function with possible additions

    I have various interfaces i have to implement. Let's assume ITypeA, ITypeB. They have following methods:
    ITypeA
    Connect
    Disconnect
    GetData
    SetData
    ClearData
    ITypeB
    Connect
    Disconnect
    GetData
    SetData
    Start
    Pause
    Stop
    They have some base functionality: Connect, Disconnect, GetData and SetData.
    If I want to add ITypeC in the future, it will have these base functionality too.
    I want to access to the base functionality and if there is additional functionality, I want to get this too. What design patterns are available that are capable of this situations?
    I found one here: Extension Interface. In this, you create a base
    interface and multiple extension interfaces that are implementing the additional functions. In the base interface you can ask for the available extension interfaces of the component. But this approach seems complicated: I have to create interfaces for each
    type, factories for the interfaces, I need some tables to save what Interface belongs to what Factory...
    What is the basic solution for this problem? Extension Interfaces? Are there any other possible alternatives for my problem?

    You may have more joy dividing your interfaces by behaviour and deciding on the types later.
    interface IConnectable
    Connect
    Disconnect
    interface IDataTransferrable
    GetData
    SetData
    interface IPlayable
    Start
    Pause
    Stop
    class TypeA : IConnectable, IDataTransferrable
    class TypeB : IConnectable, IDataTransferrable, IPlayable
    And then how can discover if your object supports these interfaces?
    here's one way:
    if (ob is IPlayable)
    Playback(ob);
    where you have a function:
    void Playback(IPlayable ob)

  • Design Patterns for java swing application front a J2EE server

    Hi,
    i dont nkow that i stay in the correct forum. I am development a java swing client application, no web, and i dont know that if there are any patterns for a client of this type.
    I have readed http://java.sun.com/blueprints/corej2eepatterns/Patterns/index.html
    but after of Buissnes Delegate pattern, the others one, over ejb tier, are applicated only for web clients, using servlets and jsp pages.
    If i have a swing client application, what patterns i must folow for implement the client logic of my swing application??
    thanks

    MVC pattern is one of the most used
    http://en.wikipedia.org/wiki/MVC
    http://csis.pace.edu/~bergin/mvc/mvcgui.html
    ...

  • Design Patterns Support in Jdev 10.1.3?

    Is Design Patterns Support included as part of JDev 10.1.3. I have seen this support in SAP NetWeaver Developer Studio where you have the option of converting existing classes to implement a certain J2EE/J2SE Design Pattern or create a new class(es) to implement a Design Pattern. I believe TogetherSoft has this support.
    Any chances this request is consider in the next major release of JDev 10.1.3?

    Dear Shmeltzer,
    My company just begins the migration from Oracle Form-based application to pure Java EE one. We will be using JDeveloper v10.1.3, persuaded by it fast GUI building, data-binding features. Before that, we have been trying out Eclipse & JBoss.
    We are going to use Swing & JSF for client, and JavaEE 5 for midtier. Persistence layer, will be JPA (EJB3 entity bean persistence) and Spring Framework DAO support. Spring DAO is interesting bcos it gives a consistent style of API (we want to support both JDBC & JPA) and consistent Exception hierarchy too. So our midtier will be partitioned (roughly according to Fowler's patterns) into 3 layers: Service, Domain/Biz Object, Data Access. Thus far is pretty standard.
    We are still pretty new to this ADF, and are still exploring.
    Now, my initial impression with ADF is that it seems to interfere too much with the kind of pattern we had in mind. The fact that ADF hides too much details from us programmers scares me -- it becomes restrictive and we are helpless as to what are going on inside (with those xml, dcx, etc). For e.g. talk about Service Locator pattern, and we cannot seem to figure out how/where it is implemented. Using ADF Data Control and Biz Components will make all the design patterns "disappear" -- we dont see DAO classes anymore bcos it has been automated. It looks more like 2-tier client-server pattern to me. :-)
    We are interested to use ADF data-binding features, so
    1) Is it still advisable to use Spring DAO layer?
    2) Is it possible to just use ADF in the Client / web tier, while the EJB container remains free of ADF technologies?
    Regards.

  • Design pattern for swind application development

    Hello all,
    I am trying to develop a new swings application with the centralized database connectivity for the data transaction .Any one please tell me which design pattern is mostly suitable for the GUI application development using swings .
    Thanks in advance
    sowjanya

    Pu - this is your decision.
    In order to know which design patterns are suitable for you, you should know what the design pattern do.
    So I suggest to read about design patterns:
    http://en.wikipedia.org/wiki/Design_pattern_(computer_science)
    Note also that ther exists a framework called Spring.
    Greetings
    Thorsten

  • Does any body have any design patterns of JSF Web Application Developping?

    Can any one answer me some questions?
    #1.I am an amatuar of people who develop Web Application.For some reason,We choose the JSF to develop our item.through some introduction,I know the UI component of JSF is resided in Server side,is it right?but I am a little confused that:if there are many users who are exploring our jsf website.(to simplify my question,image I had just one web page and just one button)How many UI components(buttons) will be there?How it(they?) works?
    #2.Does any body have the success experience (for example design pattern)to develop web applications?if We just concern about the Add,Delete,Modify,Query operations of some data.
    I just do my job according to my feeling.
    I will give every page a pagebean(backing bean),and I am not sure how to combine the business data with the pagebean.some one suggested that I should use delegate pattern to separate my business log and page logic.But I am still confused by following things:
    #2.1 does JSF have the same ability to help us construct the model dialog just like swing to
    help us control the operation flow?
    #2.2 If there is not,Does the following way work?I put every tabledata's property as corresponed component.if user choosed the row in the table,My Listener will syncronize the row data to the components.But
    #2.2.1 if JSF has the components according to the web users' number,how can My Listener tell which component should be update?Should I maintain the map?
    #2.2.2 If the problem I imaged above is false,Does any body can tell me how to custom      the ListDataModel,so I can use it like Swing?because now I can just use some view data to insert into ListDataModel,but after some selection operation,my business object must be find according to the selected data,it is not an interesting job!
         I am waiting for your advice!

    Ok I'll try to explain Step by step please correct me if I make any mistake because I have not played much with shared variables.
    To create a shared variable to an RT target go to the target if tou have already otherwise add an RT target by right clicking the Project>>Add targets and Devices
    Then in the target Right clikc and select the variable as shown below.
    Then once the Shared variable settings window opens Enter a variable name and then Select the type "Network Published"
    In the right side you can select the data type for the shared variable and even you can choose your custome controls.
    After selecting the data type go for the Network and select buffering if required else leave it if you are planning to use the variable just for display purpose.
    Then you can enable the RT FIFO if required (Not able to explain how it works and why it is used).
    Then after completing the Shared variable setup you can access the variable in the VI in both the Host and the RT.
    You can bind the variable to a control so that if any data from the RT is coming you can read the data from that control.
    Once you have placed your shared variable in the BD you can change the access typr to read or write depending on your need.
    This might not explain the complete shared variable concept but I believe that this would defenelty give you a kick off to start using the shared variable. Please correct or add more comments if anybody know better.
    Good luck.
    The best solution is the one you find it by yourself

  • The search for a perfect design pattern

    The search for a perfect design pattern
    I am searching tip to upgrade a labview program used. I am looking for the best approach to make
    my program more robust and scalable.Software and hardware. 
    Today the system consists of :
    GPS, weather station, ultrasound wind sensor, echosounder  and a  webcamera,  all connected to a computer.
    The computer OS is XP pro with Labview version 2009 installed. Except for the webcamera all peripherals have serial communication interface. 
    The webcamera  interface is ethernet.
    Device                           Data type                 Interval                    Interface
    GPS                                NMEA string                1 second                   Serial  rs232
    Ultrasound wind sensor   NMEA string                1 second                   Serial rs232
    Weather, temp,humid     NMEA string               35 seconds                 Serial rs232
    Echosounder                  NMEA string               500ms-5 seconds       Serial rs232
                                                                          (depending of depth)
    Webcamera                    Jpg                           Snapshot on demand  Ethernet
    The tasks to be solved
    All the data have to be stored.
    All the data have to be displayed in real time.
    Weather history data must be buffered to be plotted in a graph (pop-up windows).
    Absolute wind speed and direction have to be calculated.
    Option to send navigation data attached to email at desired time intervals.
    Image snapshot at desired time intervals.
    The data wich streams into the serial ports are not synchronized and vary in intervals . Would it be a good idea to put all the serial peripherals into a serial device server. Is it possible to let the server place a event in my software, to  trigger reading of the data, from the the server.  Or how could that be done in other ways?
    The perfect design pattern
    In version one of the software I use 4 parallel loops to read data at the serial ports, inside these loops the data was separated and outputted to a datasocket server.  I used datasocked read in other loops to present and store data. But it did not look good, and yes it was a mess, a really rat nest. I am looking for a better design pattern.
     Could some kind of producer/ consumer pattern be the way to go?
    Comments and tips are wanted.
    TIK

    Nice Project! Congratulations ;-)
    I am not an expert for large applications. But your project looks nice and manageable. Here my straightforward ideas:
    I would build a GUI, with menu bar, pop-up graph display thing.
    THen low level tasks with each one handling a RS232 device and feeding queues or fireing notifications.
    Maybe handle the snapshots in an event structure on the GUI blockdiagramm.
    When GUI and producer tasks are running, close the gap with a middle layer which captures the data and actualizes GUI by reference. For instance the graph-thing-dialogue triggers a "flush queue" and displays the last 200 entries of the array of data.
    I often run into issues when having defined too many userevent structures. I guess i am too stupid for that. Thats why i rather use queues (when i dont want to loose data) or notifiers (data is up-to-date). Nevertheless I like a "stop-all-tasks" user event...traditionally.
    My team is actually developing a large application. We are using LabVIEW classes and objects.
    So have fun!
    Yours
    RZM

Maybe you are looking for