Good OO Swing Design

I have been programming with Netbeans for a while now, and would like to know the best method / practices in keeping good OO design to a MDI Swing application. I understand the concepts of OO programming and have been able to code good design using separate classes for similar objects, but still feel the code is entirely too large.
Netbeans generates a considerably large chunk of the code (especially with involved GUI's), and to reduce the code size, I would like to split off each JInternalFrame to separate .JAVA files. I have attempted this, but am having a problem when manipulating the objects within those JInternalFrames once I split them off into separate classes.
I know that in VB you can access separate forms by referring to the Form name: formName.object.propertyIs there a similar method in Java you can access JInternalFrame properties located in separate classes? I'm assuming you can create an instance of the external class, and then access the property of the new instance in your program, but am not sure exactly how to do so.
Thank you for any advice/response, and an example would be great.
James C.

Hmm I can't provide you with a code example but I learned most of the MVC stuff when I had to build a web application this year, using the Struts framework. It gave me a good understanding of how MVC works, and in theory if the application is correctly built we should be able to switch to a swing gui (instead of a web gui) and all the business logic will remain the same, only the gui part would require re-working.
What we used is what people call a business-deleguate, which basicly is a class containing all functions that the client (in this case the web) will require to work with. You can think of this as a clerk working for your company, and clients come in and ask him for well defined things. They don't have to know how it's done behind the scenes, but only need to ask for what they need and the business will know how to get it for them in a format they can easily work with. If ever the business was to decide to switch its internal way of doing things, the clients should still get the same when asking for a given thing.
Hope it's not too confusing, but anyways the core of this pattern is to keep away all your business logic from the clients and let them interface with only what they need.

Similar Messages

  • Visual Swing Designer (for Eclipse)

    Hi there
    We've developed a client software with JBuilder. Now we want to move
    the whole project to eclipse.
    Is there a good plugin for Eclipse to design Swing applications? I haven't found one so far.
    JBuilder has a Swing designer, and it is very usable for us. Eclipse
    hasen't such a Swing designer...
    It could also be a external tool, to design our Swing Panels. But it
    has to be a visual Designer tool for swing, like the one for VisualStudio and co.
    Does anybody know a good Designer WORKING Tool? Maybee as plugin for eclipse?
    Greetings,
    Adrian

    Hi,
    It would be good to have some feedback about Swing GUI builders for Eclipse, are they usable and good. I heard much good things on Eclipse and am curious to try (althought NetBeans are still very good for me), but I develop Swing application and porting to SWT is unacceptable for me (it is not so advanced as Swing and I need many features that are in Swing only).

  • Good books on Designer 6i

    Can anyone recommend a good book on Designer 6i ?
    All the books I have come across are for Designer/2000.
    thanks

    Either this was a difficult question or no one wants to share their favorite books :-)
    For now I settled for the German book "Masterkurs Client/Server-Programmierung mit Java: Anwendungen entwickeln mit JDBC, Sockets, XML-RPC, RMI und JMS - Kompakt und praxisnah - Zahlreiche Programmbeispiele und Aufgaben". But I'm still very much interested in other titles on the choices, trade-offs, architecture, when to use web-services, etc.

  • A good book on design patterns?

    Hi there. Just wondering if anyone could recommend a good book on design patterns, for someone who's relatively experienced at the nuts and bolts of programming in a few languages, but hasn't really considered design patterns before? Someone recommended Gamma et al's, 'Design patterns: elements of reusable object-oriented software' to me, but it is perhaps a little dated now. Any thoughts?

    Surprisingly, no one posted the link to the Sun J2EE Pattern blueprints:
    http://java.sun.com/blueprints/corej2eepatterns/index.html
    I also liked the O'Reilly publication "J2EE Design Patterns"
    They are specific to J2EE architecture, but there's a lot of reuse available even if that's not the architecture you're working with.
    Brian

  • Tools for Swing Design

    Hi,
    Kindly help me know the tools available to Design an application using Java Swing.
    I would be thankful if you can provide me the vendor information also.
    Thanks in advance
    Lakshmi

    It makes sense. The state of the art of GUI builders is not perfect.
    In particular the way Layout Managers are handled is often annoying.
    Some tools recommend just not using one, which is not a good idea IMO.
    In my experience, there's no real 2-way editing tool available. They all
    generate code and some (netbeans, don't know about all others) are
    honest enough to guard the generated code so you are not tempted to
    modify or change it.
    Having said that, try one of the free tools, it's not as bad as I may say it is! ;-)
    -Alexis

  • It's working, but is it a good or bad design?

    hiya
    I hope I�m not breaking any forum rules, but any help would be greatly appreciated.
    I haven�t really done any programming so far, so finally writing an app with more than few lines of code was something different. Anyways, I managed to write it, but truth be told, I have no idea whether my design choices ( I�m not sure if that�s the right term ) were somewhat good or completely off. Thus, if I don�t know what parts of program are designed badly ( and why they are considered bad), then I won�t know where to improve. So I�m hoping someone could point out ( at least the most obvious )design mistakes I made.
    It�s a simple �chat� server where several clients ( up to twenty ) can connect to the server and talk to each other. In essence:
    1.server creates new client thread for each newly accepted connection
    2.if one of these client threads receives some data from the client, then:
    3. this client thread creates new ControlThread object (and passes received data to it )
    4. ControlThread object in turn spawns a new thread
    5. Finally, this spawned thread will send data to all client apps.
    I must point out that I could handle some things better using collection classes. But ignoring that, I�m most interested in other design flaws I made. For example:
    a) how scalable is this server app?
    b) what would you�ve done differently ( in terms of basic program structure )? Perhaps creating ControlThread object each time data needs to be sent to other client apps is a bad idea
    c) etc
    package serverchat;
    import java.net.*;
    import java.io.*;
    public class Main {
        public static void main(String[] args) {
            Server.runAll();
    class Server{
        static int servPort = 1600;
        static ServerSocket servSock;
        static Thread controlThread;
        static ClientHandling[] clientClass=new ClientHandling[20];
        static int numClients = 0;
        static Socket clientSockets[] = new Socket[20];
        static void runAll(){
            initServer();
            handleClient();
        static void initServer(){
            try{
             servSock = new ServerSocket( servPort );  
             catch(Exception e){}
        static void handleClient(){
            try{
                while(true){
                  clientSockets[numClients]  = servSock.accept();
                  clientClass[numClients] = new ClientHandling(clientSockets[numClients]);
                  numClients ++;               
            catch(Exception e){
    /*Each time some clientHandling thread receives data from client,
    it creates new ControlThread thread. This thread then sends this data
    to all clients connected to this server*/
    class ControlThread implements Runnable{
        ClientHandling[] clientClass=new ClientHandling[20];
        int numClients;
        String message;
        Thread t;
        ControlThread(String message){
            this.message = message;
            this.numClients = Server.numClients;
            this.clientClass = Server.clientClass;
            t = new Thread(this);
            t.start();
        public void run(){
            System.out.println("ControlThread has started");
                   for(int i= 0; i < numClients; i++){
                       if( clientClass[i] !=null ){
                           tellClients(i);
        /* sends data to all the clients. It does this by calling contrToClient()
         on an object that received this data from the client*/
        void tellClients(int i){
               clientClass.contrToClient(message);
    class ClientHandling implements Runnable{
    Socket clientSocket;
    Thread t;
    String message;
    OutputStreamWriter clientWrite;
    InputStreamReader clientRead ;
    BufferedReader readBuf;
    BufferedWriter writeBuf;
    ClientHandling(Socket s){
    clientSocket = s;
    startThread();
    void startThread(){
    t = new Thread(this);
    t.start();
    public void run(){ 
    try{        
    clientRead = new InputStreamReader (
    clientSocket.getInputStream(), "utf-8");
    readBuf = new BufferedReader (clientRead);
    catch(Exception e){ 
    do{   
    try{
    clientSocket.setSoTimeout(1000);
    message = "";
    message = readBuf.readLine();
    if ( !message.equals("") ){
    informContrThread();
    System.out.println(message);
    catch(Exception e){
    }while ( !message.equals("Stop") );
    try{
    clientSocket.close();
    catch(Exception e){
    /*this is the actual method that gets called by ControlThread object and
    sends received data to all the client apps*/
    void contrToClient( String message){
    try{
    OutputStreamWriter clientWrite = new OutputStreamWriter (
    clientSocket.getOutputStream(), "utf-8");
    writeBuf = new BufferedWriter (clientWrite);
    catch(Exception e){
    try{
    writeBuf.write(message + System.getProperty("line.separator"));
    writeBuf.flush();
    catch(Exception e){   
    try{
    clientSocket.close(); /* I assume I should close the connection
    with client if write() throws an exception? */
    catch(Exception e1){}
    /*creates new ControlThread object, which in turn will
    make sure all client apps receive this data*/
    void informContrThread(){
    System.out.println("informing contrThread");
    new ControlThread(message);
    thank you                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    1.server creates new client thread for each newly accepted connection Good. Make sure the server doesn't do any I/O in the accepting thread, including even construction of input and output streams.
    2.if one of these client threads receives some data from the client, then:
    3. this client thread creates new ControlThread object (and passes received data to it )Why? What does the Control thread do that the client thread can't do? Does the client thread really create a new Control thread per piece of received data? What's the purpose of the Control thread here?
    4. ControlThread object in turn spawns a new thread Again why?
    From your description you appear to be creating:
    (a) a thread per connection
    (b) a thread per piece of received data
    (c) another thread per (b)
    What you probably need for a chat server is an input thread and an output thread per connection. The output thread should read a queue and the input thread should write to the appropriate queue(s), making sure you don't create a loop by sending the client's own data back to him.
    5. Finally, this spawned thread will send data to all client apps.No. Use one output thread per connection, as described above. As writing to a socket can block, you shouldn't use a single thread for writes to more than one client, otherwise the whole system can stall due to one non-co-operating client.
    a) how scalable is this server app?It's about as non-scalable as it could possibly be. You will have an explosion of threads per item of data received if you've described it correctly, and you already have too many threads per connection.
    b) what would you�ve done differently ( in terms of basic program structure )?Almost everything: see above.
    Perhaps creating ControlThread object each time data needs to be sent to other client apps is a bad ideaMost definitely.

  • It's the Mac book air good for graphic design and video editing ?

    I'm into graphic design for clothing logos etc. and I'm a photographer my question is, is the Mac book air good for these things?

    ideally a 15" would be best for same, as referring to the 15" macbook Pro.
    For a photographer, which I used to be long ago, either the Air or Pro are close in form factor for travel with only one moving part, and SSD.
    The retina display in combination with the 15" would be idea as best choice for photo editing and graphic design.
    http://www.apple.com/macbook-pro/features-retina/

  • Swing - Design View not shown correctly

    I am using swing Layout Managers to design a JFrame. The problem is that the design view does not show correctly how the components are laid out. But when I run the application, the components are placed properly as expected. Why can't then jdeveloper show the components properly in the design view.
    regards,
    nirvan.

    Just bouncing this one, in case it has eluded expericened eyes.

  • Searching for a good relational database design tool

    Hi!
    I am designing an oracle database for our plant, and I want to use a entity-relationship diagram tool to create it.
    I want to design the data diagram with it, and generate creation code and run it to create the DB on our oracle server.
    I would appreciate that someone suggest good quality tools that can be used to do entity-relationship diagrams and implement the db not only on oracle, but to SQL server as well, as future designs for other projects may be implemented in SQL server.
    A small list of quality tools with their noteworthy features would be greatly appreciated.
    Best wishes to all!

    For Oracle database, Oracle Designer is the best.
    If you want to be able to use it for various databases you might think of:
    - ERwin
    - Embarcadero ER Studio
    - Sybase power designer

  • MBP, Are they good for graphic design???

    Hi...
    I ve been thinking of buying a MBP because most of the time as a freelance l move from one place to another, and im wondering if this "babes" will do me just fine for design,the thing is that most of the programs that I use are photoshop, illustrator, flash, firework, dreamweaver, after effects, and some times editing in finl cut, and I ve been reading in other post that most of this progrmas run slower, and they recomend the G5 Quad, but for the moment I don t have that kind of money and as a told you I move a lot, what can a do, should I go for it?? or what??...
    Thanks

    Well, Yes, the G5 quad would be appropriate for you, but how does that solve your moving around problem?
    The MBP is perfect for your needs, think about the future a bit, and all applications you mentioned will run natively. As of now, the speed difference between the G4 Powerbooks and the MBP is so minute while runing Adobe apps that it makes no sense to invest in older technology for immediate gains.
    Also, if you do a search, you will find many related topics and your question has been answered.
    Good luck.

  • Good Java GUI Designer... & UML Eclipse Plugin...

    Hi,
    Im starting my final year project in september & while I have some free time I wanted to get prepared and set up my development environment.
    Im going to be using Eclipse for the IDE which is fine.
    But I need a GUI designer, so I can throw a GUI together quickly so I can get a prototype out for December.
    But I have searched High and Low for one and threre does not seem to be a decent (free) one about Jigloo seems to have problems on my mac and does not seems to be that good.
    Any suggestions?
    Also can anyone recommend and good UML plugin for eclipse?
    Message was edited by:
    ChrisUK

    Why not use Netbeans? I don't think you will find a better GUI builders than Matisse.
    I have used Jigloo, it is okay but I would rather build my GUI in Netbeans and then import my code to Eclipse.
    I have never used any UML plug-ins for Eclipse but I have used Poseidon which is free for non-commercial use and a pretty cool UML designer.
    http://www.gentleware.com/uml-software-community-edition.html
    http://www.netbeans.org/kb/41/flash-matisse.html

  • Good app for designing a house

    Does anyone know about a good app that I can use to draw the plan design a new house?

    One way to find an app at the App Store is to use keywords.
    Type   print labels   in the search field top right corner of the App Store window then press Enter or Return on your keyboard.
    Click one of the apps listed. Always check Requirements under Information and definitely read customer reviews before purchasing and make sure there is a support link available in case you need to contact the app developer for questions.
    This forum is mainly for troubleshooting the App Store.
    For feedback for software designed for printing labels, try posting your topic in the Mac OS X community here.

  • Can anyone recommend a good app for designing and printing labels?

    I have just switched from pc to mac and have pages on my macbook but it does not have a label function (please apple sort this out its the only major flaw!) so can anyone recommend a good app that will do what a pc does? I do not really want to pay £85+ for office for mac just for the word program

    One way to find an app at the App Store is to use keywords.
    Type   print labels   in the search field top right corner of the App Store window then press Enter or Return on your keyboard.
    Click one of the apps listed. Always check Requirements under Information and definitely read customer reviews before purchasing and make sure there is a support link available in case you need to contact the app developer for questions.
    This forum is mainly for troubleshooting the App Store.
    For feedback for software designed for printing labels, try posting your topic in the Mac OS X community here.

  • Are the Imacs good for Graphic Design/Illustration work?

    I work as a digital illustrator so I spend all day at a monitor. I'm thinking of replacing my powerbook and am leaning towards a 20" Imac.
    Does anyone else here use their Imac for professional graphic design or illustration work? How does it measure up?
    I've seen many posts about poor screen quality. Should I steer clear of the Imac, or are the screens adequate for design work? At the moment I use a 17" Apple studio display (the old stripey framed kind) which is fine for my needs. How does the Imac screen compare to this?
    Is it easy to connect an external monitor (I'd use my Apple Studio Display as a 2nd screen) and can you set them up so they create a giant screen area - i.e. not just 'mirrored'? I already have a VGA to DVI adaptor so presumably this is all I'd need to hook up my 2nd screen?
    Is the 24" Imac screen quality much better than the 20"?
    Sorry, so many questions! Any advice or opinions much appreciated - Many thanks.

    To answer your first question yes they are great for digital illustration. However this will depend on how color accurate your work requires. The only downside I have found with the 20" iMacs is narrow viewing angles. This will be nothing new to you since you have the older 17" studio display. The 24" iMacs are all around absolutely stunning and have much better viewing angles however I have seen a lot of them(including mine) that have some degree of uneven back lighting. If you live anywhere near an Apple store or reseller I would recommend that you go into the store and actually use both of the machines for some period of time and see for yourself how you like it. Bring some of your illustrations from home on a flash drive to see how they look. Otherwise IMO these machines are superb. I love my 24" and it runs CS3 Apps amazingly fast.
    If your 17" studio display has the ADC(Apple Digital Connector) then you will have to purchase the power supply adapter to make it work. If you are unsure if it qualifies or not just look and see if your display has it's own power plug. If not then you will need this adapter for $99. IMO it's not worth it as you could put the $100 bucks toward a new display.
    http://store.apple.com/1-800-MY-APPLE/WebObjects/AppleStore.woa/wa/RSLID?mco=7E4 EB91E&nplm=M8661LL/B
    George

  • Good or Bad Design

    The following is the design for a reporting module. Any suggestions on the same would be appreciated.
    1) ChartGenerator implements Generator.
    Attributes �
    private int ncompID = UNDEF
         private int njobId = UNDEF
         private String storedproc = ""
         private java.util.Date fromdt = null
         private java.util.Date todt = null
    Methods �
    generateTrendlinevalues(String[] entities2plot)
    generatePieChart(String[] entities2plot)
    generateBarChart(String[] entities2plot)
    generateBarChart(ReportingLabelsAndValues labelvals,
    String[] boards)
    2) GenerateValues implements Generator.
    Attributes �
         private int ncompID = UNDEF;
         private int njobId = UNDEF;
         private Date fromdt = null;
         private Date todt = null;
         private double[] values = null;
         private String[] labels = null;
    Methods �
    public BaseObjectList generateData(String storedproc)
    public String[] getLabels()
    public double[] getValues()
    3) ReportingSource extends baseobject
    Attributes �
    String label
    Double value1
    Methods �
    getSetRepSource()
    4) ReportingSourceDAO extends baseobjectDAO
    5) Servlet � responsible for generating the chart
    Code in the servlet
    GenerateValues gvalues = new GenerateValues(compid, jobId, frmdt,todt);
    ChartGenerator obj = new ChartGenerator(compid, jobId, frmdt, todt, storprocname);
    String[] boards = req.getParameterValues("boards");
    ReportingLabelsAndValues labelvals = obj.generateTrendlinevalues(boards);
    XYChart cxy = obj.generateXYChart(labelvals, boards);
    PieChart cpie = obj.generatePieChart(boards);
    XYChart cbarchart = obj.generateBarChart(labelvals, boards);

    The following is the design for a reporting module.
    Any suggestions on the same would be appreciated.To create reports?
    There are certainly commercial libraries that do this and I believe there is at least one open source one as well, so the first suggestion would be to use one of those instead of creating one.

Maybe you are looking for