Class organisation of a GUI based application

I am interested in some tips on how to organise classes in a application that has a GUI.
I am not sure how many classes should i have.
Should there be a new custom class for every component i use? Or should i make custom classes only for containers like JPanels?
Do you know any patterns or conventions that could be of help... some tutorial of that sort that can be downloaded?
Thank you.
Borut.

Check out the Model View Controller pattern for this look up MVC, and see what you get, this is where you prob want to go w/ this. Good luck
harold smith iii
[email protected]
GO HOKIES

Similar Messages

  • Creating GUI based Help File!!!

    Can anyone point me to a resource where I can find information for creating Help for a GUI based application? I know that javadoc can create API specification for standalone programs but I like something for GUI based application like the one found on MS Word under Help menu.
    Need help plz.
    --DM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    If anyone is trying to find out how DM777 implemented help. I would guess that he found JavaHelp.
    Here's a search to get you started
    http://onesearch.sun.com/search/developers/index.jsp?and=javahelp&nh=10&phr=&qt=&not=&field=&since=&col=javadoc&col=javatecharticles&col=javatutorials&col=devarchive&col=devall&rf=0&Search.x=0&Search.y=0

  • Conversion of forms5.0 to web based application

    dear folks,
    i have an existing application which runs on forms 5.0. i want to
    convert it to a web based application. i do not want to rewrite
    the scripts.if some of you could tell me the details about how to
    go about it.
    null

    I am not sure if there is any tool to do that.
    You can delete WebSphere specific xml files from ear/jar and open it in Weblogic's builder tool. Weblogic Builder is a GUI tool. Helps you assign values for deployment parameters, Transaction attributes, JNDI names and so on. Then you can generate deployment descriptors. Subsequently you can modify the descriptors as and when you want.

  • Registering the Web based application as a Partner Application

    Good day
    I went through the suggested documentation of registering a
    web based application as a partner application of the SSO Login Server.
    I installed the SSOSDK.JAR and went through the demo application (JSP Demo)
    which consists of the following programs :
    papp.jsp
    ssoinclude.jsp
    ssoEnablerJspBean
    SSOEnablerBean
    SSOSignon
    As per the technical documentation,I register this demo application as a
    partner application.
    1 - The source code of the papp.jsp checks for the existence of the user
    through method of ssoEnablerJspBean [getSSOUserInfo(request, response)] which
    calls method of SSOEnablerBean [getSSOUserInfo (request, response) and this
    method calls getUserInfo(p_request) of SSOEnablerBean (the same program) to
    check the existence of the application cookie.
    2 - If it doesn't exit , it redirect it to the SSO Login page for user
    authentication.Once the user is authenticated, a SSO login cookie is created on
    the client's browser and redirects back to the SSOSignOn.
    3 - The SSOSignOn program creates the application cookie and redirects back to
    the entry point of the demo application which is papp.jsp.
    My Questions are as follows :
    1 - Instead of creating a session object within my web based application to hold some
    information used between the different pages, can I define them in the
    application cookie? kindly advise? Is there any limitation for the length of
    the application cookie? If yes, what will be the risk?
    2 - The SSOSignOn program is calling a method in the SSOEnablerBean
    [setPartnerAppCookie(response, request). Within this method , it is retrieving
    the parameters values of the request object as :
    request.getParameterValues("urlc")[0];
    What is the role of this [urlc]? Is it hard coded? Can I change it?
    3 - In order to ensure that I am still dealing with the same user, shall I put
    the above security check procedure on each page of my weeb based application? Kindly advise?
    Thanks in advance for your prompt feedback
    regards

    Dear Paul
    I think there is a misunderstanding regarding the last correspondence.
    I am talking about the customized home page of the PORTAL and not the home page of my web based application (JSP) .So in this case, Am I able to use the customized home page which contains a login portlet instead of the default Login page of the SSO Login Server.Kindly advise!!!
    On the other hand, I am facing a problem during the surfing of the web based application.
    The web based application consists mainly of two packages :
    Package I : Bank.counter which contains a set of jsp pages.
    JSP_HOME_COUNTER (MAIN PAGE WHICH CONTAINS 2 FRAMES)
    JSP_LEFT_FRAME_COUNTER
    JSP_MAIN_FRAME_COUNTER
    JSP_MAIN_FRAME_COUNTER_DETAIL
    Package II : Bank.portfolio which contains a set of jsp pages.
    JSP_HOME_PORTFOLIO (MAIN PAGE WHICH CONTAINS 2 FRAMES)
    JSP_LEFT_FRAME_PORTFOLIO
    JSP_MAIN_FRAME_PORTFOLIO
    Please note that the SSO classes are residing under the first package.
    As agreed on in the third question, I am including in each page of my web based application, a security check procedure as follows :
    <%@ include file="ssoinclude.jsp" %>
    <%
    if(usrInfo == null)
    response.getWriter().println("<center>User information not found</center>");
    else
    my jsp code.......
    %>
    Please note that all the jsp page of the portfolio package are pointing to the SSO classes as follows :
    <%@ include file="../counter/ssoinclude.jsp" %>
    <%
    if(usrInfo == null)
    response.getWriter().println("<center>User information not found</center>");
    else
    my jsp code.......
    %>
    Once I invoke the JSP_HOME_COUNTER , it will render the JSP_LEFT_FRAME_COUNTER page and
    JSP_MAIN_FRAME_COUNTER page which invokes the SSO Login page. Once the user has been authenticate, the result of the JSP_MAIN_FRAME_COUNTER is rendered successfully. The result contains an hyperlink to the
    JSP_MAIN_FRAME_COUNTER_DETAIL page. As the user has been authenticated , this page is rendering automatically the result without displaying the SSO Login page. (Perfect as of now!!).
    Once I invoke the JSP_HOME_PORTFOLIO from the JSP_HOME_COUNTER, it runs the security procedure without any rendering of the SSO Login page (fine!!) but redirects me back to JSP_HOME_COUNTER instead of rendering the result of the JSP_HOME_PORTFOLIO.
    please note that the m_requestUrl variable in the SSOEnablerJSPBean class has been assigned the folowing value : JSP_HOME_COUNTER
    Kindly advise .

  • Table View in View-based Application

    Hi.
    I want to use an UITableView in a View-based Application.
    All examples I found are for Navigation-based Applications.
    I Found only one example for View-based Applications, but it create all components himself without the Interface-Builder.
    I search an example with Interface-Builder.
    My main problem is, when i create a view with Interface-Builder, the controller class does not inherit from UITableViewController.

    GrinderFX wrote:
    I want to use an UITableView in a View-based Application.
    Hi, and welcome to the Dev Forum!
    Firstly, I would point out that you don't need to use UITableViewController to control a table view. The table view controller is just more convenient. So for example, you could simply drag a table view from the library in IB and drop it onto your view. Then you could hook up the table view's dataSource and delegate outlets to the File's Owner. Then you would add the data source and delegate protocols to the @interface of your UIViewController subclass and add the required data source and delegate methods to the @implementation.
    I mention the above because building your table view that way is very instructive. If you want to learn more about table views in general I would recommend Chapter 8 of +Beginning iPhone Development: Exploring the iPhone SDK by Mark and LaMarche+, which includes 3 table view projects that don't involve a navigation controller.
    My main problem is, when i create a view with Interface-Builder, the controller class does not inherit from UITableViewController.
    Returning to your specific question, IB allows you to change the class of an object. Here are the steps to use the View-Based Application template as you described (In the following I'm using Grinder as the name of the project; e.g. the app delegate class is named GrinderAppDelegate, and the view controller subclass is named GrinderViewController):
    1) _Change parent of view controller subclass in your code_
    In GrinderViewController.h, you only need to change the superclass from UIViewController to UITableViewController:
    @interface GrinderViewController : UITableViewController {
    However it will be easier later on if you make new files from the UITableViewController file template:
    a) Ctrl-click on GVC.h and GVC.m in the Groups & Files tree; select Delete->Also Move to Trash;
    b) Ctrl-click on Classes; select Add->New File->iPhone OS->Cocoa Touch Classes;
    c) Select UITableViewController subclass from the right center panel and click Next;
    d) File Name: GrinderViewController.m; check Also create GrinderViewController.h;
    e) Make sure the name for these new files is exactly the same as the ones you deleted; if you make a mistake here, delete the new files and start over, because that name must be the same in several other files;
    f) Click Finish; the replacement files should now appear under Classes.
    2) _Change the view controller class in IB_
    a) Double click on MainWindow.xib under Resources in the Groups & Files tree;
    b) Make sure the MainWindow.xib window is open by selecting Window->Document from the IB menu;
    c) Locate the View Mode switch, upper-left, in the xib window, and select the Center position;
    d) The xib window should now be displaying two columns with small icons on the left;
    e) Select the Grinder View Controller icon;
    f) Select Edit-Delete to delete that icon;
    g) Select Tools->Library from the menu, and expand Controllers in the Library Panel;
    h) Drag a Table View Controller to the xib window and drop it right under the app delegate icon;
    i) Select Tools->Identity Inspector from the menu to open the Grinder View Controller Identity Panel (the new Table View Controller should still be selected in the xib window);
    j) Under Class Identity, select Grinder View Controller from the list; tab out of the Class field to be sure the selection is recorded;
    k) Ctrl-Click on Grinder App Delegate and connect the view controller outlet (ctrl-drag) to Grinder View Controller;
    l) Expand GVC in the xib window and delete the Table View icon (since we want it in the other xib file);
    m) Reselect the GVC icon and open the Grinder View Controller Attributes panel;
    n) Under View Controller, select GrinderViewController from the NIB Name list;
    o) In the Table View Controller IB Editor window, select GrinderViewController.nib to open the other xib file;
    p) Make sure the GrinderViewController.xib window is open in small icon mode as in steps b-d above;
    q) The class of the File's Owner should be GrinderViewController;
    r) Delete the View icon;
    s) Drag a Table View from the Library to where the View icon was;
    t) Ctrl-click on File's Owner and connect (ctrl-drag) it's view outlet to the Table View;
    u) Ctrl-click on Table View: connect both the dataSource and delegate outlets to File's Owner;
    v) File->Save both xib files.
    3) _Make some rows in the table view and test_
    a) Open GrinderViewController.m in Xcode;
    b) Add the commented lines (be sure to use the correct line for your target OS);
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 20; // <-- change to more than zero
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    // Configure the cell
    // add this line for OS 2.x
    cell.text = [NSString stringWithFormat:@"Row %d", indexPath.row];
    // add this line for OS 3.0
    // cell.textLabel.text = [NSString stringWithFormat:@"Row %d", indexPath.row];
    return cell;
    c) Build and Go.
    I should add that the procedure might be a little easier if you start with the Window-Based Application Template. But the above is good practice in editing xib files.
    Hope that's helpful!
    - Ray

  • JRE1.6 in Windows Vista for Swing based application

    Hi,
    I am running a Swing based and applet based application in Windows VISTA using JRE 1.6_U13. The text font is appearing bold in JRE 1.6_U13 whereas it is appearing normal while using JRE 1.5, though the style of the Font
    is "SansSerif", PLAIN and size 12 for both JRE 1.6 and JRE 1.5.
    Reason for the Issue:
    Swings follows the concept of taking the display values from the Windows UIManager(). The UIManager consists of keys and values. The values for the keys change from OS to OS. As a result, if the UIManager key values are not overridden with the customized values, the display will change from OS to OS. Hence the issue has occurred.
    Analysis:
    Case-1:
    1.     CALM is setting the font style to “Font("SansSerif", Font.PLAIN, 12)”.
    2.     This font is being set to the Label and Text components in swings.
    3.     The font class consists of Font.PLAIN argument whose value is 0 as per the java API.
    4.     This value can’t be changed.
    5.     Hence we couldn’t solve.
    Case-2:
    1.     We tried to get the key value for the key “Label.font” and tried to override its value.
    2.     But then the issue is with the Font.Plain which is one of the arguments in Font object.
    3.     Hence couldn’t achieve it.
    Case-3:
    1.     We thought of creating a new font where in we can have control over the weight and width of the text. Then set this font to respective key of the UIManager.
    2.     Here the weight indicates the bold thickness. As a result of which we thought of changing the weight.
    3.     But then the options that we have in the API are less and the least weight value is “TextAttribute.WEIGHT_EXTRA_LIGHT” which is equal to “0.5”.
    4.     This value is not sufficient as the boldness of the text is comparatively more than the text that is appearing in jre-1.5.
    5.     Then we tried to give the value manually, instead of using the API. But then, it was mentioned in the API that any values mentioned other than the ones specified in the API will be rounded to the nearest integer.
    6.     By doing this we have customized the boldness of the Label, but could not achieve the required boldness of the Label.
    Please need a urgent solution.

    Hi,
    The reason of the problem is Antialiasing effect of the graphics. In Control Panel -> Performance Information and tools -> Adjust visual effect, if the 'Smooth edges of screen font' is unchecked then the boldiness of the font or the Antialiasing effect is not there.
    But this effect is reflecting not only on my swing based and applet based application but also on the whole system.
    I tried to call the renderingHint method and change default value of the key KEY_TEXT_ANTIALIASING to VALUE_TEXT_ANTIALIASING_OFF, to make the antialiasing effect off for the application.
    I implemented the below code:
    Graphics g= new Graphics();
    Graphics2D g2d = (Graphics2D)g;
    g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
    RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
    But I am not able to create an object of Graphics.

  • Front End for BW 3.5 and Java based application

    We are trying to connect two systems; SAP based (through BW) and Non-SAP based (Sybase, Java based) applications. We are exploring BI Java SDK with UDDI or XI services to bring Non-SAP data to NetWeaver. We don't want to store all data from sybase to BW. We could use Front end of BW or any other GUI from SAP Portal. I have heard options like UI, GUI machine, net weaver developer studio, visual composer. Ideally, we would like to combine non-sap and sap data in Business explorer/BW web browser but any other front end suggestion within Net weaver frame work will help us keep our cost down. Please advise.
    Thanks.
    Vinay Karna

    We're in the middle of upgrading from 3.1 SP 22 BW w/6.20 SAPGUI. We've only upgraded a sandbox BW server at this point, but we have upgraded all BW team members with SAPGUI 6.40 FEP 5 and can successfully connect to our 3.5 and 3.1 BWs.

  • [iPhone] Navigation-Based Application template / UITableViewController

    I'm new to development for both Mac OS X, the iPhone and Objective-C, but do have decent experience with C/C++. I'm trying to put together a series of simple iPhone applications to help expand my knowledge and wanted to ask whether or not I've got the right idea regarding my next test application.
    I've used the Navigation-Based Application template to create an application that loads a Table View and populates it with a few items. I'm considering this Table View as the root menu for my application. Selecting an item from the Root Menu will take the user to a sub-menu (that is specific to the Root Menu selection). Selection of an item from the sub-menu will take the user to a view that'll let them perform a particular action.
    I'm wondering the best way to go about structuring this kind of application? Should I create a controller class and accompanying xib for each of my sub-menus? If this is the case, would I have to use the didSelectRowAtIndexPath method to detect which menu item has been selected in order to determine which sub-menu view to push?
    I'm happy to get my hands dirty and experiment (which is why I'm taking these baby steps), but I'm hoping someone with a little experience can come along and shed some light on how a relative professional would go about doing something like this?

    Sounds like a good approach. You can use initWithNibName to load a view from a nib / xib. You can also re-use the same xib for different instances of the submenu view by parametrizing initWithNibName and do any customization to the controls in viewDidLoad.

  • Client/server socket based application

    hi does anyone have example of client/server socket based application using Spring and Maven
    where application do the following
    Client sends a request with a path to any file on the server
    „h Server reads the file and responds back with the content
    „h Client outputs the content to the console
    am trying to follow this
    http://www2.sys-con.com/itsg/virtualcd/java/archives/0205/dibella/index.html
    http://syntx.io/a-client-server-application-using-socket-programming-in-java/
    am using java 6

    i have attempt code but i wht to do the following
    client/server socket based application that will read the content of a file and stream the content of the file to the client. The client must simply output the content of the file to the console using System.out. The client must be able to run in a standalone mode (non-network mode) or in a remote mode.
    Additionally the client must be designed in a way that i can print the output to a console but must be interchangeable where if requirements change i can persist the response to file or persist the response to a database.
    /* Server.java*/
    ///ifgetBoolen= true then...
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.sql.*;
    public class Server
        static String array[][];
        // STEP 1 a1  
        // Server socket
        ServerSocket listener;
        // STEP 1 a2 Client connection
        Socket client;
        ObjectInputStream in;
        ObjectOutputStream out;
        public void createConnection() throws IOException
                System.out.println("\nSERVER >>> Waiting for connection.....");
                client = listener.accept();
                String IPAddress = "" + client.getInetAddress();
                DisplayMessage("SERVER >>> Connected to " + IPAddress.substring(1,IPAddress.length()));
          public void runServer()
            // Start listening for client connections
            // STEP 2
            try
                listener = new ServerSocket(12345, 10);
                createConnection();
                  // STEP 3
    //              processConnection();
            catch(IOException ioe)
                DisplayMessage("SERVER >>> Error trying to listen: " + ioe.getMessage());
        private void closeConnection()
            DisplayMessage("SERVER >>> Terminating connections");
            try
                if(out != null && in != null)
                      out.close();
                    in.close();
                    client.close();                
            catch(IOException ioe)
                DisplayMessage("SERVER >>> Closing connections");
        public static void define2DArray(ResultSet RS, int Size)
            try
                ResultSetMetaData RMSD = RS.getMetaData();
                DisplayMessage("SERVER >>> Requested arraySize: " + Size);
                if (RS.next())
                    array = new String[Size][RMSD.getColumnCount()];
                    for (int Row = 0; Row < Size; Row++)
                        for (int Col = 0; Col < RMSD.getColumnCount(); Col++)
                            array[Row][Col] = new String();
                            array[Row][Col] = RS.getString(Col+1);
                            DisplayMessage(array[Row][Col] + " ");
                        RS.next();
                else
                    array = new String[1][1];
                    array[0][0] = "#No Records";
            catch (Exception e)
                DisplayMessage("SERVER >>> Error in defining a 2DArray: " + e.getMessage());  
        public static void DisplayMessage(final String IncomingSMS)
            System.out.println(IncomingSMS);
    //client
    * @author
    import java.io.*;
    import java.net.*;
    import javax.swing.*;
    public class ClientSystem
        static Socket server;
        static ObjectOutputStream out;
        static ObjectInputStream in;
        static String Response[][];
        static boolean IsConnected = false;
        static int Num = 0;
        public static void connectToServer() throws IOException
            server = new Socket("127.0.0.1", 12345);
    //        server = new Socket("000.00.98.00", 12345);
            String IPAddress = "" + server.getInetAddress();
            DisplayMessage("\nCLIENT >>> Connected to " + IPAddress.substring(1,IPAddress.length()));
        public static void getStreams() throws IOException
            out = new ObjectOutputStream(server.getOutputStream());
            out.flush();
              in = new ObjectInputStream(server.getInputStream());
              IsConnected = true;
              DisplayMessage("CLIENT >>> Got I/O streams");  
        public static void runClient()
            try
                connectToServer();
                getStreams();
                  DisplayMessage("CLIENT >>> Connection successfull....\n");
                  DisplayMessage("CLIENT >>> Want to talk to server");
            catch (IOException ioe)
                System.out.print("."+Num);
                Num++;
        public static void closeConnection()
            try
                out.close();
                in.close();
                server.close();  
            catch(IOException error)
                DisplayMessage("CLIENT >>> Could not close connections");
        public static void Start()
            System.out.print("\nCLIENT >>> Attempting connection.....");
            try
                IsConnected = false;
                while (IsConnected == false)
                    runClient();
                    if (IsConnected == false)
                        Thread.sleep(100);
            catch (Exception e)
                DisplayMessage("CLIENT >>> Attempting connection.....");
        public static String sendSMS(String sms)
            Response = new String[0][0];
            try
                DisplayMessage("CLIENT >>> " + sms);
                out.writeObject(sms);
                out.flush();
                Response = (String[][])in.readObject();
                DisplayMessage("CLIENT >>> Waiting for server to respond...");
                for (int Row = 0; Row < Response.length; Row++)
                    System.out.printf( "_SERVER >>> \t");
                    for (int Col = 0; Col < Response[Row].length; Col++)
                        //DisplayMessage( "_SERVER >>> " + Response[Row][Col] + " ");
                        System.out.printf( "%s\t", Response[Row][Col]);
                    System.out.println();
                DisplayMessage("CLIENT >>> Query processed successfully....\n");
            catch(ClassNotFoundException cnfe)
                DisplayMessage("CLIENT >>> Class not found for casting received object");
            catch(IOException ioe)
                reConnect();          
            catch (Exception sqle)
                DisplayMessage("CLIENT >>> Error sending query ??? " + sqle.getMessage());
            return "transmission successfull";
        public static void reConnect()
            try
                DisplayMessage("CLIENT >>> Connection was lost. Trying to reconnect...");
                closeConnection();
                Thread.sleep(100);
                IsConnected = false;
                while (IsConnected == false)
                    runClient();
                    Thread.sleep(200);
            catch (Exception e)
                DisplayMessage("CLIENT >>> Error trying to Re-Connect...");
        public static void DisplayMessage(final String IncomingSms)
            System.out.println(IncomingSms);
        System.out.printf("Isms: %s", IncomingSms);  ///naah.
        public static String[][] getResponse()
            return Response;
        public static String getResponse(int row, int col)
            return Response[row][col];
    how can i do below using above code
    The program must be able to work in a non-networked mode. In this mode, the server and client must run in the same VM and must perform no networking, must not use loopback networking i.e: no “localhost” or “127.0.0.1”, and must not involve the serialization of any objects when communicating between the client and server components.
    The operating mode is selected using the single command line argument that is permitted.
    imust use a socket connection and define a protocol. networking must be entirely bypassed in the non-network mode.

  • Dealing with a turn based application with using a global static variable

    Hi there. I read some articles about JavaFX concurrency,so as a newbie i have to practice on it. Now i'm trying to implement a turn based application that can be played among 3-6 players. Moreover, i use a scene imported from a .fxml file and i have to update it correctly depends on some calculations of each thread (in other word players ). My main issue is, i don't wanna use a while loop which checks the state of game like;
    while( GameState != State.GAME_OVER ){
         currentPlayer = GameBoard.getNextPlayer();
         // do some actions,calculations etc.
    So, i want to use worker threads instead of this while loop. I guess using Service class for iterating and assigning the next player will be suitable instead of using the while loop and Tasks for doing each player's calculation,or waiting for some responses from Human players on UI based,however, i'm struggling with two problems.
    There should a global static variable ( like GameState which is an Enumarator ) determines the state of the game,so it should be updated and should be checked by each turn. Is there any way to do this ?
    How can i get rid off this while loop ?
    I will appreciate for every answer. Thanks anyway.

    It shouldn't make too much difference. The basic idea is that you have a model class representing your game state (the Game class in jsmith's example). When a player makes a move, you update the state of the game. Since this will result in changes to the UI, this update should be performed on the FX Application Thread.
    If the player making the move is a human player, the move will likely be made by a user action (button press or mouse click, etc); this will be handled on the FX Application thread anyway.
    When the state of the game changes so it is the turn of an "artificial" player to make a move, have the object representing the artificial player calculate its next move, and then update the game state. Since this is a response to the game state changing (it's now the turn of the artificial player), this will also be on the FX Application Thread.
    The only (slight) complexity comes if the calculation of the move for the artificial player takes a long time. You don't want to perform this long running calculation on the FX Application Thread. The cleanest way to manage this is to launch a Task which calculates the desired move, and then updates the game state when the move is ready. So, something like this:
    GameState game = ... ;
    // UI is bound to the game state.
    ExecutorService executorService = ... ;
    final Player currentPlayer = game.getCurrentPlayer() ;
    final Task<Move> calculateMoveTask = new Task<Move>() {
         @Override
         public Move call() {
              Move move = // compute next move...
              return move ;
    calculateMoveTask.setOnSucceeded(new EventHandler<WorkerStateEvent>() {
         @Override
         public void handle(WorkerStateEvent event) {
              gameState.makeMove(currentPlayer, calculateMoveTask.getValue());
    executorService.submit(calculateMoveTask);
    If you're doing more threading than that, you're probably doing it wrong... . There should also be no need for anything to be held as a "global" static variable (the idea above is the only structural modification you need to the example posted by jsmith).

  • Separte GUI and application code

    Below is my code to separate GUI and application code. When i try to execute the code i get message applet not initiated. Can any one point what mistake i am doing in the code.
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    class ColorAction extends AbstractAction
         public ColorAction(String name, Icon icon,Color c, Component comp)
              putValue(Action.NAME, name);
              putValue(Action.SMALL_ICON,icon);
              putValue("Color",c);
              target = comp;
         public void actionPerformed(ActionEvent evt)
              Color c = (Color)getValue("Color");
              target.setBackground(c);
              target.repaint();
         private Component target;
    class ActionButton extends JButton
         public ActionButton(Action a)
              setText((String)a.getValue(Action.NAME));
              Icon icon = (Icon)a.getValue(Action.SMALL_ICON);
              if(icon != null)
                   setIcon(icon);
              addActionListener(a);
    public class SepGUI extends JApplet
         public void init()
              JPanel panel = new JPanel();
              Action blueAction = new ColorAction("Blue",new ImageIcon("a.gif"),Color.blue,panel);
              Action yellowAction = new ColorAction("Yellow",new ImageIcon("a.gif"),Color.yellow,panel);
              Action redAction = new ColorAction("Red",new ImageIcon("a.gif"),Color.red,panel);
              panel.add(new ActionButton(yellowAction));
              panel.add(new ActionButton(blueAction));
              panel.add(new ActionButton(redAction));
              Container contentPane = getContentPane();
              contentPane.add(panel);
    }

    public class SepGUI extends JApplet
      public void init()
        JPanel panel = new JPanel();
        try
          Action blueAction = new ColorAction("Blue",new ImageIcon(new java.net.URL (getCodeBase(),"a.gif")),Color.blue,panel);
          Action yellowAction = new ColorAction("Yellow",new ImageIcon(new java.net.URL (getCodeBase(),"a.gif")),Color.yellow,panel);
          Action redAction = new ColorAction("Red",new ImageIcon(new java.net.URL (getCodeBase(),"a.gif")),Color.red,panel);
          panel.add(new ActionButton(yellowAction));
          panel.add(new ActionButton(blueAction));
          panel.add(new ActionButton(redAction));
        catch(Exception e){}
        Container contentPane = getContentPane();
        contentPane.add(panel);
    }

  • OC4J support Ajax based Application, If yes....give me example

    Hi,
    I did Ajax based application and getting output in MyEclipse with Tomcat server.
    but, same Ajax Program I am running in oracle jdeveloper with OC4J, it's not getting output......
    can anyone help.....what is the reason.....
    regards,
    Abu

    Sorry for posting no code.
    I was hoping it was a common problem with the ajax anyware framework.
    Folow some simple part of the application :
    [JSP BEGIN]
    <aa:zone name="pgoVerbaZone">
                                   <t:dataList var="pgoVerba" value="#{amortizaBean.proAmorPOJO.listaPgoVerba}" rowIndexVar="indice">
                                          <f:verbatim>
                                                <table border="0" cellpadding="0" cellspacing="10" width="100%">
                                                   <tbody><tr>
                                                     <td><label class="label">Valor*</label>
                                                     </f:verbatim>
                                                                        <h:inputText id="valorPagPrinc" alt="Verba Principal e Reflexo - Pagamentos - Valor" value="#{pgoVerba.valorPagPrinc}"
                                                                size="18" onblur="mascara_numero_controle_extra(this, 'dinheiro', true);" onkeyup="mascara_numero_controle_extra(this, 'dinheiro', false);" />
                                                     <f:verbatim>
                                                     <td>
                                                     <label class="label">Tipo*</label>
                                                         </f:verbatim>
                                                         <h:selectOneMenu id="selectTipoPrinc" value="#{pgoVerba.tipoPagamentoPrinc}">
                                                                     <f:selectItems value="#{amortizaBean.listaTipoPagamento}" />
                                                                </h:selectOneMenu>
                                                         <f:verbatim>
                                                       </td>
                                                     <td><label class="label">Data do recolhimento*</label>
                                                      </f:verbatim>
                                                          <h:inputText id="dtRecoPrinc" alt="Verba Principal e Reflexo - Pagamentos - Data Recolhimento" value="#{pgoVerba.dtRecoPrinc}" size="10"
                                                          onblur="verificarData(this);" onkeyup="autoTab(this, 10, event); mask_input_date(this);" maxlength="10"/>
                                                     <f:verbatim>
                                                     </td>
                                                     <td>
                                                     <label class="label">Priorizar juros*</label>
                                                          </f:verbatim>
                                                          <h:selectOneMenu id="selectPriorizarJurosPrinc" value="#{pgoVerba.priorizarJurosPrinc}">
                                                                     <f:selectItem itemValue="-1" itemLabel=""/>
                                                                     <f:selectItems value="#{amortizaBean.listaSimNao}" />
                                                                </h:selectOneMenu>
                                                                 <f:verbatim>
                                                       </td>
                                                     <td width="25%">
                                                          <div align="right">
                                                                </f:verbatim>
                                                                    <t:commandLink id="linkIncluirPgoVerbaAJAX" action="#{amortizaBean.incluirPgoVerbaAJAX}" rendered="#{indice eq 0}">
                                                                         <t:updateActionListener value="#{indice}" property="#{amortizaBean.indicePgoVerba}"/>
                                                                         <h:graphicImage style="border:0" alt="Adicionar Pagamento" url="/common/img/ico_novo.png" />
                                                                    </t:commandLink>     
                                                                 <f:verbatim>
                                                          </div>
                                                          <div align="right">
                                                                </f:verbatim>
                                                                    <t:commandLink id="linkExcluirPgoVerbaAJAX" action="#{amortizaBean.excluirPgoVerbaAJAX}" rendered="#{not(indice eq 0)}">
                                                                         <t:updateActionListener value="#{indice}" property="#{amortizaBean.indicePgoVerba}"/>
                                                                         <h:graphicImage style="border:0" alt="Excluir Pagamento" url="/common/img/ico_excluir.png" />
                                                                    </t:commandLink>     
                                                                 <f:verbatim>
                                                          </div>
                                                     </td>
                                                   </tr>
                                                 </tbody>
                                                 </table>
                                                 </f:verbatim>
                                       </t:dataList>
                                   </aa:zone>
    [JSP END]
    [JavaScript BEGIN]
              // Funções AJAX (AjaxAnywhere)...
              ajaxAnywhere.getZonesToReload = function(url, submitButton) {
                   // Identificando ID do componente disparado (commandButton ou commandoLink)....
                   if ((typeof submitButton != "undefined") && (submitButton.type=="submit")) {
                        componentId = submitButton.id;
                   }else {
                        if (this.findForm().elements["atualizaPagamentoForm:_link_hidden_"] != null) {
                             componentId = this.findForm().elements["atualizaPagamentoForm:_link_hidden_"].value;
                   //execeção
                   if(componentId == 'atualizaPagamentoForm:botaoEnviarAtualizacao' ||
                        componentId == 'atualizaPagamentoForm:botaoEnviarAtualizacaoRateada') {
                        return null;
                   //Zonas que será atualizadas de acordo com as requisições via AJAX.               
                   var zones;     
                   zones = 'zoneMensagem,pgoVerbaZone,pgoCustaZone,' +
                             'pgoDiversosZone,pgoReclamanteZone,pgoReclamadoZone,' +
                             'pgoTercZone,pgoIRRFZone,pgoFGTSZone,diversosZone,historicoZone';
                   setarImagemDeSubmissaoAJAX(componentId);     
                   return zones;
    [JavaScript END]
    [BEAN BEGIN]
    /** AJAX VERBA*/
         public String incluirPgoVerbaAJAX() {
              proAmorPOJO.getListaPgoVerba().add(proAmorPOJO.new PgoVerba());
              return null;
         public String excluirPgoVerbaAJAX() {
              proAmorPOJO.getListaPgoVerba().remove(indicePgoVerba.intValue());
              return null;
    [BEAN END]Well this code runs ok. The Request is Sent, the methods are called, the response is received, but nothing is rendered.

  • Class organisation for long project

    Hello there,
    I have developed a system for some collegues which, among many others, contains a single class that shows the output of their work in a GUI. My work contract runs out soon, however, these guys are going to need to continue to develop this GUI - probably by making another GUI class, which contains much of my code.
    My problem lies here: currently, my GUI class called GUI_Main sets up everything, and also passes itself as parameter to several other classes, which run as threads or whatever, so they can call methods on my GUI class once they have completed some work - to update the GUI. So; if my collegues create another GUI class sometinme, and they copoy my code and try to pass this class to other classes to update the GUI, it will fail.
    To regular Java programmers, this is a problem which can be solved trivially e.g. change the parameter types for those classes which take references to GUI_Main. However ,then there is the issue of not the original GUI_Main not working.
    I was thinking about creating an abstract class which defines the method signatures of all of the methods used by other classes to update the GUI. Then making GUI_Main and whatever other GUI class that is developed to extend this abstract class. Then, I could change the parameter types for those classes which originally were references to GUI_Main to this new abstract class.
    I wanted to make this an abstract class, and not an interface because GUI_Main is a JFrame - meaning that I would be able to make it extend JFrame. Is this ok?
    Sorry if this is too long a message - but any help on general programming practise would be very greatly received.
    - yours sincerely,,
    Edward Turner.

    Make it an interface, and phrase the method names in as generic way as possible. This will allow the greatest amount of reuse.
    eg:
    if there is something like refreshOutputPanel(ResultsData data) in GUI_Main, which is called when a Thread CalculateResultsData finishes running, make an interfaceinterface ResultsDataTarget {
    void resultsDataCalculated (ResultsData data);
    }that captures the higher level event rather that the result specific to a single GUI implementation.
    That way not only can other GUIs by used (eg an AWT dialog), the same callback interface can be used inside an application server or console app, should the need arise in the future.
    Pete

  • ArrayController in non-document based Applications

    I just tried to use the ArrayController in an app. The app was not document based. I did everything as you are supposed to do, I made up a class called AppControll, set it Files Owner of the XIB file, connected the contend Array and so on. There were no warnings or errors, the compiler said No Issues, the Build was suchsessfull. But before the window has opened, the Application crashed. On the console was this log:
    2011-05-17 16:28:45.652 MyApp[9637:903] An uncaught exception was raised
    2011-05-17 16:28:45.656 MyApp[9637:903] [<NSApplication 0x10011b240> valueForUndefinedKey:]: this class is not key value coding-compliant for the key boxArray.
    2011-05-17 16:28:45.792 MyApp[9637:903] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSApplication 0x10011b240> valueForUndefinedKey:]: this class is not key value coding-compliant for the key boxArray.'
    *** Call stack at first throw:
              0   CoreFoundation                      0x00007fff8059a7b4 __exceptionPreprocess + 180
              1   libobjc.A.dylib                     0x00007fff864c30f3 objc_exception_throw + 45
              2   CoreFoundation                      0x00007fff805f2969 -[NSException raise] + 9
              3   Foundation                          0x00007fff867abb8e -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 245
              4   Foundation                          0x00007fff866db488 -[NSObject(NSKeyValueCoding) valueForKey:] + 420
              5   AppKit                              0x00007fff8810a384 -[NSApplication(NSScripting) valueForKey:] + 492
              6   Foundation                          0x00007fff866dedcc -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 226
              7   AppKit                              0x00007fff87e9fb6f -[NSBinder valueForBinding:resolveMarkersToPlaceholders:] + 171
              8   AppKit                              0x00007fff88065f80 -[NSArrayDetailBinder _refreshDetailContentInBackground:] + 368
              9   AppKit                              0x00007fff87e92a33 -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 557
              10  AppKit                              0x00007fff87e6f546 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1172
              11  AppKit                              0x00007fff87e6d88d loadNib + 226
              12  AppKit                              0x00007fff87e6cd9a +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 248
              13  AppKit                              0x00007fff87e6cbd2 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 326
              14  AppKit                              0x00007fff87e6a153 NSApplicationMain + 279
              15  MyApp                            0x0000000100001302 main + 34
              16  MyApp                            0x00000001000012d4 start + 52
    terminate called after throwing an instance of 'NSException'
    The debugger tells me "Programm recieved signal SIGBART"
    If I cut the bnding to the contend array, the Applications stats as usual, but it dosent work, because there is no contend array.
    Then I tried something else. I made up a new project, this time a document-based one, and did exactly the same as I did before. It worked well and fine the way it should work. There was no problem and the ArrayController worked fine. I don`t think a made mistake writing the name of the array, because I allways copied and pasted the name to the IB. So I would like to know if it is possible to use an ArrayController in a Non-document based Application? What do i have to do differently? The reference about the ArrayController does not mention this. It would be great if you could help me soon, thank you.

    No, but actually this was not my Problem But It helped me figure out what the problem is in detail. If you use a document based application, NSDocument can call the subclass NSPersistentDocument. This automatically reads out the model (if you use Core Data. I do`t like Core Data because it`s sometimes a bit strange and it`s hard to hunt down bugs there, but I think basically the problem is the same) and create a managedObjectContext, wich is needed to run the NSArray Controller. The big question is now, how to call something simular to NSPersistentDocument wich is not a subclass ob NSDocument but of NSObject.

  • Running a GUI based software on powerbook G4

    Hi guys,
    I need to run a GUI based ERP software on my powerbook g4. the developer has no idea how to do so. he is not familiar with macs. but if he gets the right instructions he is ready to give it a try. Here's my query....is it possible to run this..and how so...what instructions do i give to the developer. Can you guys help to point out to certain literature which already addresses this issue. I need you help. thanks in advance.
    to the moderator...if this is posted on the wrong thread pls feel free to direct it to the right one.
    any help is appreciated.
    Powerbook G$   Mac OS X (10.4.8)  

    GUIs come in may different flavors. You need to find out more about what the developer is capable of/willing to do before you go to far. 
    If the developer has no Mac experience, it's unlikely that he'll rewrite his application as a fully-fledged Mac application since that's a non-trivial task.
    However, if the application uses a client-server model, he may be able to impement a graphical front-end without too much work. That front-end could be written in AppleScript (more likely AppleScript Studio), but he may prefer to write an app in a more traditional language such as C or C++.
    If the application is already running on other flavors of Unix, he may have an X11-based application, in which case his work is done - you can run X11 apps on the Mac without any additional programming work needed. It won't look like a traditional Mac application, but it will run (and be consistent with the other Unix systems it's running on).
    If he's familiar with Java he could write a Java-based front-end. This would probably be his best bet for all-round cross-platform portability.
    In any case, you might find the Developer or Software Development forums a more productive place to get started.

Maybe you are looking for

  • How to get primary keys in some order with joins?

    Hi, I build BBS using BDB as backend database, forum database, topic database and post database share one environment. This BBS web application is multi-thread program. If user selects one forum, its topics will be listed in order of last reply time;

  • Internal OEM CD/RW & USB Slots

    Two questions: 1.) I have an iMac G3, 233MHz, 256 MB RAM, NEW 120 GB Internal HD. I want to know what brand and MAX recognizable size internal CD/RW to replace OEM 24x (if possible)? 2.) Is it possible to upgrade from my current USB 1.1 to 2.0 (or hi

  • Dynamic ClassLoader - feasability question

    Problem: need to be able to 'hot-replace' a class definition at runtime Particulars: A method of this class popuplates a hash map with 'key-<anon.class>' pairs, ie: public void initTransformerMap() {    xMap.put("Color", new Transformer() {        pu

  • Any idea how to exchange the CTI-OS Lincense with CAD License?

    Any idea how to exchange the CTI-OS Lincense with CAD License?

  • Printing multilple pages

    Hi We are rendering the crystal report using crystal report java api. The output form of the rendered crystal report is in HTML format. We are using window.print() to print the report. A single page report is printed in three pages. Any clues how to