MVC architecture - how it can be applied to swings

hi
I have created a program that gets data from an MS access database and displays it in Swings JFrame, with view, next, previous buttions to traverse through records
I want to write my program in the MVC architecture model. Though i have read details about it, i am unable to apply it on new programs.
Any one please help me with an instance of a program or modify the below program to suit the MVC architecture
thank u
import java.awt.*;
import javax.swing.*;
import java.sql.*;
import java.awt.event.*;
class display extends JFrame implements ActionListener
ResultSet rs;
Statement st;
JTextField tf;
JLabel l;
Button b0,b1,b2;
ResultSetMetaData rsmd;
display()throws Exception
tf = new JTextField(10);
l = new JLabel("Empno: ");
b2 = new Button("Previous");
b1 = new Button("Next");
b0 = new Button("View");
connection con = new connection();
Container c = getContentPane();
c.setLayout(new FlowLayout());
setSize(300,300);
c.add(l);
c.add(tf);
c.add(b0);
c.add(b1);
c.add(b2);
setVisible(true);
l.setBounds(20, 10,70,35);
tf.setBounds(20,50, 70,35);
b0.setBounds(20,90, 70,35);
b1.setBounds(90,90, 70,35);
b2.setBounds(170,90, 70,35);
b0.addActionListener(this);
b1.addActionListener(this);
b2.addActionListener(this);
public void actionPerformed(ActionEvent ae)
if(ae.getActionCommand().equals("View"))
try{
rs.close();
rs = st.executeQuery("select * from emp");
if(rs.next())
tf.setText(rs.getString(1));
catch(Exception e)
{System.out.println(e);}
if(ae.getActionCommand().equals("Next"))
try
if(rs.next())
{tf.setText(rs.getString(1));b2.setEnabled(true);}
else
{b1.setEnabled(false);b2.setEnabled(true);}
catch(Exception e)
{System.out.println(e);}
if(ae.getActionCommand().equals("Previous"))
try
if(rs.previous())
{ tf.setText(rs.getString(1)); b1.setEnabled(true);}
else
{b2.setEnabled(false);b1.setEnabled(true);}
catch(Exception e)
{System.out.println(e);}
class connection
connection()throws SQLException, ClassNotFoundException
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:dsn1");
     /*st = con.createStatement();
rs = st.executeQuery("select * from emp");*/
st = con.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
rs = st.executeQuery("select * from emp");
} // connection constructor
} // end of connection
}//end of display
class records
public static void main(String args[])throws Exception
display d = new display();
}

help full hint use code formating tags
David

Similar Messages

  • Shared services and workspace architecture(How we can find out req &respon)

    Good morning Hyperion folks,
    Does any body have any document or PDF about workspace and shared service architecture...How these both components are communicate each other..any idea or any document..while communicating of these if anything goes wrong,,where we need to check, what is exactly the problem (any suggestible logs)...
    Company are doing big mistake by using this hyperion tool ..These guys are not supporting and even they don't know much about the tool apart Product dev team..and that too they are not disclosure any documents related product...
    **Does anybody found any kind performance tunning guide or lab guide about workspace and shared service HFM,Planning...** I have never seen component wise documents and tunning guide and recommendations.
    I am strong opnion about hyperion is,we would not get any support from oracle and documents so He can migrate Cognos TM1 and Finance management etc........
    Edited by: 888154 on 29/09/2011 02:55

    Thanks john For ur reply ..i have seen these documents long ago ..i am asking about Shared services and workspace architecture and how these are functioning and where we can find out communication error and slow login issue with workspce and shared services.. How authentication is log on ..is there any machanisam they are using for authencation ...We are using OpenLadp ...
    Ex :1.Per suppose log on to workspace that request goes to shared services directory and it will check whether that user is exists or not on Shared services tables ...here what kind of alogirtham using to aunthenticate user...How we can diagonse this process taking to much time,,,is there any specific logs related this (If logs are exsits how we can find out)...
    2.Once authencation done successfully and responce send to workspace and populate workspace home page...then i click on application button (FM application) and it's taki ng to much time to load HFM page.To this where we need to look whta excatly problem? what are logs file helpful to us to diagonse..

  • How can i apply adobe bridge in my ipad 2?

    how can i apply adobe bridge in my ipad 2?

    As when installing an app on a computer, there must be a version for the app that is compatible with the computer and the OS running the computer.
    Is there an Adobe Bridge app for the iPad available via the iTunes app store?

  • How can I apply a backup of one device to a different device?

    Hello,
    This past week, my phone "fell" and the screen broke beyond all repair. And I'm not talking about a crack...I'm talking about a huge crack as well blue lines being displayed whenever I hit the home button. Other than that, the phone still works. It charges, it syncs, it vibrates when I get calls or messages but I can't see anything on the screen. I know that I can still unlock though. I managed to backup my pictures directly onto my Mac using iPhoto. Besides my pictures and Calendar dates, there wasn't much that I cared for within the actual phone.
    I went to my local phone service provider place and they told me that since my phone was a 4S and was covered for damage, I could send it to Apple in exchange for a new phone. I already contacted them and received my new 5C. Now, I'm not really worried about the pictures because they're already in my computer; I'm worried about all the Calendar dates that are in my broken 4S. Yes, I did do a backup AFTER it fell so I have a backup ready. But the thing is that I do not wish to sync this onto my new 5C just for the calendar dates.
    I have an old iPod 4th Generation that I'm willing to use to restore with the backup of my 4S but I don't know how to do that. I was hoping that I could apply the backup of my 4S onto my iPod and then manually enter all the dates that I needed onto my 5C
    If anyone knows how I can access these dates in any way, shape, or form, it would be greatly appreciated.
    Oh and I don't think I ever used iCloud for my calendar so that's just a huge setback, huh?

    Yes, you can restore the iPod Touch from the iPhone backup, provided the iPod Touch's iOS is the same or better than that of the iOS that was on the iPhone.  Example: If you had your iPhone updated to iOS 7.1.1 when you backed it up, your iPod Touch will need iOS 7.1.1   Currently only the 5th Gen iPod Touches can receive this version of iOS.  4th Gen and prior cannot update to iOS 7.
    The following article shows limitations when going from iPhone/iPod Touch to iPad or vice versa.  The iPhone and iPod Touch are essentially identical with the minor exception of the phone app.  They still have all the contacts apps, etc.
    iTunes: About iOS backups
    Only app data from App Store apps and sync settings will be restored to your device when you do the following:
    Restore your iPad from an iPhone or iPod touch backup.
    Restore your iPhone or iPod touch from an iPad backup.

  • How can I apply my CS Photoshop membership to a second computer?

    how can I apply my CS Photoshop membership to a second computer?

    Thank You!
    I felt like I was wandering through mazes to get that question to the right
    venue.
    Thanks again,
    Gayatri

  • How can I apply color to black and make it accurate?

    Hello,
    I have an illustration that is black, white, and shades of gray. I want to apply a color to the black, and have all the grays become tints of that color. I have tried different blending modes and I have tried monotones, but I don't think either of these techniques are working. When I go back to check the color, it's a different color, and it prints looking different than the color I had selected.
    Do you know how I can make this happen?

    May I suggest:  Layer - New Adjustment Layer - Black & White, then use the Tint facility.
    Personally, I often find it more handy (and providing more control) to use a Curves adjustment layer above all the others.  Grab the curves of individual color channels and pull them this way and that to alter the color of what's underneath.  It's not hard to keep whites white, blacks black, and give the stuff in between believable coloration.
    -Noel

  • How I can apply more than one DBI reports at a time?

    I have many DBI reports (and maybe dashboards in future) in one database and I want to transfer them to second database. Of course I can export every report to individual zip file and than import this file to second database. But how I can import all my reports at a time? I tried to simply merge files in archives. But EBS imported only one report from merged zip file. Then I downloaded some patches (for example, E-Business Intelligence Family Pack 11i.BIS_PF.F) and explored their structure. I copied xml files with report description (RPerPersonsLayoutsource.xml and RPerPersonsDocsource.xml) from zip archive to <patch directory>\bis\mds, set versions in file-version attribute to 120.6 and wrote driver file. Than I tried to apply this patch. There was no errors (as I think) but report didn't appear in database.
    So, can I do something to transfer many DBI reports at a time?
    P.S. Driver file text:
    begin aru xxbis_test
    compatible release 12.0.0
    compatible platform GENERIC
    compatible parallel always
    compatible language RU
    characterset cl8mswin1251
    # installation for bis module
    begin bug bis xxbis_bis_test
    begin actions
    #=================================#
    # Actions for Copying Patch Files #
    #=================================#
         copy bis mds RPerPersonsDocsource.xml 120.6
         copy bis mds RPerPersonsLayoutsource.xml 120.6
    #=======================================#
    # Actions for Applying Database Objects #
    #=======================================#
         # file-version-parsed bis mds RPerPersonsDocsource.xml 120.6
         exec java oracle/jrad/tools/xml/importer XMLImporter.class java &phase=dat+24 checkfile:bis:mds:RPerPersonsDocsource.xml &fullpath_bis_mds_RPerPersonsDocsource.xml -username &un_apps -password &pw_apps -dbconnection &jdbc_db_addr -userId "1" -rootPackage /oracle/apps/bis -rootdir &fullpath_bis_mds_directory
         # file-version-parsed bis mds RPerPersonsLayoutsource.xml 120.6
         exec java oracle/jrad/tools/xml/importer XMLImporter.class java &phase=dat+24 checkfile:bis:mds:RPerPersonsLayoutsource.xml &fullpath_bis_mds_RPerPersonsLayoutsource.xml -username &un_apps -password &pw_apps -dbconnection &jdbc_db_addr -userId "1" -rootPackage /oracle/apps/bis -rootdir &fullpath_bis_mds_directory
    end actions
    end bug bis xxbis_bis_test
    end aru xxbis_test
    Edited by: [email protected] on 17.02.2009 4:15

    Not real sure what your asking but if you want to view two apps side by side, make sure they're not in full screen mode and drag the edge of a window to resize.  If you want to browser windows, On the menubar Safari > File > New Window.  Or the shortcut, CMD N
    Then resize to view both.
    Regards,
    Captfred

  • How can I apply text position attributes (e.g. lower third) to more than one title at a time?

    How can I apply text position attributes (e.g. lower third) to more than one title at a time?

    jhb3243
    What version of Premiere Elements are you using and on what computer operating system is it running?
    In the case of this theoretical lower third to be applied to more than one title at a time
    a. Is there text in the lower third besides a graphic of some kind?
    b. Are all the titles to which this lower third is to be applied all together on the Timeline or scattered?
    If no text in lower third and titles all together, then, with text titles on Video 1 and lower third on Video 2, drag out the lower third to cover the length of the text titles on Video 1.
    I do not find "lower third" title files to be in the same category as certain effects where the Copy and "Paste Attributes" or "Paste Effects and Adjustments" lend themselves so well.
    Let us see what others have to say about all this. I will continue to experiment with what you seek and how you would prefer to get there. I am not optimistic but I will try.
    Thanks.
    ATR

  • How can i apply gradient...

    I have a rectangular shape movie Clip (Size :130px X40 px). I
    want to apply linear gradient on it using action script. Can
    anybody help me how can I apply gradient on it.
    Note: This movie clip is made manually. Not by using
    createEmptyMovieClip method.

    i already checked this -
    MAKE A OVAL ON YOUR STAGE AND GIVE THIS INSTANCE NAME 'ovl'
    (withought single quote) and use the code under
    here i am creating two movie clips on stage --
    1st is 'ovl' and 2nd one is 'mc'
    But to apply gradient on ovl i have to use setMask method
    like this _root.mc.setMask(_root.ovl)
    i do not want to use SetMask... I want to apply gradient
    directly on 'ovl'
    How can i do ??????????????
    // create emtpy movieclip
    mc = createEmptyMovieClip("mc",1);
    // set the constants for the gradient fill
    // the colors
    col = [0x000066,0x0033FF];
    // the alphas
    alp = [100,30];
    // the ratios
    rat = [100,255];
    //this.onMouseMove = function () {
    // we will make a radial gradient
    // and make it move with the mouse
    // first we clear the previous gradient fill
    mc.clear();
    // get the mouse-position
    // the x-coordinate
    x = _xmouse-200;
    // the y-coordinate
    y = _ymouse-200;
    // set the matrix for the transformation
    matrix = { matrixType:"box",x:x,y:y,w:400,h:400,r:0 }
    // now make the new gradient fill
    mc.beginGradientFill("linear",col,alp,rat,matrix);
    // now make the shape to fill
    mc.lineTo(400,0);
    mc.lineTo(400,400);
    mc.lineTo(0,400);
    // end the fill
    mc.endFill();
    _root.mc.setMask(_root.ovl)
    Text
    Text

  • How can i apply different color for each cell in jlist component?

    hi guys i need your help and sorry if my english is very bad..guys how can i apply different colors for each cell in jlist component? for example for the first cell i want to apply color blue, for the second cell i want red, etc... i need your answer guys tnx..
    Edited by: ryrene on Mar 21, 2010 12:13 AM

    ryrene wrote:
    hi guys i need your help and sorry if my english is very bad.
    ..guys how can i apply different colors for each cell in jlist component? for example for the first cell i want to apply color blue, for the second cell i want red, etc... i need your answer guys tnx..I'll see your tnx, and raise you dve bmbrs & nplm.

  • How can i  apply this  java program for  a jsp page?

    import java.io.*;
    import java.util.*;
    public class FileProcessing
      //create a vector container  for the input variables
         Vector variables = new Vector();
      //create a vector container for the constants
         Vector constants = new Vector();
      /*create a string expression container for the equation
         as read from the file */
         String expression = " ";
      //create double result container for the final result
         double result = 0;
         public boolean processFile(String filename,String delim)
          //index for values vector
              int num_values = 0;
          //index for constants vector
              int num_constants = 0;
          //current line being read from the external file.
              String curline = " ";
          //start reading from the external file
              try
                   FileReader fr = new FileReader(filename);
                   BufferedReader br = new BufferedReader(fr);
                   while(true)
                        curline = br.readLine();
                        if(curline == null)
                             break;
                    //determine the type of current interaction
                        boolean variable = curline.startsWith("input");
                        boolean constant = curline.startsWith("constant");
                        boolean equation = curline.startsWith("equation");
                        boolean output = curline.startsWith("result");
                   //on input variables
                        if(variable)
                          StringTokenizer st = new StringTokenizer(curline,delim);
                          int num = st.countTokens();
                          int count=0;
                          while(st.hasMoreTokens())
                               String temp = st.nextToken();
                               if(count==1)
                                    byte b[]= new byte[100];
                                    System.out.println(temp);
                                    System.in.read(b);
                                    String inputval = (new String(b)).trim();
                                    variables.add(num_values,inputval);
                                    num_values++;
                               count++;
                        // on constant values
                        if(constant)
                             StringTokenizer st = new StringTokenizer(curline,delim);
                             int num = st.countTokens();
                             int count = 0;
                             while(st.hasMoreTokens())
                                  String temp = st.nextToken();
                                  if(count==1)
                                       byte b[]= new byte[100];
                                       System.out.println(temp);
                                       System.in.read(b);
                                       String cons = (new String(b)).trim();
                                       constants.add(num_constants,cons);
                                       num_constants++;
                                  count++;
                        // on equation
                        if(equation)
                             StringTokenizer st = new StringTokenizer(curline,delim);
                             int num = st.countTokens();
                             int count = 0;
                             while(st.hasMoreTokens())
                                  String temp = st.nextToken();
                                  if(count==2)
                                       this.expression = temp;
                                  count++;
              // now we are ready to evaluate the expression
                       if(output)
                          org.nfunk.jep.JEP  myparser= new org.nfunk.jep.JEP();
                          myparser.setAllowAssignment(true);
                          for(int i=1;i<variables.size()+1;i++)
                             String name = "arg"+Integer.toString(i);
                             myparser.addVariable(name,new Double(variables.get(i-1)
                                                .toString()).doubleValue());
                          for(int i=1;i<constants.size()+1;i++)
                               String name = "arg" +Integer.
                                         toString(i+variables.size());
                               myparser.addConstant(name,new Double(constants.get(i-1).toString()));
                   //output is obtained as follows
                          myparser.parseExpression(expression);
                          result = myparser.getValue();
                          System.out.println("Assay value: "+result);
              catch(Exception e)
                   System.out.println(e.toString());
              return true;
         public static void main(String[] args)
              FileProcessing fp = new FileProcessing();
              fp.processFile("input.eqn",":");
    }//my text file name is: "input.eqn" (given below)
    input:Enter Value1:arg1
    input:Enter Value2:arg2
    input:Enter Value3:arg3
    constant:arg4
    constant:arg5
    Equation:arg1+arg2+arg3
    result:

    how can i apply this java program for a jsp pagewhy do you want to do this ?
    Your program reads from a file on the disk and formats based on a patterm.
    Jsp is not intended for such stuff.
    ram.

  • How i can give date in each input for applying the exchange rate in Query.

    Hi Gurus,
    We have a requirement to create some currency conversion queries. In the selection screen user should be able to give four inputs. Like given below
    Input 1.          a)  key figures
                            b) Fiscal Year
                            c) Fiscal Period
                            d) Exchange Rate Type
                            e) Date (Exchange rate will be applied which is applicable on the given date)
      Input 2.         a)  key figures
                            b) Fiscal Year
                            c) Fiscal Period
                            d) Exchange Rate Type
                            e) Date (Exchange rate will be applied which is applicable on the given date)
    Input 3.          a)  key figures
                            b) Fiscal Year
                            c) Fiscal Period
                            d) Exchange Rate Type
                            e) Date (Exchange rate will be applied which is applicable on the given date)
    Input 4.          a)  key figures
                            b) Fiscal Year
                            c) Fiscal Period
                            d) Exchange Rate Type
                            e) Date (Exchange rate will be applied which is applicable on the given date)
    So we will have 4 key figures in the query results with the exchange rate applied on the given date.
    I will make four restricted key figures and make the query. I do not know how i can give date in each input for applying the exchange rate.
    Please give your suggestions to resolve my problem.
    Many thaks in advance.

    You can not bring the key figures in the selection screen for the currency translation. Instead you can apply a currency translation type to respective key figures in the query definition.
    The currency translation type can be defined in RSCUR transaction, where you can maintain the parameters like Exchange Rate Type, Exchange Rate Date etc.
    You can refer one of my article on this at
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/600157ec-44e5-2b10-abb0-dc9d06ba6c2f
    Hope this helps.
    Regards,
    Yogesh

  • How to use a  MVC architecture

    i dont know how to use a MVC architecture,what are the files has to be needed to create a MVC architecture,right now iam using jsp file and a java file .in jsp file i just use the usebean tag

    http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html

  • How can I apply the same crop to multiple photos?

    It is easy to apply the same Adjust settings to multiple photos by using the Copy and Paste in the Adjust pane. Or by using iPhoto Batch Enhancer.
    But can you apply the same crop to multiple photos? I don't see any way to copy a crop. iPhoto Batch Enhancer can do something like it but, being an external editor, it does so on a copy of the photo. I want it on the original photo. (Well, it's not really the original since that one is saved separately in the Library but on the current version).
    Thanks for any suggestion.
    Bo

    Here's how:
    1 - bring up the first photo in the edit window and click on the Crop button or *use the "C" key on the keyboard*.
    2 - set the crop size/ratio in the menu and position the crop window over the photo as needed.
    3 - click the Apply button or *use the Enter key*.
    4 - click on the right arrow in iPhoto or *use the right arrow key on the keyboard* to bring up the next photo.
    5 - click the "C" key to bring up the crop function.
    6 - repeat steps 2 thru 5 for each photo.
    This video screenshot shows how:
    Click to view video screenshot
    Happy Holidays

  • Sap XI application can  be developed based on the MVC architecture in java?

    MVC architecture
    Jsp-->servlet--
    >database.   
    <--<<--
    (front-end)     (business logic)         (data)
    Can anyone explain one process flow  in sap xi with java.
    I would be most thankful to you if you answer me.
    Thanks in advance
    Jeevan

    Hi jeevan
    SAP XI pretty much mimics MVC
    For eg, you create the design objects in IR (View)
    the controller is the J2ee engine of the (WAS server) (controller)
    The model is the database underneath
    regards
    krishna

Maybe you are looking for

  • To print multiple page in script

    hii frnds my requirement is i have to display 1 line item of my table in 1 page and then the second line item in the  second  pages and as on IN A clasical report . can any body tel me how to do it . actualy the first line item will be displayed by d

  • Account post

    Hi gurus, I have created the below program to create accounting document using F-43 and for this I have used BAPI_ACCOUNT_POST, data: begin of it_input_file occurs 0,         pos_date(10),         doc_type(2),         pos_per(2),         bukrs(4),   

  • Copying/Moving Pictures question.

    I was wondering if there is away to move/copy pictures from the picture folder to the application menu into a folder in their? if possible can anyone help please Solved! Go to Solution.

  • Video Converter Recommend

    Hi guys, just to ask something.. I've tried every converter that i could try and i cant get a good quality video that i wanted, I tried this following softwares and the output i've got. Xilisoft-video and sound are perfect but sounds comes first. (me

  • How to implement line numbers in order acknowledge report

    Hi all,         I am newbie to Oracle Reports. I have an order acknowledgement report in which i show columns like line number Ordered item ship from quantity unit price extended price In above table format i need to show line numbers as 1.1