How to use MVC in Swing application

Hi,
I'm creating an application using Java Swing. I want to use Model View Controller (MVC) architecture to design by application. I want to use MVC to seperate by business logic functionality from the control and presentation logic that uses this logic.
I need your help to get this done successfully. Please send me a SAMPLE JAVA SWING APPLICATION where they have applied MVC, it will be helpful to me.
Thank you,
Regards
kumar

Would this be a basic example of an application that uses MVC?
//MODEL
public class Model {
     public void showMessage() {
          System.out.println("You clicked me!");
//VIEW
import javax.swing.JButton;
import javax.swing.JPanel;
public class View extends JPanel {
     private JButton buttonSave;
     public View() {
          super();
          initUI();
     public void initUI() {
          buttonSave = new JButton("Save");
          buttonSave.addActionListener(new Controller());
          add(buttonSave);
//CONTROLLER
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Controller implements ActionListener {
     private Model m;
     public Controller() {
          m = new Model();
     public void actionPerformed(ActionEvent e) {
          m.showMessage();
}Is this a correct implementation of MVC? I am trying to learn it, and use it in an example.
Thanks for your help/input.

Similar Messages

  • How to use MVC using MDM as backend... in Webdynpro for java

    Hi,
       How to use MVC using MDM as backend.. when we r using R/3 we used to create RFC model. I dont know how to use it here..
    Regards,
    laxmi.

    Haii
    Create a data a source using ur ODBC tool. This can be found in Administrative tools of windows.
    In ur connectino class u can write the following code
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc.odbc.dsnname u have given when u created data source","user namet","pwd");( I think there is no need to give username when u connect to ur access)
    The connection "con" is ready to use.. Put these statements inside a try catch...
    I think i have explained enough..
    regards
    SHanu

  • How to use stysheet for Swing components?

    Hi,
    Give me a guidence abt how to use Stylesheet for Swing components to crate good looking GUI...........thnx

    thank you for your reply,
    I want to know how many times a component is refreshed. I'm asumming the RefreshCondition attribute gets called everytime a component gets refreshed, hence it could be counted.
    I'm just not sure how to use it.

  • How to use "Find my iPhone" application ?

    How to use "Find my iPhone" application ?

    Find My Phone would have had to be activated/turned on before your phone was lost/stolen.. There is no way to do that now, thus no way to use such to locate your phone. Had you done so, you would login to iCloud.com from any computer & see if you could locate your phone.

  • EREC - How to use link generated by application group?

    How to use link generated by application group?

    Hello Vishal,
    You provide the link eg. in a list and candidates just have to click on that if they want to apply.
    Regards
    Nicole

  • How to use SES in my application?

    Hi, everybody:
    My manager plan to use SES in our application which maybe resolve our requirements. So he ask me to take a test. But now I'm in trouble.
    First, our application have more than about 500 tables, and one third of them need to be searched.shall I create each table source for them?
    Second, In the administrator's guide -- Web Services API -- search operations -- doOracleSearch Message , the parameter of groups, it says: Limit the search result to the documents from specified source groups. The default is for all groups if not set explicitly. So my code is following like this:
    OracleSearchResult searchResult = stub.doOracleSearch(req.getParameter("searchTerm"),new Integer(1), new Integer(10), Boolean.TRUE,Boolean.TRUE,null, "en", "en", Boolean.TRUE, null, null,null);
    I want get the default value, So I write null. But the result isn't all of the hits, just come from one of the table source groups. why?
    Third, Global Settings -- Translate Source Group Name, I translated my source group, I checked the search result element(oracle.search.query.webservice.client.ResultElement), the group's name and display name were same with written in English, but the infoSourcePath was translated. Where was my mistake?
    Fourth, I defined a private search attribute for a source from Global settings -- Search Attributes.
    And in the Home -- Sources , I choose a column with this attribute. When I search this hit use doOracleSearch, I get this attribute name, display name, type ,but how can I get this column value which mapped with this attribute?
    Can anyone help me?
    Thanks a lot!

    In answer to your first question, no - you probably don't want to create a table source for each table. Instead, try to create a view which combines as many as possible of these tables (perhaps with UNIONs) then create a "table" source on that.
    Not sure of the answers to your other questions, hopefully someone else will be able to answer them.
    - Roger

  • How to use prepared statement by Application Module on ADF?

    Hello
    i am using a prepared statement on the view side of my project,
    this is my code, i'm not sure about using this code.
    AppModuleGFTImpl am = (AppModuleGFTImpl) Configuration.createRootApplicationModule(amDef,config);
    try {
    ps =am.getDBTransaction().createPreparedStatement("Select * from XXXXXX where kullanici_id=? and sifre=?",0);
    ps.setString(1, kullanici);
    ps.setString(2, sifre);
    rs = ps.executeQuery();
    if (rs.next()) {
    girebilir = true;
    } else {
    girebilir = false;
    ps.close();
    rs.close();
    //am.getDBTransaction().closeTransaction(); ? I'm not Sure
    //Configuration.releaseRootApplicationModule(am, true); ? I'm not Sure
    Is it True? How we use this code on the project view side? Must we close Transaction, or release application Module.
    thanks for interest.
    sorry my english.

    Hello, for the SP you can use something like this in your application module
      private static final String BULKSTAMMENN =
        "begin IVA_OWNER.IVA_UI_ALGEMEEN_PCK.USM_SNELLE_INVOER_GUI( P_RLE_ID => :1, P_AANTAL => :2, P_OJR_JAAR => :3, P_RAS_ID => :4, P_TOELICHTING => :5, P_SUCCES => :6 ); end;";
    public void bulkStamen ( int rasId, int telerId, int jaar, int aantal, String toelichting ) {
        CallableStatement bulkStamenSP = null;
        try {
          bulkStamenSP = getDBTransaction().createCallableStatement( BULKSTAMMENN, 0 );
          bulkStamenSP.setInt( 1, telerId );
          bulkStamenSP.setInt( 2, aantal );
          bulkStamenSP.setInt( 3, jaar );
          bulkStamenSP.setInt( 4, rasId );
          bulkStamenSP.setString( 5, toelichting );
          bulkStamenSP.registerOutParameter( 6, Types.VARCHAR );
          bulkStamenSP.executeUpdate();
        } catch ( Exception e ) {
          log.warning( "Aanroep naar " + BULKSTAMMENN + " gefaald, " + e.getMessage() );
        } finally {
          if ( bulkStamenSP != null ) {
            try {
              bulkStamenSP.close();
            } catch ( Exception e ) {
              log.warning( e.getMessage() );
        log.info( "Stammen bulk uitgevoerd voor " + rasId + " " + telerId + " " + jaar + " " + aantal + " " +
                  toelichting );
      }You can then drag this method onto your page or right into your task flow if your using JDev 11.
    Also you can access it from a backing bean although the methods above are preferred
    -Anton

  • How to use Graphics in swings?

    Hi,
    I would like to write a Graphics application in swings, Is it possibel?
    help me.

    Hi,
    I would like to write a Graphics application in
    swings, Is it possibel?
    help me.Yes! a short example using JApplet in swing using graphics.
    import java.awt.Graphics;
    import java.awt.Image;
    import javax.swing.JApplet;
    public class Animate extends JApplet implements Runnable {
        Thread runner;
        boolean notDone;
        int x, y;
        public void init(){
            notDone = true;
            x = 10;
            y = 20;
            setSize(500,100);
            startRunning();
        public void run(){
            while(notDone){
                if(x < 400){
                    x++; repaint();
                    try {
                        Thread.sleep(500); // control the speed
                    } catch (InterruptedException ex) {
                        ex.printStackTrace();
                } else {
                    x = 10;
        public void startRunning(){
            runner = new Thread(this);
            runner.start();
        public void paint(Graphics g){
            animate(g);
        public void repaint(){
            try{
                Image img = this.createImage(getSize().width , getSize().height);
                Graphics g = img.getGraphics();
                g.setColor(this.getBackground());
                g.fillRect(0, 0, getSize().width, getSize().height);
                g.setColor(this.getForeground());
                paint(g);
                this.getGraphics().drawImage(img, 0, 0, null);
            }catch(NullPointerException e){}
        public void animate(Graphics g){
            g.drawString("Help me -->", x, y);
    }

  • How to use media in another application?

    Say I wish to use some of my video clips in After Effects. How do I import them into AE? The FCPX Library, of course, cannot be opened by the AE import dialog.

    Managed media should really only be ever used by someone working by themselves with their own material that doesn't need to be shared or used in any other application or by anybody else. Frankly I don't recommend managed media for any production, but there's nothing inherently wrong in it unless the library bundle gets to simply be too large.
    External media is really simple to use. When you make a new library, you select the library in FCP and in the inspector you'll see the library properties.
    The defaults for Media and Cache is In Library. Click the Modify Settings button and then create a folder for the media, assign that folder to the cache as well. Done. When you import media from a camera, it gets imported into that folder and goes into a folder called Original Media. When I have graphics files I want to use in the production I simply put them in that folder, and then when I import the graphics I use the leave in place function. Everything for the production in in one location and backed up. Think of the folder as the Capture Scratch location. The library itself stays small. Multiple libraries, multiple users on a network can access the same folder. The media inside it is available to any application.

  • How to use more than one application server during initial load?

    Hi,
    we plan to use more than one application server in CRM during initial download in order to increase the number of parallel requests and to decrease the time for the initial load. Is there a way to allocate requests to more than one server? Is is possible via multiple rfc connections for consumer CRM in CRMRFCPAR?
    Thanks.
    Alexander Schiffer

    Hi Naresh,
    thanks for your answer. It has solved my problem. SMLG is the transaction that I was looking for.
    Two more OSS notes that helped me to guide our basis into the right direction:
    OSS 593058 - New RFC load balancing procedure
    OSS 1413986 - SMLG: Possibility to select a favorite type for Ext.RFCs
    Thanks again.
    Alexander Schiffer

  • How to use GUI_DOWNLOAD inside BSP Application event

    Hi All,
    I am facing one issue while using GUI_DOWNLOAD inside BSP Application. When the processing goes at GUI_DOWNLOAD it gives me unknown error where as the same code is working when used in report program. My requirement is to save password into excel file at my local machine. I am using FM MS_EXCEL_OLE_STANDARD_DAT to save password in excel file but this function module fail when it reach at GUI_DOWNLOAD . Can you please help me out.
    Thanks and Regards
    Pradeep Kr. Rai

    Dear Pradeep,
    Find the below link which explains a simple data download to excel from a table view.
    www.sapt echnical.com/Tutorials/BSP/Excel/Index.htm
    Try to avoid the way your using in the BSP application and it is abdicable to use the standard methods / class available like "cl_bsp_utility"
    Hope this will be helpful.
    Regards,
    Gokul.N
    Edited by: Gokul on Oct 8, 2009 9:57 AM

  • How to implement Help in Swing Application

    Hi..
    In my Swing Application I want to put �Help� for Every field..
    Ex: After Username field ��� if I press �Whatisthis�. I will explain abt the user name field .in a popup text Area
    Thanks
    Cheers
    Mallik

    this may help you...
    http://java.sun.com/products/javahelp/
    regards
    Aniruddha

  • How to validate in ADF Swing application

    I created an app using ADF Swing:Holiday. My table is Holiday has: HolidayID, Holiday, Reason, Desc. I only want to show Holiday, Reason, Desc. Holiday is Date type. Now I want to validate if user type an ilegal format date?

    Are you using application express?
    For ADF try the JDev discussion forum.
    JDeveloper and ADF

  • How to use com.bruceeckel.swing

    Im trying to execute some code that comes in bruce eckel�s thinking in java, but it imports com.bruceeckel.swing, and the compiler (eclipse) doesnt know where the package is located. How do i use those classes that come with the book? where do i have to place them? please, anyone who�s gone trhu this, please explain

    Im trying to execute some code that comes in bruce
    eckel�s thinking in java, but it imports
    com.bruceeckel.swing, and the compiler (eclipse)
    doesnt know where the package is located. How do i
    use those classes that come with the book? where do i
    have to place them? please, anyone who�s gone trhu
    this, please explainDownload the class files or their source code and add/import them into your project in Eclipse.

  • How to use quartz in web applications

    Hi people,
    Can anyone please help me out how i can use quartz scheduler in web applications ? I want to utilize quartz to update databases periodically and automatically. Please help me its urgent ...:(

    Hi
    I have a requirement to implement Quartz in a we application.Technologies using as JSF, spring, hibernate and server is JBOSS. Here i am unable to decide how to implement quartz using these technologies.
    What is the methodology i have to use to implement quartz along with these technologies.

Maybe you are looking for