AWT method not recognised

Hi, I am trying to compile a simple program on centering a window using the get local graphics environment method but I received the error "getCenterPoint()" symbol not recognised. Can someone help please. The code is below
import javax.swing.JFrame;
import java.awt.Point;
import java.awt.GraphicsEnvironment;
public class TryWindow3
     // The window object
     static JFrame aWindow = new JFrame("This is the Window Title");
     public static void main(String[] args)
          Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
          int windowWidth = 400;
          int windowHeight = 150;
          // Set position and size
          aWindow.setBounds(center.x-windowWidth/2, center.y-windowHeight/2,
                            windowWidth, windowHeight);
          aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          aWindow.setVisible(true);           // Display the window
}Thanks.

'getCenterPoint()' method is added since j2se1.4. Check the JRE version in your machine.

Similar Messages

  • Method not recognised as method.

    I have been having extreme frustration trying to get this client program to compile. Everything is ok up to the point where the compiler tries to compile the LogCheck method. It seems to think it is an expression and thus cannot compile it. Can anyone tell me why this is and help me solve this. Thanks in advance.
    import org.omg.CORBA.*;
    import UserManagerTest.*;
    import javax.swing.*;
    import java.awt.*;
    public class Client
         public static void main(String[] args)
              try{
                             ORB orb = ORB.init(args, null);
                             ObjectInputStream in = new ObjectInputStream(new FileInputStream("IOR"));
                             String ior = (String)in.readObject();
                             in.close();
                             org.omg.CORBA.Object obj = orb.string_to_object(ior);
                             UserManager reference = UserManagerHelper.narrow(obj);
                             JFrame logonObj = new Logon("User Logon Process");
                             logonObj.setVisible(true);
                   }catch(Exception e){
                             e.printStackTrace();
         public boolean LogCheck(String n,String p)
                                                 String name = n;
                                                 String password = p;
                                                 boolean check = reference.login(name, password);
                                                 return check;
    }

    Thats why one should format the code so it looks nicely, then one is able to find those mistakes quickly. Like this:
    class XY
    public void Something()
    if()
    code;
    code;
    code;
    }//END Something()
    }//END classXY

  • Ipod not recognised by Windows, USB device not recognised

    Hi hope someone can help
    I have recently received my ipod back from Applecare who have sent the ipod back in ' working order ' but it will no longer be recognised by my windows. It says USB device not recognised and i cant find, nor will it install drivers that i located on the ipod updater etc.
    I have tried several methods on this forum but none seem to work.
    The letter from mycare says the iPod is formatted for a computer operating Mac OS X. Although i stated wi use Windows. But the leter states this can be changed bu installing the updater, but this wont make a diff as comp still wont regonise the device after i have followed there instructions. Any advice?
    Thanks

    I'm not really up on the complexities of the Windows OS but try this tip I picked up a while back, hopefully it might help.
    "USB Device not Recognized in Windows".
    1. On the Start menu, click Control Panel.
    2. Double-click the System icon.
    3. Click the Hardware tab.
    4. Click Device Manager.
    5. Scroll down the list of devices to the Universal Serial Bus controllers
    6. Click the plus icon next to the Universal Serial Bus controllers.
    7. Double-click one of the indented USB Root Hub entries.
    8. Click the Power Management tab.
    9. Deselect the "Allow the computer to turn off this device to save power" option.
    10. Click the OK button at the bottom of the window.
    11. Restart the computer.

  • Macbook pro(2008 later) can not recognise external monitor(NEC UXI2090) with mini-DP to DVI adapter with 9600GT

    I bought mini-DP to DVI frome Apple several monthes ago and it worked well in that time until yesterday the external monitor show me no signal sign. Other PCs were connected with the same cable and monitor and they are fine. I am wondering there is something wrong in the adaptor or macbook pro. Furthermore I found the external monitor can display nornally when I switched to 9400 graphic card and used mini-DP to VGA adapter. If I switch to 9600GT no signal again. If I switch 9400 using mini-DVI, it is shown on the external screening: Out of range... In a word, In the mode of 9600GT, mac can not recognise external monitor(I can not detect it in the systerm preference even I press detect display buttun) and 9400 works in VGA mode. However when I connect adapter to mac, the screen showed blue flash.
    I reseted SMC, no use; I created a new account or enter mac to safe mode, no use; so far I did not reseted PRAM beacuse of something wrong of my system. I am downlaoding Mountain Lion OS and will install it. Then I will reset PRAM and try again.
    I do not know whether I shoud change the adapter or the single-link DVI cable to dual-link. Someone said it is useful in their condition. I tried some methods from BBS, such as connected when devices were off and then open, and so on. I failed.
    Any suggestion for this problem?
    Addition: OS: 10.7.4(Lion)

    I turns out that the logic board of my MacBook Pro was faulty (despite being brand new).
    I took it to the Apple Store, presented the problem, and one of the Tech's came to the same conclusion that I had -- hardware failure.  Phone support was no help in the matter (and even told me that what I was trying to do wasn't a supported option, which is rediculous).  However, the Genius Bar did take care of the problem, and my MacBook Pro was back to me with a replaced logic board within a few days.
    Hope that htis helps.

  • Hey. I have received an iTunes gift card, so I was all excited, punching the code into the "redeem" option on iTunes on my iPad2; however, I kept on getting the alert, "This is not recognised as a valid code". It is very legible, though. How come?

    Hey. I have received an iTunes gift card, so I was all excited, punching the code into the "redeem" option on iTunes on my iPad2; however, I kept on getting the alert, "This is not recognised as a valid code". It is very legible, though. How come?

    The obvious answer I think is that maybe you are not entering the letters and numbers correctly. I almost never get it right the first time when I use a gift card.
    Try entering the code again - slowly and methodically. If it still doesn't work - look here for help.
    http://support.apple.com/kb/TS1292
    One final thought - if you are using a gift card that was purchased in another country - say like you have a Canada gift card and you live in the U.S. - that card will not work in the U.S. iTunes store.

  • 10.4  Update files not recognised

    Using 10.4 on a second hand Powermac g4 from ebay, so no installation discs.
    Successfully downloaded standalone updates 10.4.1....10.4.9 etc but first one (MacOSXUpdate10.4.1.dmg) not recognised so won't install. others recognised but won't work until first one installed.
    Same with standalone combo update (MacOSXUpdCombo10.4.10) it isn't recognised. Using AOL dial up so it's taken seven attempts (overnight) to get a continuous connection for the complete Combo download. (Same with Software Updates Combo from Apple menu on desktop)
    How do I get the right file which will be recognised ? or should I buy a full retail version of Tiger from ebay ? I'm concerned about all the probs people are having with updates as I am miles away from Apple Store for repairs and am a newbie. Many thanks for any replies.

    Welcome To  Discussions frenchbingo!
    Which version of OS X is currently installed on the Power Mac G4?
    If it is not Tiger 10.4.x, then as sig posted, you will have to purchase a set of install discs.
    Exactly which model PowerMac G4 is it?
    What size is the Hard Drive, and how much space is available?
    If it is this model Power Mac G4 (AGP Graphics), it had OS 8.6 or OS 9.0 installed, when manufactured in 1999.
    Mac OS X Versions 10.1, 10.2, 10.3, 10.4, and 10.5, are complete system upgrades that must be purchased.
    Once an OS has been installed, the point upgrades, such as 10.1.x to 10.1.5 (Final) 10.2.x to 10.2.8 (Final), 10.3.x to 10.3.9 (Final), and 10.4.x to 10.4.10 (Pending), can be downloaded for free.
    Leopard 10.5.x, can be purchased at The Apple Store (U.S.).
    Leopard System Requirements
    Jaguar 10.2.x, Panther 10.3.x, and Tiger 10.4.x, are no longer available directly from the Apple Online Store, as Leopard 10.5.x, will be the most up to date OS.
    But, if you know what to look for, Jaguar Full Retail CDs, a Full Retail Version, of the Panther Install CDs, or a Full Retail Version, of the Tiger Install DVD, can be purchased, sometimes less expensively, at some online Apple retailers, Amazon, eBay, FastMac, HardCore Mac, etc.
    Be sure not to purchase grey, upgrade or machine specific CDs or DVDs.
    Jaguar and Panther are only on CDs, not DVDs.
    The discs should look exactly like the images in the above links, and not say Upgrade, CPU Drop-in DVD, or "This software is part of a hardware bundle purchase - not to be sold seperately." on them.
    Additional info in these links.
    Using OS X Install CDs/DVDs On Multiple Macs
    What's A Computer Specific Mac OS X Release
    Software Update, Upgrade: What's The Difference?
    Caveat Emptor!
    If any are currently available, examine these items very carefully, and if in doubt, ask questions of the seller before purchase!
    Jaguar On eBay
    Panther On eBay
    Tiger On eBay
    Before upgrading to any OS X version, check to see if your Mac needs a Firmware Update.
    If one is required, you must start the computer from a Mac OS 8 or Mac OS 9 System Folder on the computer's hard disk, not from a CD, in order to install it.
    This Power Mac G4 Firmware Update 4.2.8 appears to be the one you would need to install.
    Once Jaguar 10.2.x is installed, you can use the 10.2.8 Combo Update,
    or if Panther 10.3.x is installed, you can use the 10.3.9 Combo Update, to upgrade to the final version of either OS.
    If your Mac meets the Tiger System Requirements, you could also consider installing that, and then use the PPC 10.4.10 Combo Update, to upgrade to the current version.
    Jaguar System Requirements
    -Power Mac G3 or G4, iMac, eMac, PowerBook G3 or G4, or iBook computer
    -128MB of physical RAM
    -Supports all video cards shipped by Apple on Mac OS X-compatible systems. Quartz Extreme functionality is supported by the following video cards: NVIDIA GeForce2 MX, GeForce3, GeForce4 MX, or GeForce4 Ti; Any AGP-based ATI RADEON card. A minimum of 16MB VRAM is required.
    -QuickTime Pro functionality requires a QuickTime 6 Pro key. The QuickTime 5 Pro key will not work after this software is installed.
    -DVD Player requires a DVD-ROM equipped Macintosh with built-in FireWire.
    Review these Apple documents for Panther System Requirements
    And Additional Panther System Requirements.
    Additionally, Tiger 10.4.x ships on a DVD, so if your Mac doesn’t have a built-in DVD-ROM player, you will have to use an alternative method of installation.
    Info here Installing Tiger Without A DVD Drive.
    And here Installing Tiger Using Firewire Target Disk Mode.
    The Tiger Media Exchange Program, referred to in that article, is no longer available.
    Shop Carefully, Examine All Documentation, And I Wish You Success!
    ali b

  • Clip+ not recognised by Windows 7 any more but charges it?

    Hi. Firstly I have never had a problem before but recently when connected to Windows 7 the Clip+ starts charging but Windows does not recognise it. It is shown in Devices. I have tried all the methods of resetting suggested (hold down power button 20 seconds - 2mins some time), holding Power and Menu button and receive message "do you want to remove old firmware press centre button for OK" and I have done that too, still nothing works. As Windows doesn't recognise it I can't remove, reinstall or install new firmware. Tried different USB ports and leads. When starting up with Micro SD Card inserted Clip+ just hangs so I can't use the Clip+ at all now. Help please, thanks. Chris

    Maybe you just got a lemon. At this point I'd suggest a replacement or a phonecall with tech support.  
    Some other thoughts: 
    Are your new mp3s properly tagged? Have you gone down the Music options to see if they are visible in Folders?  If there are no tags (or ID3v2.1 tags or, I think, ID3v2.4 tags) then Artist, Album, etc. won't be listed.
    You're right about the power-center-menu offering the option to clear the firmware. Had no idea. 
    I have to wonder if doing that has contributed to your problems, since the firmware is the operating system for the unit, but you've said you were still getting the menus, settings, etc., so there must have been backup firmware on there. 
    One other thing you might try is a non-Windows 7 computer, preferably XP, which doesn't have a lot of the security obstacles of Vista and WIn7. Put it in MSC, see if it connects, and if miraculously it does, drag over a new firmware, unzipped from this thread using the Manual instructions:
    http://forums.sandisk.com/t5/Sansa-Clip-Sansa-Clip/Sansa-Clip-Firmware-Update-01-02-18/td-p/280756

  • Method Not Found Invoke Node error 1316 using Solid Works IEdm

    Hi Forum members,
    I have been having a problem with calling a function in a dll file.  I have attached the VI as example.  When I use the GetFile method I get a reference to that.  I then use the Invoke node and recieve a list of methods, the first of which is ChangeState.  I select this method and wire all required inputs and when I run the program I receive the error at that invoke node that the method does not exist.  How is this possible?  I have tried various methods to ensure the inputs are all correct and none have worked.  I do not believe the fault lies in the inputs, but I cannot for the life of me find the problem...  Perhaps someone has experience using Solid Works in Labview?  Any help would be appreciated.!!
    Cheers
    Ben
    Attachments:
    SetFileSatus.vi ‏18 KB

    I have determined that there is a problem with the Invoke node not recognising the function.  This is a Labview problem as the function is listed and selectable, so when the error comes saying the function is not found, this is a problem with Labview and not the dll.  The Function when selected also has the right input parameters that automatically appear.  How is it then that the method is not found when the program is run?

  • IPod 4G not recognised in Windows 8

    My iPod 4G is not recognised in iTunes. I am running Windows 8 and I have tried ALL methods that's could find but it is still not working. My question to the community of Apple is to please help me connect my iPod to my iTunes. This problem also extends to my other devices which makes it a problem of my computer rather than my iDevice. I have also tried this on my friends laptop with successful results but would like to get it to work on my laptop.

    Done EVERTHING mentioned above. Here is some results of diagnostics that I ran on iTunes.
    http://www.dropviewer.com/v.php?i=52b54b2f5549a.png
    I hope this helps
    Results:
    Microsoft Windows 7 x64 Business Edition (Build 7600)
    Dell Inc. Inspiron N5110
    iTunes 11.1.3.8
    QuickTime 7.7.4
    FairPlay 2.5.16
    Apple Application Support 2.3.6
    iPod Updater Library 11.1f5
    CD Driver 2.2.3.0
    CD Driver DLL 2.1.3.1
    Apple Mobile Device 7.0.0.117
    Apple Mobile Device Driver 1.64.0.0
    Bonjour 3.0.0.10
    Gracenote SDK 1.9.6.502
    Gracenote MusicID 1.9.6.115
    Gracenote Submit 1.9.6.143
    Gracenote DSP 1.9.6.45
    iTunes Serial Number 00B5BBB0128227A8
    Current user is not an administrator.
    The current local date and time is 2013-12-21 08:10:13.
    iTunes is not running in safe mode.
    WebKit accelerated compositing is enabled.
    HDCP is supported.
    Core Media is supported.
    **** External Plug-ins Information ****
    Plug-in Name:          WhiteCap
    Plug-in Loaded:          Yes
    Plug-in Version:          1.0
    Plug-in File Version:          Unknown
    Plug-in Path:          C:\Users\IshankParul\AppData\Roaming\Apple Computer\iTunes\iTunes Plug-ins\WhiteCap_iTunes.dll
    Plug-in Name:          G-Force
    Plug-in Loaded:          Yes
    Plug-in Version:          2.0.7
    Plug-in File Version:          Unknown
    Plug-in Path:          C:\ProgramData\Apple Computer\iTunes\iTunes Plug-ins\vis_G-Force.dll
    **** Device Connectivity Tests ****
    iPodService 11.1.3.8 (x64) is currently running.
    iTunesHelper 11.1.3.8 is currently running.
    Apple Mobile Device service 3.3.0.0 is currently running.
    No Universal Serial Bus Controller found.
    No FireWire (IEEE 1394) Host Controller found.
    Most Recent Devices Not Currently Connected:
    iPod touch (4th generation) running firmware version 6.1.3
    Serial Number:          C42DTEV4DCP7
    iPhone 4 (GSM) running firmware version 6.1.2
    Serial Number:          7R107GYHA4S
    iPad 2 (GSM) running firmware version 6.1.2
    Serial Number:          DKVH31QFDFJ2
    **** Device Sync Tests ****
    No iPod, iPhone or iPad found.

  • SetJPEGEncodeParam method not found in JPEGImageEncoder jdk 1.5 and jdk 1.6

    Hi,
    We are group of students working on college project.
    We want to capture webcam and show stream on screen.
    We are using JMF and class JPEGImageEncoder.
    Here we are getting setJPEGEncodeParam method not found error.
    Please see detail error message and source code attached below.
    Thanks in advance.
    Regards,
    Vinayak & Surendra
    // Error and Warnings
    SwingCapture.java:125: warning: com.sun.image.codec.jpeg.JPEGImageEncoder is Sun proprietary API and may be removed in a future release
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    ^
    SwingCapture.java:125: warning: com.sun.image.codec.jpeg.JPEGCodec is Sun proprietary API and may be removed in a future release
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    ^
    SwingCapture.java:126: warning: com.sun.image.codec.jpeg.JPEGEncodeParam is Sun proprietary API and may be removed in a future release
    JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
    ^
    SwingCapture.java:128: cannot find symbol
    symbol : method setJPEGEncodeParam(com.sun.image.codec.jpeg.JPEGEncodeParam)
    location: class com.sun.image.codec.jpeg.JPEGImageEncoder
         encoder.setJPEGEncodeParam(param);
    ^
    1 error
    3 warnings
    // Source code
    import javax.swing.*;
    import javax.swing.event.*;
    import java.io.*;
    import javax.media.*;
    import javax.media.format.*;
    import javax.media.util.*;
    import javax.media.control.*;
    import javax.media.protocol.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import com.sun.image.codec.jpeg.*;
    public class SwingCapture extends Panel implements ActionListener
    public static Player player = null;
    public CaptureDeviceInfo di = null;
    public MediaLocator ml = null;
    public JButton capture = null;
    public Buffer buf = null;
    public Image img = null;
    public VideoFormat vf = null;
    public BufferToImage btoi = null;
    public ImagePanel imgpanel = null;
    public SwingCapture()
    setLayout(new BorderLayout());
    setSize(320,550);
    imgpanel = new ImagePanel();
    capture = new JButton("Capture");
    capture.addActionListener(this);
    String str1 = "vfw:Logitech USB Video Camera:0";
    String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";
    di = CaptureDeviceManager.getDevice(str2);
    ml = di.getLocator();
    try
    player = Manager.createRealizedPlayer(ml);
    player.start();
    Component comp;
    if ((comp = player.getVisualComponent()) != null)
    add(comp,BorderLayout.NORTH);
    add(capture,BorderLayout.CENTER);
    add(imgpanel,BorderLayout.SOUTH);
    catch (Exception e)
    e.printStackTrace();
    public static void main(String[] args)
    Frame f = new Frame("SwingCapture");
    SwingCapture cf = new SwingCapture();
    f.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    playerclose();
    System.exit(0);}});
    f.add("Center",cf);
    f.pack();
    f.setSize(new Dimension(320,550));
    f.setVisible(true);
    public static void playerclose()
    player.close();
    player.deallocate();
    public void actionPerformed(ActionEvent e)
    JComponent c = (JComponent) e.getSource();
    if (c == capture)
    // Grab a frame
    FrameGrabbingControl fgc = (FrameGrabbingControl)
    player.getControl("javax.media.control.FrameGrabbingControl");
    buf = fgc.grabFrame();
    // Convert it to an image
    btoi = new BufferToImage((VideoFormat)buf.getFormat());
    img = btoi.createImage(buf);
    // show the image
    imgpanel.setImage(img);
    // save image
    saveJPG(img,"c:\\test.jpg");
    class ImagePanel extends Panel
    public Image myimg = null;
    public ImagePanel()
    setLayout(null);
    setSize(320,240);
    public void setImage(Image img)
    this.myimg = img;
    repaint();
    public void paint(Graphics g)
    if (myimg != null)
    g.drawImage(myimg, 0, 0, this);
    public static void saveJPG(Image img, String s)
    BufferedImage bi = new BufferedImage(img.getWidth(null),
    img.getHeight(null), BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = bi.createGraphics();
    g2.drawImage(img, null, null);
    FileOutputStream out = null;
    try
    out = new FileOutputStream(s);
    catch (java.io.FileNotFoundException io)
    System.out.println("File Not Found");
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
    param.setQuality(0.5f,false);
    encoder.setJPEGEncodeParam(param);
    try
    encoder.encode(bi);
    out.close();
    catch (java.io.IOException io)
    System.out.println("IOException");

    JPEGImageEncoder isn't a JMF class...so this isn't a JMF question. You need to go to the appropriate forum, which would be Java2D, I believe.
    Also, is there a specific reason you're not just capturing from your web camera directly?

  • Input/Output And Method Not Found Problem

    Ok so firstly I think I should apologise on two fronts.
    Firstly, 'cause this is probably posted in the wrong board but I'm not sure this was suitable for the Swing board just 'cause I've been using Swing? And secondly 'cause the code I'm gonna post is so shoddy I would think this constitutes as flaim-bait. >_>
    In my defense this is purely for a little class project to give something to write some documentation on so I'm really not too bothered about the efficiency or ace-mazingness of the end result. I just want it to work.
    To the problem at hand.
    I'm trying to write a program that asks the user a question and then outputs their answer to a file, from which a tally of answers can later be made for the purpose of displaying "results".
    My problem is I've been having problems with the input/output of saving the answers given to the program.
    I'm still learning and input/output is probably my weakest subject (other than, y'know, being good at Java). I've had a bash at it in the following code but all it does it overwrite what is in the file with a single answer so no list of results accumulate. I generally don't have an idea what to try for that one so any pointers would be appreciated.
    Also, my second problem is, in trying to gather results by tallying what is contained in the file, I've run across a problem with the charAt() method not being found and I'm not sure why. Isn't that method a part of java.lang?
    Here's the code thus far:
    //libraries
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.text.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
    import java.io.*;
    class CaseStudy {
         public static void main(String args[]) {
              GUI maininterface = new GUI();
              maininterface.setupMenu();
              maininterface.display();
    class GUI {
         //for the actionlisteners
         int whatframe = 0;
         //creates mainframe and border content panel
         JFrame mainframe = new JFrame("Survey Client");
         JPanel borderpanel = new JPanel(), bottompanel = new JPanel();
         JButton quizbutton = new JButton("Take the quiz"), tallybutton = new JButton("Show Results"), submitbutton = new JButton("Submit Results"), menubutton = new JButton("Return To Menu");
         QuizQuestions toppanel = new QuizQuestions();
         QuizResults toppanel2 = new QuizResults();
         GUI() {
              //sets border in borderpanel, this spaces the main content in from the sides of the window
              borderpanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
              //sets up the frame and panels and adds on borders
              mainframe.setDefaultCloseOperation(mainframe.EXIT_ON_CLOSE); // exits java when clicking on close on main frame
              mainframe.getContentPane().add(borderpanel); // adds the panel as a component to the frame, the panel can hold stuffs
              borderpanel.setLayout(new BoxLayout(borderpanel, BoxLayout.PAGE_AXIS));// page_axis means it'll layout vertically
              bottompanel.setLayout(new BoxLayout(bottompanel, BoxLayout.LINE_AXIS));// line_axis means it'll layout horizontally
              //gives button an action
              quizbutton.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e1) {
                        setupQuiz();
              tallybutton.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e1) {
                        if(whatframe == 1) setupResults();
                        else {
                             int rusure = JOptionPane.showConfirmDialog(null, "Are you sure you wish to show results? Any current quiz answers won't be saved.", "Please Choose One", JOptionPane.YES_NO_OPTION);
                             if(rusure == JOptionPane.YES_OPTION) setupResults();
              menubutton.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e1) {
                        setupMenu();
              submitbutton.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e1) {
                        toppanel.doQuiz();
              borderpanel.add(bottompanel);
         public void setupMenu() {
              if(whatframe == 3) {
                   bottompanel.remove(menubutton);
                   borderpanel.remove(toppanel2);
              whatframe = 1;
              //adds components and lays them out
              bottompanel.add(quizbutton);
              bottompanel.add(Box.createRigidArea(new Dimension(0,10)));
              bottompanel.add(tallybutton);
              display();
         public void setupQuiz() {
              bottompanel.remove(quizbutton);
              bottompanel.remove(Box.createRigidArea(new Dimension(0,10)));
              bottompanel.remove(tallybutton);
              whatframe = 2;
              bottompanel.add(submitbutton);
              bottompanel.add(Box.createRigidArea(new Dimension(0,10)));
              bottompanel.add(tallybutton);
              borderpanel.add(toppanel);
              display();
         public void setupResults() {
              if(whatframe == 1) {
                   bottompanel.remove(quizbutton);
                   bottompanel.remove(Box.createRigidArea(new Dimension(0,10)));
                   bottompanel.remove(tallybutton);
              else {
                   bottompanel.remove(submitbutton);
                   bottompanel.remove(Box.createRigidArea(new Dimension(0,10)));
                   bottompanel.remove(tallybutton);
                   borderpanel.remove(toppanel);
              whatframe = 3;
              bottompanel.add(menubutton);
              borderpanel.add(toppanel2);
              display();
         public void display() {
              //sets the size of the frame around it's components and then shows it
              mainframe.pack();
              mainframe.setVisible(true);
              mainframe.validate(); //makes referenced container relayout it's components
    class QuizQuestions extends JPanel {
         LoadingSaving loadsave = new LoadingSaving();
         JPanel popm = new JPanel(), pop1 = new JPanel(), pop2 = new JPanel(), pop3 = new JPanel(), pop4 = new JPanel();
         JFormattedTextField ques = new JFormattedTextField(), op1 = new JFormattedTextField(), op2 = new JFormattedTextField(), op3 = new JFormattedTextField(), op4 = new JFormattedTextField();
         JButton bop1 = new JButton("1"), bop2 = new JButton("2"), bop3 = new JButton("3"), bop4 = new JButton("4");
         char answer;
         QuizQuestions() {
              popm.setLayout(new BoxLayout(popm, BoxLayout.PAGE_AXIS));
              pop1.setLayout(new BoxLayout(pop1, BoxLayout.LINE_AXIS));
              pop2.setLayout(new BoxLayout(pop2, BoxLayout.LINE_AXIS));
              pop3.setLayout(new BoxLayout(pop3, BoxLayout.LINE_AXIS));
              pop4.setLayout(new BoxLayout(pop4, BoxLayout.LINE_AXIS));
              this.add(popm);
              popm.add(ques);
              popm.add(pop1);
              popm.add(pop2);
              popm.add(pop3);
              popm.add(pop4);
              pop1.add(op1);
              pop1.add(bop1);
              pop2.add(op2);
              pop2.add(bop2);
              pop3.add(op3);
              pop3.add(bop3);
              pop4.add(op4);
              pop4.add(bop4);
              //sets up question text fields
              ques.setEditable(false);
              op1.setEditable(false);
              op2.setEditable(false);
              op3.setEditable(false);
              op4.setEditable(false);
              bop1.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e1) {
                        answer = 'a';
              bop2.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e1) {
                        answer = 'b';
              bop3.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e1) {
                        answer = 'c';
              bop4.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e1) {
                        answer = 'd';
              Question1();
         public void doQuiz() {
              loadsave.save(answer);
         public void Question1() {
              ques.setValue("Who's your favourite X-Men character?");
              op1.setValue("Cyclops");
              op2.setValue("Xavier");
              op3.setValue("Wolverine");
              op4.setValue("Rogue");
    class QuizResults extends JPanel {
         LoadingSaving loadsave = new LoadingSaving();
         JPanel popm = new JPanel();
         JFormattedTextField op1 = new JFormattedTextField(), op2 = new JFormattedTextField(), op3 = new JFormattedTextField(), op4 = new JFormattedTextField();
         int[] answerarray = new int[4];
         QuizResults() {
              popm.setLayout(new BoxLayout(popm, BoxLayout.PAGE_AXIS));
              this.add(popm);
              popm.add(op1);
              popm.add(op2);
              popm.add(op3);
              popm.add(op4);
              op1.setEditable(false);
              op2.setEditable(false);
              op3.setEditable(false);
              op4.setEditable(false);
              answerarray = loadsave.load();
              op1.setValue(answerarray[0]);
              op2.setValue(answerarray[1]);
              op3.setValue(answerarray[2]);
              op4.setValue(answerarray[3]);
    class LoadingSaving {
         public void save(char answer) {
              FileReader fr;
              FileWriter fw;
              BufferedReader br;
              String s;
              try {
              //ERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERROR
                   fr = new FileReader("casestudyoutput.txt");
                   fw = new FileWriter("casestudyoutput.txt");
                   br = new BufferedReader(fr);
                   if (br.readLine() == null) s = "x";
                   else s = br.readLine();
                   s = s + answer;
                   fw.write(s);
                   fr.close();
                   fw.close();
              //ERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERROR
              catch(FileNotFoundException exc) {
                   JOptionPane.showMessageDialog(null, "File not found.");
                   return;
              catch(IOException exc) {
                   JOptionPane.showMessageDialog(null, "Something bad happened.");
                   return;
         public int[] load() {
              FileReader fr;
              BufferedReader br;
              int[] answerarray = new int[3];
              String s;
              long length;
              int a = 0, b = 0, c = 0, d = 0;
              answerarray[0] = 0;
              answerarray[1] = 0;
              answerarray[2] = 0;
              answerarray[3] = 0;
              try {
                   fr = new FileReader("casestudyoutput.txt");
                   br = new BufferedReader(fr);
                   if (br.readLine() == null) return answerarray;
                   else s = br.readLine();
                   length = s.length();
                   for(int i = 0; i < length; i++) {
                        char ch = charAt(i); //ERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERRORERROR
                        switch(ch) {
                             case 'a':
                                  a++;
                                  break;
                             case 'b':
                                  b++;
                                  break;
                             case 'c':
                                  c++;
                                  break;
                             case 'd':
                                  d++;
                                  break;
                   answerarray[0] = a;
                   answerarray[1] = b;
                   answerarray[2] = c;
                   answerarray[3] = d;
                   fr.close();
              catch(FileNotFoundException exc) {
                   JOptionPane.showMessageDialog(null, "File not found.");
                   return answerarray;
              catch(IOException exc) {
                   JOptionPane.showMessageDialog(null, "Something bad happened.");
                   return answerarray;
         return answerarray;
    }Any pointers/tips/solutions/angry posts to tell me to stop trying to learn Java would be greatly appreciated.
    Thanks in advance!
    Oh, and in trying to work with it a bit further I realised I'm having a few problems with runtime errors due to exceptions. The first was due to the array being assigned out of bounds (fixed in the above code). But the second reads the following:
    Exception in thread "main" java.lang.NullPointerException
         at Loadingsaving.load(CaseStudy.java:330)
         at QuizResults.(init)(CaseStudy.java.259)
         at GUI.(init)(CaseStudy.java:34)
         at CaseStudy.main(CaseStudy.java:15)Not quite sure what this one means or how to handle it. =\
    Edited by: ThePermster on May 19, 2008 8:08 AM

    A NullPointerException means a method has been called on a null object, or a variable that isn't pointing to any object. Your Exception points to line 330, which is:
    length = s.length();A NPE on that line means that s is null. So let's look at where s is set:
    if (br.readLine() == null) return answerarray;
    else s = br.readLine();s gets it's value from br.readLine(), so that method must be returning null. You have a logical error here. Look at your If-Else. It reads a line, makes sure it isn't null...then it reads another line. Well what if that line is null? You are performing 2 reads here instead of 1.
    Since your If condition returns a value, there's no need for an Else. The code will continue on until it reaches another return. Try this:
    s = br.readLine();
    if (s == null) return answerarray;

  • SetJPEGEncodeParam method not found

    Hi,
    We are group of students working on college project.
    We want to capture webcam and show stream on screen.
    We are using JMF and class JPEGImageEncoder.
    Here we are getting setJPEGEncodeParam method not found error.
    Please see detail error message and source code attached below.
    Thanks in advance.
    Regards,
    Vinayak & Surendra
    // Error and Warnings
    SwingCapture.java:125: warning:
    com.sun.image.codec.jpeg.JPEGImageEncoder is Sun proprietary API and
    may be removed in a future release
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    ^
    SwingCapture.java:125: warning: com.sun.image.codec.jpeg.JPEGCodec is
    Sun proprietary API and may be removed in a future release
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    ^
    SwingCapture.java:126: warning:
    com.sun.image.codec.jpeg.JPEGEncodeParam is Sun proprietary API and
    may be removed in a future release
    JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
    ^
    SwingCapture.java:128: cannot find symbol
    symbol : method setJPEGEncodeParam
    (com.sun.image.codec.jpeg.JPEGEncodeParam)
    location: class com.sun.image.codec.jpeg.JPEGImageEncoder
    encoder.setJPEGEncodeParam(param);
    ^
    1 error
    3 warnings
    // Source code
    import javax.swing.;
    import javax.swing.event.;
    import java.io.;
    import javax.media.;
    import javax.media.format.;
    import javax.media.util.;
    import javax.media.control.;
    import javax.media.protocol.;
    import java.util.;
    import java.awt.;
    import java.awt.image.;
    import java.awt.event.;
    import com.sun.image.codec.jpeg.*;
    public class SwingCapture extends Panel implements ActionListener
    public static Player player = null;
    public CaptureDeviceInfo di = null;
    public MediaLocator ml = null;
    public JButton capture = null;
    public Buffer buf = null;
    public Image img = null;
    public VideoFormat vf = null;
    public BufferToImage btoi = null;
    public ImagePanel imgpanel = null;
    public SwingCapture()
    setLayout(new BorderLayout());
    setSize(320,550);
    imgpanel = new ImagePanel();
    capture = new JButton("Capture");
    capture.addActionListener(this);
    String str1 = "vfw:Logitech USB Video Camera:0";
    String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";
    di = CaptureDeviceManager.getDevice(str2);
    ml = di.getLocator();
    try
    player = Manager.createRealizedPlayer(ml);
    player.start();
    Component comp;
    if ((comp = player.getVisualComponent()) != null)
    add(comp,BorderLayout.NORTH);
    add(capture,BorderLayout.CENTER);
    add(imgpanel,BorderLayout.SOUTH);
    catch (Exception e)
    e.printStackTrace();
    public static void main(String[] args)
    Frame f = new Frame("SwingCapture");
    SwingCapture cf = new SwingCapture();
    f.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    playerclose();
    System.exit(0);}});
    f.add("Center",cf);
    f.pack();
    f.setSize(new Dimension(320,550));
    f.setVisible(true);
    public static void playerclose()
    player.close();
    player.deallocate();
    public void actionPerformed(ActionEvent e)
    JComponent c = (JComponent) e.getSource();
    if (c == capture)
    // Grab a frame
    FrameGrabbingControl fgc = (FrameGrabbingControl)
    player.getControl("javax.media.control.FrameGrabbingControl");
    buf = fgc.grabFrame();
    // Convert it to an image
    btoi = new BufferToImage((VideoFormat)buf.getFormat());
    img = btoi.createImage(buf);
    // show the image
    imgpanel.setImage(img);
    // save image
    saveJPG(img,"c:\\test.jpg");
    class ImagePanel extends Panel
    public Image myimg = null;
    public ImagePanel()
    setLayout(null);
    setSize(320,240);
    public void setImage(Image img)
    this.myimg = img;
    repaint();
    public void paint(Graphics g)
    if (myimg != null)
    g.drawImage(myimg, 0, 0, this);
    public static void saveJPG(Image img, String s)
    BufferedImage bi = new BufferedImage(img.getWidth(null),
    img.getHeight(null), BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = bi.createGraphics();
    g2.drawImage(img, null, null);
    FileOutputStream out = null;
    try
    out = new FileOutputStream(s);
    catch (java.io.FileNotFoundException io)
    System.out.println("File Not Found");
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
    param.setQuality(0.5f,false);
    encoder.setJPEGEncodeParam(param);
    try
    encoder.encode(bi);
    out.close();
    catch (java.io.IOException io)
    System.out.println("IOException");
    }

    look at: javax.imageio.ImageIO
    File myFile = new File(myFileName);
    myFile.createNewFile();
    ImageIO.write(myImage, "JPEG", myFile);also post your code with code tags--otherwise the forum software will alter your code, using some of it as formatting sequences.

  • Pc suite dos not recognise the connect phone.

    I am receiving the error message "pc suite dos not recognise the connect phone.
    the connection between the pc and the phone failed, error code 0x80043605. Switch off your phone, switch it on, and try again."
    Any idea?
    Operative System: Windows XP SP 2
    PC Suite version: 6.80.20
    Mobile: 7250i
    Connection method: cable DKU5
    BR,
    Leandra

    Hi, did running PC suite cleaner 3.3 work for you? I am having exactly the same problem and tried this. PC suite cleaner didn't seem to run properly. I chose the "other" problem type and it said that it could not create a list of directories, please reboot and try again. I did this but no good. I then reloaded PC suite and got the same results.
    My phone is 6230i
    PC suite version is 8.80.21
    Thanks!

  • PC Suite not recognising any connection

    Having recently updated to the newer model 6120c from my previous 6230i I reinstalled PC Suite for ease of transferring data from my PC to my handset but have found that when I reach the 'Get Connected' page of the installation where it asks me to 'Select the connection type' I have no options active at all and when I make certain that the phone is connected to the cable which is fully plugged into a USB port it still will not show any active options for me to select from. I had no problems connecting the previous 6230i via the cable connection and am currently at a loss on how to solve this issue. It may be with the limited amount of services that I have running that I may have inadvertantly turned off an essential service that is required to have PC Suite running. Or maybe it could be that I have a selective start up, but upon investigating the system config utility I do note that there is a launch application checked for a Nokia service to start up so at this point I am open to any helpful suggestions that may assist in the solution to my problem.
    Thanks in advance for any help on this issue.
    Jasper69
    PC Operating System: XP Pro SP2
    Connection Method: Cable
    Handset: Nokia 6120c (Classic)
    PC Suite Version: 6.84.78.3

    Microsoft Windows XP Professional Version 2002
    Service Pack 2
    Nokia PC Suite 7.1.18.0
    Cable Type: DKE-2
     I have a problem with PC suite; it doesn’t allow me to connect to my Nokia N95 and maybe my other Nokia phones; as the get connected wizard shows three greyed out options. These options are Cable connection, Infrared connection and Bluetooth connection. These are found under the select connection type. I have already un and then reinstalled three times, tried to repair the installation and installed the drivers separately. The previous 7.0 version worked fine, but by updating I can no longer connect my phone through PC suite mode. Data transfer, image print and media player work fine. The USB symbol does appear on top of the phone screen, but still no phone connected.
     When I click on ‘click here to connect a phone’ a
    Menu pops up:
    Get Connected - Troubleshoot Titled  Problems with Infrared connection?  I don’t even have infrared or Bluetooth on my laptop.
    The computer does however make a noise to show that something has been connected to the laptop, “tun-nuh” when I connect via PC suit mode.
     When I click on one touch access, it says no phones connected, there are no Nokia modems installed, make sure you have installed Nokia Connectivity Cable Driver software. Settings spanner icon, Select modem, and from here I can chose Nokia N95 USB Modem, and then my network operator.
     Sometimes when I connect the phone, it says the USB device is not recognised and has malfunctioned. But, when I continue to replug into the different sockets; it starts to install new device found Nokia N95, phone parent, sync-ml… until it finally says your new device is ready.
     Please do help, if you can.
    Thank you!

  • A function DrawGeometry not recognised in WPF

    Hello
    I'm transleting project from C# to WPF
    In C#, I have : 
    drawingContext.DrawGeometry.DrawPolygon(new System.Windows.Media.Pen(System.Windows.Media.Brushes.Black, 3), p);
    In WPF, DrawGeometry is not recognise and I have the libraries
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using LibLogic;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Windows.Forms;
    I have an error
    'System.Windows.Media.DrawingContext.DrawGeometry(System.Windows.Media.Brush, System.Windows.Media.Pen, System.Windows.Media.Geometry)' is a 'method', which is not valid in the given context
    Z:\WPF\Kakuro WPF 22_02_2015\UserControls\Triangle.xaml.cs
    76
    28
    UserControls
    What should I do ?

    You must add some points to aa if you want to draw a Polygon, otherwise it is just a blank geometry object. 
    Here is a complete example of a VisualHost object that hosts a DrawingVisual:
    public class VisualHost : FrameworkElement
    private DrawingVisual path;
    public VisualHost()
    Point point2 = new Point(10, 80);
    Point point3 = new Point(50, 50);
    Point point4 = new Point(30, 20);
    StreamGeometry aa = new StreamGeometry();
    using (StreamGeometryContext geometryContext = aa.Open()) {
    geometryContext.BeginFigure(new Point(1, 50), true, true);
    PointCollection points = new PointCollection
    point2,
    point3,
    point4
    geometryContext.PolyLineTo(points, true, true);
    // Draw the polygon visual
    DrawingVisual visual = new DrawingVisual();
    using (DrawingContext context = visual.RenderOpen()) {
    context.DrawGeometry(Brushes.LightGreen, new Pen(Brushes.White, 2), aa);
    path = visual;
    protected override int VisualChildrenCount {
    get {
    return 1;
    protected override Visual GetVisualChild(int index) {
    return path;
    You can add it to a window like this:
    public partial class MainWindow : Window
    public MainWindow() {
    InitializeComponent();
    stackPanel.Children.Insert(0, new VisualHost()
    Width = 250,
    Height = 250
    <Window x:Class="WpfApplication24_4.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <StackPanel x:Name="stackPanel">
    </StackPanel>
    </Window>
    Hope that helps.
    Please remember to mark all helpful posts that answers your question(s), and only these, as answer and please start a new thread if you have a new question.

Maybe you are looking for