Help me w/ the method setPreferredSize

guyz, im having problems w/ this....when i compiled it it gave me an error..it says the method cannot be resolved...pls help me.... heres the prog...thanks in advance
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.*;
* Il vostro primo componente Swing!
public class SimpleFrame extends JFrame {
* Costruisce un nuovo JFrame contenente una JLabel
SimpleFrame() {
super();
setTitle("Il mio primo componente Swing!");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
add(new JLabel("Benvenuti in Swing!", JLabel.CENTER));
// setPreferredSize(new Dimension(150, 100));
pack();
setVisible(true);
* Crea un'istanza di questa classe
public static void main(String[] args) {
SimpleFrame sf = new SimpleFrame();
}

setPreferredSize is not a method of JFrame. Use SetSize instead.

Similar Messages

  • Want help in deciding the method of development for this scenario

    Hi,
    My requirement is to create one screen where customer enters shipment #, and ship-to information and say continue, he will be shown another screen with shipment details, and combo box to select appointment time. when he clicks on Make Appointment button of this screen, he needs to be shown confirmation screen with the appointment information being stored in sap tables. I want to know the best method of creating this peice of application. If you have any question, please feel free to ask them.
    Thank you,
    Surya

    Hi Surya,
    Just develop a small ALV for this application. It will best suite to your scenario.If you know to develop ALV using OO then its very simple, or you can just search throgh the SDN you will find lots of sample code to do the same.
    Regards,
    Atish

  • Can anyone help me to add method to rotate the image using mouse?

    Hi everyone, i am currently creating a game which require the user to be able to drag and rotate the image
    on the screen..but sadly...i'm only able to do the dragging part..
    Can anyone be able to help me add the method to rotate the image using the mouse?
    Thanks :-)
    the code
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.awt.geom.*;
    class Game extends JFrame {
         DisplayCanvas canvas;
         public Game() {
              super("My Game");
              Container container = getContentPane();
              canvas = new DisplayCanvas();
              TitledBorder border = new TitledBorder("Game Window");
              border.setTitlePosition(TitledBorder.BOTTOM);
              canvas.setBorder(border);
              container.add(canvas);
              addWindowListener(new WindowEventHandler());
              setSize(450,400);
              show();
              class WindowEventHandler extends WindowAdapter {
                   public void windowClosing(WindowEvent e) {
                        System.exit(0);
              public static void main(String arg[]) {
                   new Example();
         class DisplayCanvas extends JPanel {
              int x, y;
              BufferedImage bi;
              DisplayCanvas() {
                   setBackground(Color.white);
                   setSize(450,400);
                   addMouseMotionListener(new MouseMotionHandler());
                   Image image = getToolkit().getImage("duke.gif");
                   MediaTracker mt = new MediaTracker(this);
                   mt.addImage(image, 1);
                   try {
                        mt.waitForAll();
                   catch (Exception e) {
                        System.out.println("Exception while loading image.");
                   if (image.getWidth(this) == -1) {
                        System.out.println("***Make sure you have the image "
                        + "(duke.gif) file in the same directory.*****");
                        System.exit(0);
                   bi = new BufferedImage(image.getWidth(this),
                   image.getHeight(this),
                   BufferedImage.TYPE_INT_ARGB);
                   Graphics2D big =bi.createGraphics();
                   big.drawImage(image, 0, 0, this);
              public void paintComponent(Graphics g) {
                   super.paintComponent(g);
                   Graphics2D g2D = (Graphics2D) g;
                   g2D.drawImage(bi, x, y, this);
              class MouseMotionHandler extends MouseMotionAdapter {
                   public void mouseDragged(MouseEvent e) {
                        x = e.getX(); y = e.getY();
                        repaint();

    research a bit on AffineTransforms. you can set the rotated instance of the Graphics2D class and it will do the rotations for you :-D

  • Help with updating the grid(CONNECT 4)

    Hi, this a small portion of my connect 4 game program. I have a problem with updating the grid. During the game, whenever I enter a column number for the first time, the program works properly. But when i try to give the same column for the second time, the chip falls in the same row instead of going to the second row. Can anybody help me write the method that will do this.
    This is the method that switches the chip's value(By the way discard the variable 'turn' because that works properly, it is used in another method):
        //Method 2: Updates the matrix
        public static void UpdateMatrix (char location, char turn)
            c.println (location);
            switch (location)
                case '1':
                    matrix [5] [0] = turn;
                    break;
                case '2':
                    matrix [5] [1] = turn;
                    break;
                case '3':
                    matrix [5] [2] = turn;
                    break;
                case '4':
                    matrix [5] [3] = turn;
                    break;
                case '5':
                    matrix [5] [4] = turn;
                    break;
                case '6':
                    matrix [5] [5] = turn;
                    break;
                case '7':
                    matrix [5] [6] = turn;
                    break;
        } //End Method 2Can anybody describe me how to write a method or write a method that will tell the computer to assign the chip to the next row. You an edit my method if u want to. THANX A LOT!!!

    HERE IS THE METHODS SO FAR!
        //Method 3: Checks if assigned place for the chip has a chip there already
        public static void emptyspot (int column, int row)
            for (row = 5 ; row >= 0 ; row--)
                for (column = 0 ; column <= 6 ; column++)
                    if (matrix [row] [column] == 'X' || matrix [row] [column] == 'O')
                        row--;
        }I AM GETTING AN ERROR!!! AT THE BOTTOM OF MY PROGRAM! SOMEBODY HELP!
    Message was edited by:
    Taufiq

  • Urgent help req : work item id not getting passed in the method

    Hi ,
    I have created a subtype zcats of business object CATS and delegated it .
    I have created a new method Approve1 ( with attributes  SYNCRONUS & DIALOG )  in zcats which is similar in coding  to Approve method of CATS ( DIALOG) .
    I have include the method Approve1 of business object zcats in a standard task .
    The problem is that when the eorkflow gets triggered ,  the workitem id is not getting passed in the method APProve1 of zcats.
    Can someone please help me with this .
    Points would surely be awarded .

    BEGIN_METHOD APPROVE1 CHANGING CONTAINER.                 
      DATA: WORKITEMID_IMP LIKE OBJECT-KEY-ITEMID.              
      DATA: WI_CHCKWI LIKE SWWWIHEAD-WI_ID.                     
      DATA: WORKITEM TYPE SWC_OBJECT.                           
       <u> WORKITEMID_IMP = OBJECT-KEY-ITEMID</u>.                     
        SWC_GET_ELEMENT CONTAINER '_WORKITEM' WORKITEM.         
        SWC_GET_PROPERTY WORKITEM 'WorkitemReference' WI_CHCKWI.
        IF SY-SUBRC EQ 0 AND NOT WI_CHCKWI IS INITIAL.          
          WORKITEMID_IMP = WI_CHCKWI.                           
        ENDIF.                                                  
        CALL FUNCTION 'CATS_WF_APPROVAL'                        
          EXPORTING                                             
            WORKITEMID_IMP = WORKITEMID_IMP                     
          TABLES                                                
            CONT_IMP = CONTAINER.                               
      END_METHOD.                                               
    hi ,
    the above is the code in the method .
    At the first step of execution underlined above , the work item id is appearing blank .
    I think that the value is not passed to the container , but i am not sure og how to pass data to this conatiner

  • Help to edit the output of a method please

    Hi
    I have a piece of code which i need to change. Currently the method connects to a socket c, and reads in a string from a method called get(String), which returns a string, i however need to change this so that the method get(String) returns a list. I am not sure however how to go about changing this code so as to do this
    public void run() {
            try {
                BufferedReader i = new BufferedReader(new InputStreamReader(c.getInputStream()));
                DataOutputStream o = new DataOutputStream(c.getOutputStream());
                try {
                    while (true) {
                        String s = i.readLine();
                        if (s.startsWith("GET")) {
                            StringTokenizer t = new StringTokenizer(s, " ");
                            t.nextToken(); // discard GET
                            String p = t.nextToken();
                            String response = get(p);
                            o.writeBytes("HTTP/1.0 200 OK\nContent-Type: text/plain\nContent-Length: "
                             + (response.length() + 1)
                             + "\n\n"
                             + response + "\n");
                            break;
                } catch (Exception x) {
                    System.err.println("Error: " + x);
                    x.printStackTrace();
                    o.writeBytes(SAYWHAT + "Error: " + x);
                o.close();
            } catch (Exception x) {
                System.err.println("Error: " + x);
                x.printStackTrace();
        }Currently this method seperates the words in the string output by the get(String) method as far as i can see and writes this output to a HTTP address. I dont know how i could go about changing this so that instead of outputting a string, get(string) will output a list, which in turn will be output by this run() method to a HTTP address. I would welcome any help with this problem, as i dont know where to start.
    Thanks

    Thanks for the references, ive been looking through these for a while now but i cannot figure out how to do what i have to do. I have not been able to find a way to read in from an array, i found a ByteArrayInputStream but am not sure how this works. Does anybody know of a way to read in from an array using a BufferedReader or some similar construct?

  • I taked this through with a mac support agent, but forgot the method, As my Opticle drive fefuses to burn a full ML dvd   Re setting be re starting and pressing some keys, Can you help?

    I taked this through with a mac support agent, but forgot the method, As my Opticle drive fefuses to burn a full ML dvd
    Re setting be re starting and pressing some keys, Can you help?

    I taked this through with a mac support agent, but forgot the method, As my Opticle drive fefuses to burn a full ML dvd
    Re setting be re starting and pressing some keys, Can you help?

  • TS3367 Hi, the FaceTime just did not work between my mom and I. It used to work weeks ago, but now it does not work after showing"connecting". I feel frustrated and try all the method I can think of. Still do not work. Hope u can help me. Thanks!

    Hi, the FaceTime just did not work between my mom and I. It used to work weeks ago, but now it does not work after showing"connecting". I feel frustrated and try all the method I can think of. Still do not work. Hope u can help me. Thanks!

    Was it just this one time?  Could be that you, or your mom, were experiencing network problems.  Try again at a later time.

  • I purchased gems from a game and didnt get them because my method was declined i want to remove the order so i dont pay for it and so i can update my other apps and i want to remove the method i will be thankfull if someone help me

    i purchased gems from a game and didnt get them because my method was declined i want to remove the order so i dont pay for it and so i can update my other apps and i want to remove the method i will be thankfull if someone help me without updating the payment method i cant update my apps in my iphone i want to remove the method and remove the order i dont want it

    Click here and ask the iTunes Store staff for assistance.
    (125742)

  • Help with the method copyPixels

    Hello good day!
    I need a force in  a scheme that I am doing with a combobox that I created to select a  font of a text. I would like to display the text to the source, but do  not want to imply load all sources that I am offering 30, then a  solution that I thought it would be feasible to use an image with these  sources, then in that case all that needs to be done would be to carry this image that has about 30kb which would be a process not so  slow.
    For this did the following: I created the image in my library  as a movie clip and then used two BitmapData and a bitmap to display the  image as follows:
        var bmp: Bitmap;
        / / Lista_fonte  is my image of the sources
        var list: = new  lista_fonte lista_fonte ();
        / / Create a  BitmapData from the list instantiated
        var bmd:  BitmapData = new BitmapData (lista.width, lista.height, true);
        / / Create a BitmapData less for the item from combobox
        var bmdtemp:  BitmapData = new BitmapData (lista.width, 20, true);
    And then I go  with a paragraph of the sources and use the copyPixels to copy part of  the image:
        for (var i: int = 0; i <30; i) (
            bmdtemp.copyPixels (bmd, new Rectangle (0,0, lista.width, 20),  new Point (0, 20 * i));
            bmp = new  Bitmap (bmdtemp);
            addChild (bmp);
    Above would look like this,  but I have two problems:
    1 The picture is transparent with the  background and create the BitmapData I allow there is an overhead  transparency, but the picture shows a white background!
    2 are just  copying the image at position 0.0 in the case is with any combo of the  first source image only.
    I hope that was clear, please help me now  to break the head at a time on it and I read in some forums and some  discusões around and nothing.

    wannabehacker wrote:
    But my actual question remained unanswered. Would you please take a look at the method if you have some time and explain to me how the method is converting the IP to decimal.
    public class CharTest {
        public static void main(String[] args) {
            int b = '0';
            System.out.println(b);
    }This prints out 48. What do you think the significance of that is, and what do you think would happen if I did
    int c = '8' - '0';
    System.out.println(c);

  • Hello, I have a MacBook Air, when I was watching a movie it started to freeze, so I turned off. But when I turn it on just the white screen appears nothing else. I looked on other websites, but the methods didn't help.

    Hello, I have a MacBook Air, when I was watching a movie it started to freeze, so I turned off. But when I turn it on just the white screen appears nothing else. I looked on other websites, but the methods didn't help.

    Try a Safe Mode boot ...
    Startup your Mac in Safe Mode
    A Safe Mode boot takes much longer than a normal boot so be patient.
    Once you are in Safe Mode, click Restart from the Apple () menu.

  • How to delete help button in the wizard and dialogs.

    Hello,
    I am trying to delete the Help button in the wizard and dialogs provided by bibeans and having problems. Can someone give me an advise regarding the following three issues please? Thank you.
    bibeans:bibeans903a
    JDeveloper:JDeveloper903
    1)Deleting the Help Button from the Print Dialog.
    I'm using "oracle.dss.dataView.gui.PrintDialog" for the Print Dialog and this class has method to delete the Help button(setHelpEnabled(Boolean)).
    But, the Help button is always displayed even when I set false for this method like below.
    PrintDialog.setHelpEnabled(false);
    2) Deleting the Help button from Open Dialog and BI Explorer.
    I am using "PersistenceObjectChooser" class for Open Dialog and "Explorer" class for BI Explorer. But, these classes does not have a method to delete the Help button like the PringDialog class has. How can I delete the Help button for these dialogs?
    3) Deleting the Help button from Calculation Builder.
    I am using "CalcBuilderStepStorage" class to build a calculation and trying to delete the Help button like this.
    ((DefultBuilderDialog)calcBuilderStepStorage.getContainer()).getWizard().setHelpAvailable(false);
    But, again the Help button will be displayed

    hi,
    Use this code..
    REPORT  Z_TEST999                               .
    DATA itab TYPE TABLE OF sy-ucomm.
    PARAMETERS test(10) TYPE c.
    AT SELECTION-SCREEN OUTPUT.
      APPEND: 'E' TO itab.
      CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
           EXPORTING
                p_status  = sy-pfkey
           TABLES
                p_exclude = itab.
    Regards,
    Sailaja.

  • How use the method hasPermission in weblogic server 6.1

    Hello everybody !
    In my application web ,i restrict access to some ressources (some jsp)
    to some specified groups .
    So,i create permissions in the file web.xml , as indicated in the doc
    6.0 .
    For example only the user : system can access to all the jsp , and the
    others users no .
    Now ,in my code ,I would like to use the method hasPermission in order
    to modify my application according to the differents groups of users .
    But my problem is that i don't know the parameter aclName !
    For the parameter permission I use the syntax "new
    weblogic.security.acl.PermissionImpl(".../x.jsp") .
    For the parameter sep (char),i use : '.' .
    But i don't find the parameter aclName .
    When i was in weblogic 5.1 ,i created permission in the file
    weblogicURL.policy with the syntax : " Permission
    weblogic.security.acl.URLAcl "weblogic.url",".../x.jsp" " and after
    i gave "weblogic.url" as parameter for aclName .
    But in version 6.0, I try web.xml, web ? but nothing is good .
    Is there any person which have an idea or the solution ?
    All the sugestions are welcome !
    Thanks by advance !
    Good bye .

    hi,
    maybe a better approach could be to use roles instead of permissons.
    Your menu.jsp could look like this:
    <%
    if(request.isUserInRole("super-user"))
    %>
    ... code HTML where the button "Creation" is created
    <%
    %>
    You can map the role 'super-user' to an individual principal or a
    user group in weblogic.xml. In that case only users that are in
    the mapped group/principal will see the 'creation' link. So simply
    add user 'system' to a group 'super-user'.
    regards,
    przemek
    Marc Alfonsi schrieb:
    Hi Kirann and everybody!
    Thanks for your message .
    I'm going to explain better than the first time .
    I set up security-constraints in my web.xml .
    For example only "system" can access to the directory Creation and
    all its .jsp , and the others users no .
    Now ,in my code , there is a jsp : menu.jsp which displays some
    possibilities : creation of an employee , visualisation ...with HTML
    code : button "Creation" which call a .jsp of the directory Creation .
    Actually , if a user different of "system" try to click on the button
    "Creation" there is a dialog box of login . The user writes its loggin
    but the access is prohibited ( because security-constraint in web.xml
    ).It's normal but not very well .I would like that a user who don't
    have access to the functionality "Creation" don't see the button
    "Creation" !
    So in menu.jsp , i would like to use the method hasPermission at the
    location of the button "Creation" is created with HTML code :
    <%
    if weblogic.security.acl.Security.hasPermission(.....,new
    weblogic.security.acl.PermissionImpl("/Creation/x.jsp"),'.')
    %>
    code HTML where the button "Creation" is created
    <%
    %>
    But my problem is that i don't know the first parameter which
    correspond
    to aclName .
    Any suggestions are welcome .
    Thanks for help .

  • How to call a java method so I can pass a file into the method

    I want to pass a file into a java method method from the main method. Can anyone give me some help as to how I pass the file into the method - do I pass the file name ? are there any special points I need to put in the methods signature etc ?
    FileReader file = new FileReader("Scores");
    BufferedReader infile = new BufferedReader(file);
    Where am I supposed to put the above text - in the main method or the one I want to pass the file into to?
    Thanks

    It's a matter of personal preference really. I would encapsulate all of the file-parsing logic in a separate class that implements an interface so that if in the future you want to start taking the integers from another source, e.g. a db, you wouldn't need to drastically alter your main application code. Probably something like this, (with an assumption that the numbers are delimited by a comma and a realisation that my file-handling routine sucks):
    public class MyApp{
    public static void main(String[] args){
    IntegerGather g = new FileIntegerGatherer();
    Integer[] result = g.getIntegers(args[0]);
    public interface IntegerGatherer{
    public Integer[] getIntegers(String location);
    import java.io.*;
    public class FileIntegerGatherer implements IntegerGatherer{
    public Integer[] getIntegers(String location){
    FileInputStream fs=null;
    try{
    File f = new File(location);
    fs = new FileInputStream(f);
    byte[] in = new byte[1024];
    StringBuffer sb = new StringBuffer();
    while((fs.read(in))!=-1){
    sb.append(new String(in));
    StringTokenizer st = new StringTokenizer(sb.toString(),",");
    Integer[] result = new Integer[st.countTokens()];
    int count = 0;
    while(st.hasMoreTokens()){
    result[count]=Integer.valueOf(st.nextToken());
    count++;
    catch(IOException e){
    //something sensible here
    finally{
    if(fs!=null){
    try{
    fs.close();
    catch(IOException f){
    return result;
    Once compiled you could invoke it as java MyApp c:\myInts.txt
    Sorry if there are typos in there, I don't have an ide open ;->

  • Error in crawl log "Error while crawling LOB contents. ( Error caused by exception: Microsoft.BusinessData.Infrastructure.BdcException The shim execution failed unexpectedly - The method or operation is not implemented..; SearchID "

    Hi 
    I get the following error in my crawl logs
    "Error while crawling LOB contents. ( Error caused by exception: Microsoft.BusinessData.Infrastructure.BdcException The shim execution failed unexpectedly - The method or operation is not implemented..; SearchID "
    Because of this i suspect, the search results are not including those aspx pages marked as "Hide physical urls from search".
    This error is not available in the another environment where the aspx pages are coming in the results.
    Thanks
    Joe

    Hi Joe,
    Greetings!
    Reset the index and re-crawl. That usually clears it
    If you are using NTLM authentication, then make sure that you specified the PassThrough authentication for crawling
    Probably you need to debug the BDC code that underlies the external content types.
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/41a86c43-151d-47cd-af73-967a4c940611/lotus-notes-connector-error-while-crawling-lob-contents?forum=sharepointsearch
    Please remember to click 'Mark as Answer' on the answer if it helps you

Maybe you are looking for