Swing Error

Get the following error:
package javax.swing not found in import
I am using jdk1.3.1
Here is my code
import java.awt.*;
import javax.swing.*;
public class Notepad1 extends JFrame {
     public Notepad1() {
          setSize(300, 400);
          show();
     public static void main(String[] args) {
          Notepad1 npad = new Notepad1();

Your JDK installation is probably broken, try reinstalling.

Similar Messages

  • Swing Error while trying to set libraries on a new Project.

    I am running JDeveloper Version 10.1.2.1.0 (Build 1913) -- on a machine running Windows XP SP2
    Initially I tried with the basic version (without JDK) and configured by local install of j2sdk1.4.2_05.
    Then later I tried downloading the full version and used the java.version 1.4.2_06 which comes with it. In both cases I get a NPE while performing the following steps.
    Created a WorkSpace
    Created an Empty Project in it
    Go to Project Properties
    Click on "libraries"
    I get the following Error
    java.lang.NullPointerException
         at oracle.jdevimpl.config.JProjectLibrariesPanel.loadFrom(JProjectLibrariesPanel.java:134)
         at oracle.jdevimpl.config.JProjectLibrariesPanel.onEntry(JProjectLibrariesPanel.java:95)
         at oracle.ide.panels.MDDPanel.enterTraversableImpl(MDDPanel.java:841)
         at oracle.ide.panels.MDDPanel.enterTraversable(MDDPanel.java:815)
         at oracle.ide.panels.MDDPanel.access$7000871(MDDPanel.java:90)
         at oracle.ide.panels.MDDPanel$Tsl.updateSelectedNavigable(MDDPanel.java:1206)
         at oracle.ide.panels.MDDPanel$Tsl.updateSelection(MDDPanel.java:1074)
         at oracle.ide.panels.MDDPanel$Tsl.actionPerformed(MDDPanel.java:1068)
         at javax.swing.Timer.fireActionPerformed(Timer.java:271)
         at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:141)
         at java.awt.Dialog$1.run(Dialog.java:540)
         at java.awt.Dialog.show(Dialog.java:561)
         at java.awt.Component.show(Component.java:1133)
         at java.awt.Component.setVisible(Component.java:1088)
         at oracle.bali.ewt.dialog.JEWTDialog.runDialog(Unknown Source)
         at oracle.ide.dialogs.WizardLauncher.runDialog(WizardLauncher.java:55)
         at oracle.ide.panels.TDialogLauncher.showDialog(TDialogLauncher.java:276)
         at oracle.jdeveloper.model.JProjectSettingsPanel.showDialog(JProjectSettingsPanel.java:185)
         at oracle.jdeveloper.model.JProjectSettingsPanel.showDialog(JProjectSettingsPanel.java:110)
         at oracle.jdeveloper.model.JProjectSettingsPanel.showDialog(JProjectSettingsPanel.java:101)
         at oracle.jdeveloper.model.JProjectStructureController.handleEvent(JProjectStructureController.java:342)
         at oracle.ide.IdeAction.performAction(IdeAction.java:649)
         at oracle.ide.IdeAction$1.run(IdeAction.java:857)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
    Beyond this the JDev becomes practically unusable, as if I try clicking on any thing else I get the error, "The J2SE version must be specified"
    Only way to recover from the error is to close Jdev and re open the same. But even then I am not able to change any library setting for the project.
    Any suggestions on how to get around the problem?

    I believe I figured it out .. thanks

  • New to swing: Error while using getText() in ActionPerformed

    Hi there!
    I'm fairly new to java and swing, and this problem I'm having drives me nuts!
    // Imports //
    public class Generator extends JFrame {
         // Graphical components
         private JTextField nr1;
         private JTextField nr2;
         // Constructor
         public Generator() {
              // Call superclass
                    // Init variables
              JTextField nr1 = new JTextField(2);
              JTextField nr2 = new JTextField(2);
              nr1.setVisible(true);
              nr2.setVisible(true);
              // Layout stuff..
              // Create listner-object for event handeling
              Lyssnare minLyssnare = new Lyssnare();
              playerName.addActionListener(minLyssnare);
              clear.addActionListener(minLyssnare);
              shuffle.addActionListener(minLyssnare);
              // closing of window
              // Pack
              // Visible
         // Action Listener
         class Lyssnare implements ActionListener {
              public void actionPerformed(ActionEvent ae) {
                   // Some other actions...
                            // Shuffle
                   else if(ae.getSource() == shuffle) {
                        String teams = nr1.getText();
                        String players = nr2.getText();
                        Shuffle.shuffle(name);
                        playerArea.setVisible(false);
                        int teamsint = Integer.parseInt(teams);
                        int playersint = Integer.parseInt(players);
                        error1.setVisible(true);
         }The error I get is after "else if(ae.getSource() == shuffle) {"
    something on the next line (and the line after that) is the one who gives the error...
    I Get this (during running, compile works fine..):
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    AFAIK that means I'm reffering to something that is null... but how can that be when all the textfields are initialised? do I have to make does fields global in some way?
    Grateful for any help!

    Your inner class does not have access to nr1 and nr2 because they are not final variables.
    Instead of creating an inner class Lyssnare, you can have your Generator class implement the ActionListener and add the actionPerformed method inside Generator class as follows:
    public class Generator extends JFrame implements ActionListener {
         // Graphical components
         private JTextField nr1;
         private JTextField nr2;
         // Constructor
         public Generator() {
              // Call superclass
                    // Init variables
              JTextField nr1 = new JTextField(2);
              JTextField nr2 = new JTextField(2);
              nr1.setVisible(true);
              nr2.setVisible(true);
              // Layout stuff..
              // Create listner-object for event handeling
              //Lyssnare minLyssnare = new Lyssnare();
              playerName.addActionListener(this);
              clear.addActionListener(this);
              shuffle.addActionListener(this);
              // closing of window
              // Pack
              // Visible
    public void actionPerformed(ActionEvent ae) {
                   // Some other actions...
                            // Shuffle
                   else if(ae.getSource() == shuffle) {
                        String teams = nr1.getText();
                        String players = nr2.getText();
                        Shuffle.shuffle(name);
                        playerArea.setVisible(false);
                        int teamsint = Integer.parseInt(teams);
                        int playersint = Integer.parseInt(players);
                        error1.setVisible(true);
              }

  • Weird Swing Error!

    With J2SE 1.4.2 (PREVIOUS VERSIONS DID NOT DO THIS) JDK i RANDOMLY get :
    java.lang.NullPointerException
    at javax.swing.ImageIcon.<init>(Unknown Source)
    at javax.swing.ImageIcon.<init>(Unknown Source)
    at com.sun.java.swing.plaf.windows.WindowsFileChooserUI$ShortCutPanel.<init>(Unknown Source)
    at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(Unknown Source)
    at javax.swing.plaf.basic.BasicFileChooserUI.installUI(Unknown Source)
    at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(Unknown Source)
    at javax.swing.JComponent.setUI(Unknown Source)
    at javax.swing.JFileChooser.updateUI(Unknown Source)
    at javax.swing.JFileChooser.setup(Unknown Source)
    at javax.swing.JFileChooser.<init>(Unknown Source)
    at javax.swing.JFileChooser.<init>(Unknown Source)
    at MMCDCatalog.openDB(MMCDCatalog.java:570)
    at MMCDCatalog.access$200(MMCDCatalog.java:77)
    at MMCDCatalog$OpenFileAction.actionPerformed(MMCDCatalog.java:1023)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    with code
    JFileChooser fc;
    MMCDFileFilter ff;
    int dialogReturnVal;
    String nameChosen;
    //Create a file chooserfc = new JFileChooser();
    fc.setMultiSelectionEnabled(false);
    fc.setDragEnabled(false);
    //Create a new FileFilter
    ff = new MMCDFileFilter();
    //Add this filter to our File chooser.
    fc.addChoosableFileFilter(ff);
    fc.setFileFilter(ff);
    dialogReturnVal = fc.showOpenDialog(mainFrame);
    if (dialogReturnVal == JFileChooser.APPROVE_OPTION) {  
       nameChosen = fc.getSelectedFile().getAbsolutePath();
    }which is in my openDB() method, which is called from an actionPerformed() somewhere else that does nothing except calling openDB()
    IS THIS A BUG IN SWING 1.4.2??????????????
    AH! thought this would be relevant. I also execute the code (when building my GUI) :
    try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(mainFrame, "Could not load the look and feel", "Error", JOptionPane.ERROR_MESSAGE);
    } and i'm running Windows XP Pro SP1... since 1.4.2 added the new "Windows XP" look, is it a new introduced bug???? that's why i'm asking :P

    1) cross posts are annoying
    2) have you tried the same code built on the same Java SDK on a system running Win2000 or Solaris
    3) with the honorific "Mastermind" I'm sure you can figure it out.
    4) is the line new
    //Create a file chooserfc = new JFileChooser(); one line or two? Should it be
    //Create a file chooser
    fc = new JFileChooser();

  • Swing error messages

    I have written the follwing code and to the best on my understanding it's correct but for some reason the JButton object fails to show up on the JPanel(i'm not even 100% sure the panel is attached the JFrame). The error message i get is as follows:
    Exception in thread "main" java.lang.Error: Do not use Mouse.add() use Mouse.get
    ContentPane().add() instead
    at javax.swing.JFrame.createRootPaneException(JFrame.java:465)
    at javax.swing.JFrame.addImpl(JFrame.java:491)
    at java.awt.Container.add(Container.java:307)
    at Mouse.main(Mouse.java:31)
    and here is the code.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Mouse extends JFrame
         public static void main(String[] args)
              JFrame jf = new Mouse();
              jf.setSize(300, 300);
              jf.setVisible(true);
              JPanel jp = new JPanel(new FlowLayout());
              JButton jb = new JButton("GO!");
              jb.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        System.out.println("hello");
              jp.add(jb);
              jf.add(jp);
         // constructor
         public Mouse()
              super("MouseListener");
    can anyone see anything wrong with it?

    Hello,
    Exception in thread "main" java.lang.Error: Do not use Mouse.add()
    use Mouse.getContentPane().add() insteadAs clearly stated by the exception message, you should add the JPanel this way:
    jf.getContentPane().setLayout(new BorderLayout());
    jf.getContentPane().add(jp, BorderLayout.NORTH);I hope it helps.

  • HelloWorld Swing Error -JFrame

    Not sure why this happened. I've made no change to my computer, yet today I am unable to
    compile the following code, when I was able to do it the day before. For some rease JFrame is
    not understood:
    My Code:
    import javax.swing.*;
    import java.awt.*;
    public class HelloWorld extends JApplet {
    SwingHelloWorldPanel m_Panel;
    Create the panel and pass init to it
    public void init() {
    m_Panel = new SwingHelloWorldPanel();
    // NOTE the call to getContentPane - this is important
    getContentPane().add("Center", m_Panel);
    m_Panel.init();
    public void start() {
    m_Panel.start();
    Inner class representing a panel which does all the work
    static class SwingHelloWorldPanel extends JPanel {
    public void paint(Graphics g) {
    super.paint(g);
    Dimension size = getSize();
    g.setColor(Color.lightGray);
    g.fillRect(0,0,size.width,size.height);
    g.setColor(Color.red);
    g.drawString("Hello World",50,50);
    // Override to do more interesting work
    public void init() {
    public void start() { }
    // end inner class SwingHelloWorldPanel
    Standard main for Applet/Application projects
    Note that an inner class is created to to the
    real work. The use of a light weight inner class
    prevents inclusion of a heavyweight JApplet inside
    a heavyweight container
    public static void main(String args[]) {
         JFrame f = new JFrame("SwingHelloWorld");
         // Create the panel and pass init and start to it
         SwingHelloWorldPanel     hello = new SwingHelloWorldPanel();
    // NOTE the call to getContentPane - this is important
         f.getContentPane().add(hello);
         hello.init();
         hello.start();
         f.setSize(300, 300);
         f.show();
    The error:
    C:\java_dev>javac HelloWorld.java
    HelloWorld.java:71: cannot resolve symbol
    symbol : constructor JFrame (java.lang.String)
    location: class JFrame
    JFrame f = new JFrame("SwingHelloWorld");
    ^
    1 error
    Thanks in advance

    EXIT_ON_CLOSE has been in the API since v 1.3. Are you using an earlier version?

  • JWS 1.6.0_12 possible regression - can anyone verify?

    My company's application uses Java 1.4.2, and has some issues with later Java versions (event handling appears to have been done in an interesting way in our libraries that doesn't seem to upgrade properly). This is something I don't have the ability to change, much as I would like to.
    To ensure we can always use the correct version of Java, we therefore deploy the application using JWS, specifying J2SE Version 1.4 in the JNLP file.
    I've recently been investigating JWS 1.6.0, and have run into certain technical difficulties.
    * With JWS 1.6.0 and later (I've tried all the publicly available releases), I get 100% CPU usage whenever the application tries to load a class out of anything but the first JAR file. This may be an issue with the JAR files themselves, as I can't replicate with our other application. If anyone can offer any pointers on this, it'd be great (but I'm going to assume "broken JARs" and ignore it for now). Note that the exact same JNLP file and JAR files work fine in JWS 1.4 and 1.5 - it's just upgrading to JWS 1.6.0 or later that causes this issue.
    * With JWS 1.6.0_12, if the "homepage" is set to a non-responsive server, JWS fails to launch the application. This worked fine in JWS 1.6.0_11 - and seems odd; why would JWS try and contact the homepage for the application (note that this is nothing like the CodeBase or DocumentBase). The error received is as below:
    #### Java Web Start Error:
    #### No route to host: connect* With JWS 1.6.0_12, the application fails to start even once the homepage is set to a valid URL, when using the JRE 1.4.2. The error message below is shown. Note that this code works fine on JWS 1.6.0_11, and also works fine if the J2SE Version is set to 1.6 - so it appears to be a problem with the way JWS is launching JRE 1.4.2...
    Java Plug-in 1.6.0_12
    Using JRE version 1.4.2_19 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\Aldata
    java.lang.Error: Do not use javax.swing.JFrame.setLayout() use javax.swing.JFrame.getContentPane().setLayout() instead
         at javax.swing.JFrame.createRootPaneException(Unknown Source)
         at javax.swing.JFrame.setLayout(Unknown Source)
         at sun.plugin2.applet.viewer.JNLP2Viewer$1.run(JNLP2Viewer.java:355)
         at java.awt.event.InvocationEvent.dispatch(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)I think the "homepage" bug should be easy for anyone to verify, but I'd appreciate any tips anyone can give me on where best to follow on the Swing error with JRE 1.4.2, or if anyone has ever encountered a similar 100% CPU issue using JWS - I just don't know where to start on that one (Google wasn't helpful!)

    Hi there,
    Our team supports a 1.4.2 application running at our company, and we have experienced a similar CPU usage issue now that the users have JWS 1.6 installed on their PCs for other reasons.
    The app now takes about 30 seconds to even appear to the user where it used to take 3 seconds or so in JWS 1.4.2. This is against JWS 1.6.0_12. The app appears to be taking forever to load classes from a large jar file (WebLogic's weblogic.jar file, 35 MB in size). And the app runs through memory at an incredible rate, consuming 3 MB or so to load a single class. I haven't found any solutions online. I figured I would try to look at the JNLPClassLoader source at some point and see if I could understand why it's doing so much work.

  • Musings: MVC Front Controller/Command and Controller Strategy

    Hi,
    I am currently taking my first shot at implementing the Front Controller pattern, the Command and Controller Strategy flavor, in Java. When applying the pattern, my chosen point of focus is achieving as much isolation as possible of Client-specific implementation details from the rest of the framework (Web-based framework Clients, Swing-based framework Clients, queueing-based framework Clients, etc.) However, I am running into a lot of (apparent?) inconsistencies when it comes to CCS discussions "out there", so I have a feeling that perhaps I have misunderstood the Front Controller/Command and Controller Strategy pattern. Maybe the MVC gurus out there would have some thoughts on the matter.
    My issues:
    1.) Some CCS discussions seem to assign View presentation (sometimes called "dispatch", or "rendering", or "forwarding"?) to an ApplicationController. It seems puzzling to me, since only a concrete FrontController should include any knowledge of a concrete View structure. Shouldn't only a FrontController perform a logical-to-physical resource mapping, thus encapsulating knowledge whether a particular View is a separate, stand-alone Web page or a compound, argument-driven Swing object, and how to "present it" (by either redirecting to a Web page, or bringing a particular Swing object into the foreground)?
    2.) Some CCS discussions seem to introduce Client-specific implementation details at the ApplicationController level, for example "HTTP requests" or "HTTP responses". It seems puzzling to me, since I feel that every part of the framework, except for a concrete FrontController, should be completely independent of the nature of a Client making a request. Instead, I created a generic Request object w/arguments and have a concrete FrontController translate any client-specific details into such a generic Request, before delegating to an ApplicationController.
    3.) In the light of the (2.) above, I am not sure what constitutes a "response" from an ApplicationController back to a FrontController. It seems to me that the only universal "response" is a LogicalViewEnumeration: what View to present once a command has been completed, in many cases a "don't care", or a "show the requestor", or a "show a home page" (not every request has to result in changing a View). Well, perhaps a LogicalViewEnumeration as well as possible View arguments (?).
    4.) In the light of the (3.) above, I suspect that any failures in Request delegation, or Command execution, should be perhaps propagated back to a FrontController by exceptions only, since, say, a WebFrontController might want to show a click-through error page, when a SwingFrontController might prefer to show an error dialog box, a LogicalErrorViewEnumeration might not make sense at all in the context of a particular Client, for example a queueing Client.
    5.) In the light of the (4.) above, there is the question of an appropriate Request interface (into an ApplicationController), an appropriate Response interface (back into a FrontController), as well as an appropriate ViewArguments interface (into a FrontController and later into a View). The problem with generic Requests is that they can be created with nonsensical argument combinations, so shouldn't Requests be abstract and force proper arguments in concrete subclasses, through explicit constructors (in a sense, degenerate Commands)? The problem with Responses and ViewArguments is that... well, I have not found any formal discussion anywhere as to what those should look like. In most samples I have encountered, Responses include Client-specific implementation details, as mentioned in (2.), above.
    6.) Some CCS discussions seem to introduce a Flow Manager at the ApplicationController level. It seems puzzling to me, since the whole point of the Command and Controller Strategy flavor seems to be centralization of business logic execution within self-contained Command objects. Shouldn't Requests get associated with Handlers (objects capable of actually carrying out Requests) and transformed into Commands inside an ApplicationController, thus Commands themselves return appropriate LogicalViewEnumeration back to an ApplicationController, back to a FrontController? Let's consider a ShowMyShippingAddress request coming into the framework: unless such a Request is eventually treated as a Command returning a particular LogicalViewEnumeration, it is suddenly a Flow Manager "acting" as a business logic driver. I guess the question here is: except for a few special cases handled by a particular ApplicationController (authentication, error conditions, default behavior, etc.), should flow management be considered stand-alone, or always delegated to Commands?
    7.) Some CCS discussions seem to include an extra Request argument that specifies an ApplicationController to use (Request.Action="create", Request.Controller="account", Request.Username="me-me-me"), instead of using a Router inside of a FrontController to resolve to a particular ApplicationController through a generic action (Request.Action="createAccount", Request.Username="me-me-me"). I am not sure about the reason for such a design decision: why should a Client or a FrontController be allowed to concern itself with an implementation-level structure of the framework? Wouldn't any framework state -dependent ApplicationController resolution issues be best handled inside a Router, used by a FrontController to resolve [obtain] an appropriate ApplicationController, thus preventing Clients from ever forcing the framework into a possibly inconsistent behavior?
    Any comments appreciated...
    Thanks,
    Gary

    gniemcew wrote:
    1.) Some CCS discussions seem to assign View presentation (sometimes called "dispatch", or "rendering", or "forwarding"?) to an ApplicationController. It seems puzzling to me, since only a concrete FrontController should include any knowledge of a concrete View structure. Shouldn't only a FrontController perform a logical-to-physical resource mapping, thus encapsulating knowledge whether a particular View is a separate, stand-alone Web page or a compound, argument-driven Swing object, and how to "present it" (by either redirecting to a Web page, or bringing a particular Swing object into the foreground)?It is hard to tell without reading the actual discussion, but my guess is that the posters were either conflating or being loose with the distinction between a FrontController and an ApplicationController. The former is (normally) intimately tied to the actual view being used (HTTP, Swing, etc.) whereas the ApplicationController typically is not. Both are involved in dispatch and event processing. The former normally renders a view whereas the latter does not.
    gniemcew wrote:
    2.) Some CCS discussions seem to introduce Client-specific implementation details at the ApplicationController level, for example "HTTP requests" or "HTTP responses". It seems puzzling to me, since I feel that every part of the framework, except for a concrete FrontController, should be completely independent of the nature of a Client making a request. Instead, I created a generic Request object w/arguments and have a concrete FrontController translate any client-specific details into such a generic Request, before delegating to an ApplicationController.Generic is fine. However, you can become generic to the point where your Request and Response interfaces are only acting as "marker" interfaces (think of java.io.Serializable). Writing a truly generic controller is possible, but personally, I have never found the effort justified.
    gniemcew wrote:
    3.) In the light of the (2.) above, I am not sure what constitutes a "response" from an ApplicationController back to a FrontController. It seems to me that the only universal "response" is a LogicalViewEnumeration: what View to present once a command has been completed, in many cases a "don't care", or a "show the requestor", or a "show a home page" (not every request has to result in changing a View). Well, perhaps a LogicalViewEnumeration as well as possible View arguments (?).A given service (if you ascribe to SOA) should be the fundamental unit in your architectural design. A good application controller would be responsible for determining how to dispatch a given Command. Whether a Command pattern is used or whether service methods are invoked directly from your FrontController, the ApplicationController should enforce common service aspects. These include authentication, authorization, auditing, orchestration, validation, logging, error handling, just to name a few.
    The ApplicationController should ideally offload these aspects from a given service. The service would indicate how the aspects are to be applied (e.g., strong authentication required, x role required, fetching of existing process state, etc.) This allows services to be developed more quickly and to have these critical aforementioned aspects developed and tested centrally.
    Your FrontController, in contrast, is responsible for transforming whatever input it is designed to receive (HTTP form data posts, XML-RPC, etc.) and ensure that it honors the contract(s) that the ApplicationController establishes. There are no cut-and-dry decisions though about when a given piece of functionality should be ApplicationController or FrontController. Take error handling. Should I emit just a generic ServiceException or allow the FrontController to decide what to do with a more concrete checked exception? (The FrontController, in any case, should present the error to the user in a manner dictated by the protocol it serves).
    gniemcew wrote:
    4.) In the light of the (3.) above, I suspect that any failures in Request delegation, or Command execution, should be perhaps propagated back to a FrontController by exceptions only, since, say, a WebFrontController might want to show a click-through error page, when a SwingFrontController might prefer to show an error dialog box, a LogicalErrorViewEnumeration might not make sense at all in the context of a particular Client, for example a queueing Client.See above. Yes. However, the ApplicationController could easily 'hide' details about the failure. For example, any number of exceptions being mapped to a generic DataAccessException or even more abstractly to a ServiceFailureException. The ApplicationController could indicate whether the failure was recoverable and/or populate information necessary to speed up production support (e.g., mapping exceptions to error codes and/or providing a primary key in an error audit log table for support to reference). A given FrontController would present that information to the user in the method that makes sense (e.g., error dialog for Swing, error page for HTML, etc.)
    gniemcew wrote:
    5.) In the light of the (4.) above, there is the question of an appropriate Request interface (into an ApplicationController), an appropriate Response interface (back into a FrontController), as well as an appropriate ViewArguments interface (into a FrontController and later into a View). The problem with generic Requests is that they can be created with nonsensical argument combinations, so shouldn't Requests be abstract and force proper arguments in concrete subclasses, through explicit constructors (in a sense, degenerate Commands)? The problem with Responses and ViewArguments is that... well, I have not found any formal discussion anywhere as to what those should look like. In most samples I have encountered, Responses include Client-specific implementation details, as mentioned in (2.), above.See comment on marker interfaces above. Nothing, however, stops you from requiring a certain sub-type in a given service method. You can still pass in the interface and validate the proper type by an assert statement (after all, in the vast majority of situations, the proper service method should get the proper instance of a given Request object). IMO, the FrontController would create the Command instance which would be passed to the ApplicationController which would dispatch and invoke the proper service method. A model response would be received by the FrontController which would then render the appropriate view.
    gniemcew wrote:
    6.) Some CCS discussions seem to introduce a Flow Manager at the ApplicationController level. It seems puzzling to me, since the whole point of the Command and Controller Strategy flavor seems to be centralization of business logic execution within self-contained Command objects. Shouldn't Requests get associated with Handlers (objects capable of actually carrying out Requests) and transformed into Commands inside an ApplicationController, thus Commands themselves return appropriate LogicalViewEnumeration back to an ApplicationController, back to a FrontController? Let's consider a ShowMyShippingAddress request coming into the framework: unless such a Request is eventually treated as a Command returning a particular LogicalViewEnumeration, it is suddenly a Flow Manager "acting" as a business logic driver. I guess the question here is: except for a few special cases handled by a particular ApplicationController (authentication, error conditions, default behavior, etc.), should flow management be considered stand-alone, or always delegated to Commands?There are distinct kinds of flow management. For example, orchestration (or BPM) is properly at either the service or ApplicationController layers. However, determining which view to display is properly at the FrontController layer. The ApplicationController should receive a Command (with a populate Request) and return that Command (with a populated Response). Both the Request and Response are fundamentally model classes (within MVC). The FrontController is responsible for populating the Request and/or Command and rendering the Response and/or Command. Generic error handling is usually centralized for both controllers.
    gniemcew wrote:
    7.) Some CCS discussions seem to include an extra Request argument that specifies an ApplicationController to use (Request.Action="create", Request.Controller="account", Request.Username="me-me-me"), instead of using a Router inside of a FrontController to resolve to a particular ApplicationController through a generic action (Request.Action="createAccount", Request.Username="me-me-me"). I am not sure about the reason for such a design decision: why should a Client or a FrontController be allowed to concern itself with an implementation-level structure of the framework? Wouldn't any framework state -dependent ApplicationController resolution issues be best handled inside a Router, used by a FrontController to resolve [obtain] an appropriate ApplicationController, thus preventing Clients from ever forcing the framework into a possibly inconsistent behavior?I am not 100% sure of what you are getting at here. However, it seems to be the method by which commands are dispatched. They are in effect allowing a FrontController to dictate which of n ApplicationControllers should receive the request. If we allow a FrontController to directly invoke a service method, then the ApplicationController is simply a centralized framework that should always be invoked for each service method (enforced via AOP or some other mechanism). If there is a single, concrete ApplicationController which handles dispatch, then all FrontControllers communicate directly with that instance. It is really just a design decision (probably based on your comfort level with concepts like AOP that allow the ApplicationController to exist solely behind the scenes).
    I might have totally missed your questions, but those are my thoughts on a Monday. Best of luck.
    - Saish

  • Infinite loop error after using Java Sun Tutorial for Learning Swing

    I have been attempting to create a GUI following Sun's learning swing by example (example two): http://java.sun.com/docs/books/tutorial/uiswing/learn/example2.html
    In particular, the following lines were used almost word-for-word to avoid a non-static method call problem:
    SwingApplication app = new SwingApplication();
    Component contents = app.createComponents();
    frame.getContentPane().add(contents, BorderLayout.CENTER);I believe that I am accidentally creating a new instance of the gui class repeatedly (since it shows new GUI's constantly and then crashes my computer), possibly because I am creating an instance in the main class, but creating another instance in the GUI itself. I am not sure how to avoid this, given that the tutorials I have seen do not deal with having a main class as well as the GUI. I have googled (a nice new verb) this problem and have been through the rest of the swing by example tutorials, although I am sure I am simply missing a website that details this problem. Any pointers on websites to study to avoid this problem would be appreciated.
    Thanks for your time-
    Danielle
    /** GUI for MicroMerger program
    * Created July/06 at IARC
    *@ author Danielle
    package micromerger;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.swing.JFileChooser;
    import java.lang.Object;
    public class MGui
         private static File inputFile1, inputFile2;
         private static File sfile1, sfile2;
         private static String file1Name, file2Name;
         private String currFile1, currFile2;
         private JButton enterFile1, enterFile2;
         private JLabel enterLabel1, enterLabel2;
         private static MGui app;
         public MGui()
              javax.swing.SwingUtilities.invokeLater(new Runnable()
                   public void run()
                        System.out.println("About to run create GUI method");
                        app = new MGui();
                        System.out.println("declared a new MGui....");
                        createAndShowGUI();
         //initialize look and feel of program
         private static void initLookAndFeel() {
            String lookAndFeel = null;
         lookAndFeel = UIManager.getSystemLookAndFeelClassName();
         try
              UIManager.setLookAndFeel(lookAndFeel);
         catch (ClassNotFoundException e) {
                    System.err.println("Couldn't find class for specified look and feel:"
                                       + lookAndFeel);
                    System.err.println("Did you include the L&F library in the class path?");
                    System.err.println("Using the default look and feel.");
                } catch (UnsupportedLookAndFeelException e) {
                    System.err.println("Can't use the specified look and feel ("
                                       + lookAndFeel
                                       + ") on this platform.");
                    System.err.println("Using the default look and feel.");
                } catch (Exception e) {
                    System.err.println("Couldn't get specified look and feel ("
                                       + lookAndFeel
                                       + "), for some reason.");
                    System.err.println("Using the default look and feel.");
                    e.printStackTrace();
         // Make Components--
         private Component createLeftComponents()
              // Make panel-- grid layout
         JPanel pane = new JPanel(new GridLayout(0,1));
            //Add label
            JLabel welcomeLabel = new JLabel("Welcome to MicroMerger.  Please Enter your files.");
            pane.add(welcomeLabel);
         //Add buttons to enter files:
         enterFile1 = new JButton("Please click to enter the first file.");
         enterFile1.addActionListener(new enterFile1Action());
         pane.add(enterFile1);
         enterLabel1 = new JLabel("");
         pane.add(enterLabel1);
         enterFile2 = new JButton("Please click to enter the second file.");
         enterFile2.addActionListener(new enterFile2Action());
         pane.add(enterFile2);
         enterLabel2 = new JLabel("");
         pane.add(enterLabel2);
         return pane;
         /** Make GUI:
         private static void createAndShowGUI()
         System.out.println("Creating a gui...");
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            JFrame frame = new JFrame("MicroMerger");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         //Add stuff to the frame
         //MGui app = new MGui();
         Component leftContents = app.createLeftComponents();
         frame.getContentPane().add(leftContents, BorderLayout.WEST);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
    private class enterFile1Action implements ActionListener
         public void actionPerformed(ActionEvent evt)
              JFileChooser chooser = new JFileChooser();
              int rVal = chooser.showOpenDialog(enterFile1);
              if(rVal == JFileChooser.APPROVE_OPTION)
                   inputFile1 = chooser.getSelectedFile();
                   PrintWriter outputStream;
                   file1Name = inputFile1.getName();
                   enterLabel1.setText(file1Name);
    private class enterFile2Action implements ActionListener
         public void actionPerformed(ActionEvent evt)
              JFileChooser chooser = new JFileChooser();
              int rVal = chooser.showOpenDialog(enterFile1);
              if(rVal == JFileChooser.APPROVE_OPTION)
                   inputFile2 = chooser.getSelectedFile();
                   PrintWriter outputStream;
                   file2Name = inputFile2.getName();
                   enterLabel2.setText(file2Name);
    } // end classAnd now the main class:
    * Main.java
    * Created on June 13, 2006, 2:29 PM
    * @author Danielle
    package micromerger;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class Main
        /** Creates a new instance of Main */
        public Main()
         * @param args the command line arguments
        public static void main(String[] args)
            MGui mainScreen = new MGui();
            //mainScreen.setVisible(true);
            /**Starting to get file choices and moving them into GPR Handler:
             System.out.println("into main method");
         String file1Name = new String("");
             file1Name = MGui.get1Name();
         System.out.println("good so far- have MGui.get1Name()");
        }// end main(String[] args)
    }// end class Main

    um, yeah, you definitely have a recursion problem, that's going to create an infinite loop. you will eventually end up an out of memory error, if you don't first get the OS telling you you have too many windows. interestingly, because you are deferring execution, you won't get a stack overflow error, which you expect in an infinite recursion.
    lets examine why this is happening:
    in main, you call new MGui().
    new MGui() creates a runnable object which will be run on the event dispatch thread. That method ALSO calls new MGui(), which in turn ALSO creates a new object which will be run on the event dispatch thead. That obejct ALSO calls new MGui(), which ...
    well, hopefully you get the picture.
    you should never unconditionally call a method from within itself. that code that you have put in the constructor for MGui should REALLY be in the main method, and the first time you create the MGui in the main method as it currently exists is unnecessary.
    here's what you do: get rid of the MGui constructor altogether. since it is the implicit constructor anyway, if it doesn't do anything, you don't need to provide it.
    now, your main method should actually look like this:
    public static void main( String [] args ) {
      SwingUtilities.invokeLater( new Runnable() {
        public void run() {
          MGui app = new MGui();
          app.createAndShowGUI();
    }// end mainyou could also declare app and call the constructor before creating the Runnable, as many prefer, because you would have access to it from outside of the Runnable object. The catch there, though, is that app would need to be declared final.
    - Adam

  • Error calling WSDL Service in Swing application.

    I'm having the following error when calling a web service in a Swing Application.
    getUserInfo is defined and properly deployed. I tried several time to recreate WSDL cache and auto generated code, but nothing changed.
    Exception occurred during event dispatching:
    java.lang.Error: java.lang.reflect.InvocationTargetException
    Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jdesktop.application.ApplicationAction.noProxyActionPerformed(ApplicationAction.java:662)
        ... 88 more
    Caused by: java.lang.Error: Undefined operation name getUserInfos
        at com.sun.xml.ws.model.JavaMethodImpl.freeze(JavaMethodImpl.java:327)
        at com.sun.xml.ws.model.AbstractSEIModelImpl.freeze(AbstractSEIModelImpl.java:97)
        at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:268)
        at com.sun.xml.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:683)
        at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:340)
        at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:323)
        at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:305)
        at javax.xml.ws.Service.getPort(Unknown Source)
        at com.up4b.mercury.services.ServerManagerService.getServerManagerPort(ServerManagerService.java:56)
        at com.up4b.mercury.client.MercuryClientLoginBox.checkUser(MercuryClientLoginBox.java:139)
        ... 93 more

    OK.
    So here is an inside view of what I'm doing:
    Service is coded in a J2EE Web Application like this:
         * Web service operation
        @WebMethod(operationName = "userInfos")
        public Musers userInfos(@WebParam(name = "userId")
        Long userId) {
            return serverManager.getUserInfos(userId);
        }And in the client (Swing application generated by Netbeans) the code is:
    try { // Call Web Service Operation
                        com.up4b.mercury.services.CampaignManagerService service = new com.up4b.mercury.services.CampaignManagerService();
                        com.up4b.mercury.services.CampaignManager port = service.getCampaignManagerPort();
                        java.lang.Integer campaignId = client.getCampaignId();
                        java.util.List<com.up4b.mercury.services.Mstatus> result = port.getStatusList(campaignId);
                        Iterator iter = result.iterator();
                        String[] statusArray = new String[255];
                        statusArray[0] = "Sélectionner un statut";
                        int i = 1;
                        while (iter.hasNext()) {
                            com.up4b.mercury.services.Mstatus ts = (com.up4b.mercury.services.Mstatus) iter.next();
                            statusArray[i] = ts.getStatusSdesc();
                            i++;
                        status.setToolTipText("Statut de la fiche");
                        status.setModel(new javax.swing.DefaultComboBoxModel(statusArray));
                        status.setSelectedIndex(0);
                        // Reset pause mode to false and button to proper state
                        pauseButton.setSelected(false);
                        pauseButton.setText("Pause");
                        pauseState = false;
                    } catch (Exception ex) {
                        getClient().setIsActive(false);
                    }

  • Error while running Swing program on FreeBSD

    Hi,
    I am trying to run simple swing program "helloworld"
    but while executing it gives following error on FreeBSD
    Exception in thread "main" java.lang.UnsatisfiedLinkError:
    /usr/local/linux-sun-jdk1.4.2/jre/lib/i386/libawt.so: libXp.so.6:
    cannot open shared object file: No such file or directory
            at java.lang.ClassLoader$NativeLibrary.load(Native Method)
            at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1560)
            at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1477)
            at java.lang.Runtime.loadLibrary0(Runtime.java:788)
            at java.lang.System.loadLibrary(System.java:834)
            at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
            at sun.awt.DebugHelper.<clinit>(DebugHelper.java:29)
            at java.awt.EventQueue.<clinit>(EventQueue.java:80)
            at javax.swing.SwingUtilities.invokeLater(SwingUtilities.java:1170)
            at JPanels.main(JPanels.java:29)
    Should i install XFree86-libs package on FreeBsd
    configuration
    FreeBSD 4.10-BETA (GENERIC)
    I am using following packages
    linux-sun-jdk-1.4.2.04 Sun Java Development Kit 1.4 for Linux
    linux_base-8-8.0_4 Base set of packages needed in Linux mode (only for i386)
    linux_devtools-8.0_1 Packages needed for doing development in Linux mode
    libtool-1.3.5_1 Generic shared library support script
    gmake-3.80_1 GNU version of 'make' utility
    automake-1.4.5_9 GNU Standards-compliant Makefile generator (legacy version
    GCC 2.95.4
    gdb 4.18
    ld 2.12.1 supported emulation elf_i386
    regards
    Man479

    This is not really a Swing question. You should install the library which satisfies the lookup of libXp.so.6 .
    I quess the jre for this platform is compiled against this version. Looks to me like some X related library, maybe google can resolve a solution/package to install?
    Greetz

  • Error while deploying swing component to remote machine

    Hi,
    I have an unsolved query.I have created a simple Swing-frame using Jdeveloper.I have created a deployment profile which creates a jar file for the project.
    On executing the jar file I get an error of the manifest file which requires to change the details of the manifest file.Kindly send me how to overcome this problem through the Jdeveloper IDE itself rather than changing it manually.
    Thanks,
    [email protected]

    Hi,
    Are you trying to make an "exectable jar"? If so, on page 4 of the Deployment profile wizard, you will need to set the "Main Class" property to the full class name of the class in your project which contains the static main() method.
    Brian

  • Errors- Runtime() in Swing Help

    Hi, Iam trying to use Runtime() in Swing..iam getting nonsense errors what have i missed?
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class appSrunCommand extends JApplet implements Runnable,ActionListener{
         JLabel l1;
         JTextField tf;
         JButton run;
         JTextArea ta;
         JScrollPane jsp;
         String[] cmd = new String[4];
              public void init(){
                   l1 = new JLabel("Enter the command");
                   tf = new JTextField(10);
                   run = new JButton("Run");
                   ta = new JTextArea(20,20);
                   //jsp = getConentPane();
                   run.addActionListener(this);
                        Container con = getContentPane();
                        con.setLayout(new FlowLayout());
                        con.add(l1);con.add(tf);con.add(run);
                        con.add(ta);
                        public void actionPerformed(ActionEvent e){
                             String comm = tf.getText();
                             cmd[0]= "appSrunCommand";
                             cmd[1] = "cmd.exe";
                             cmd[2] = "/C";
                             cmd[3] = comm;
                             try{
                                  Runtime rn = Runtime.getRuntime();
                                  String temp = "";
                                  ta.setText(String.valueOf("Executing "+ cmd[0]+" "+cmd[1]+" "+cmd[2]+" "+cmd[3]));
                                  Process p = rn.exec(cmd);
                                  int exitVal = rn.waitFor();
                                  ta.setText(String.valueOf(exitVal));
                                  // any error message?
                StreamGobbler errorGobbler = new
                    StreamGobbler(rn.getErrorStream(), "ERROR");           
                // any output?
                StreamGobbler outputGobbler = new
                    StreamGobbler(rn.getInputStream(), "OUTPUT");
                // kick them off
                errorGobbler.start();
                outputGobbler.start();
                // any error???
                //int exitVal = rn.waitFor();
                             catch(Throwable t){
                                  ta.setText(String.valueOf(t));
    class StreamGobbler extends Thread{
                   InputStream is;
                   String type;
              //     Thread t = new Thread(this);
              //     t.start();
                        StreamGobbler(InputStream is,String type){
                             this.is = is;
                             this.type = type;
                                  public void run(){
                                       try{
                                            BufferedReader br = new BufferedReader( new InputStreamReader());
                                            String line = null;
                                            while((br.readLine())!= null)
                                            //ta.setText(String.valueOf(type+">"+ line));
                                            System.out.println(type+">"+line);
                                       catch(IOException ioe){}
                                       //     ta.setText(String.valueOf(ioe));
              Here are the errors..
    --------------------Configuration: <Default>--------------------
    C:\j2sdk\bin\appSrunCommand.java:11: appSrunCommand is not abstract and does not override abstract method run() in java.lang.Runnable
    public class appSrunCommand extends JApplet implements Runnable,ActionListener{
           ^
    C:\j2sdk\bin\appSrunCommand.java:45: cannot resolve symbol
    symbol  : method waitFor ()
    location: class java.lang.Runtime
                                                    int exitVal = rn.waitFor();
                                                                    ^
    C:\j2sdk\bin\appSrunCommand.java:49: cannot resolve symbol
    symbol  : method getErrorStream ()
    location: class java.lang.Runtime
                    StreamGobbler(rn.getErrorStream(), "ERROR");           
                                    ^
    C:\j2sdk\bin\appSrunCommand.java:53: cannot resolve symbol
    symbol  : method getInputStream ()
    location: class java.lang.Runtime
                    StreamGobbler(rn.getInputStream(), "OUTPUT");
                                    ^
    C:\j2sdk\bin\appSrunCommand.java:80: cannot resolve symbol
    symbol  : constructor InputStreamReader ()
    location: class java.io.InputStreamReader
                                                                    BufferedReader br = new BufferedReader( new InputStreamReader());
                                                                                                            ^
    5 errors
    Process completed.

    appSrunCommand is not abstract and does not override abstract method run() in java.lang.RunnableThis error message doesn't only tell you what's wrong, it also gives you hints about how to fix it. Why don't you read the messages?

  • Error with swing

    Hi,
    I am having the error with a basic start to a swing application, any hel;p would me much appreciated
    this is the error i keep receiving (it is not always child 11)
    Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: No such child: 11
    at java.awt.Container.getComponent(Unknown Source)
    at javax.swing.JComponent.rectangleIsObscured(Unknown Source)
    at javax.swing.JComponent.paint(Unknown Source)
    at javax.swing.JComponent.paintToOffscreen(Unknown Source)
    at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
    at javax.swing.RepaintManager.paint(Unknown Source)
    at javax.swing.JComponent._paintImmediately(Unknown Source)
    at javax.swing.JComponent.paintImmediately(Unknown Source)
    at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
    at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
    at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    The code to produce this error is as follows.
    import javax.swing.*;
    import java.awt.*;
    class play
    public monster monster_arr[]=new monster[30];
    int move_dirx;
    boolean game_playing=true;
    public play()
        for(int i=0,num=0,pos=0;i<30;i++)
            if(i%10==0) { num++; pos=0;}
            //new monster;
            monster_arr=new monster(pos,(num*50)+5);
    pos+=25;
    public void start_play()
    JFrame win = new JFrame("window");
    win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    win.setLocation(426,250);
    win.setSize(400,400);
    JPanel panel = new JPanel();
    JPanel bufpanel = new JPanel();
    //win.setDefaultL&F(true);
    //win.pack();
    win.setVisible(true);
    for(/*JPanel tmppanel=update_pane()*/int s=1;game_playing==true;/*tmppanel=update_pane()*/)
    //for(;;)
    /*if(i%5!=0) continue;
    else if(i>9999) i=0;*/
    try
    Thread.sleep(80);
    catch(Exception e)
    //System.out.println("i : "+i);
    //panel=tmppanel;
    panel = update_pane();
    //panel.updateUI();
    //win.remove(bufpanel);
    win.remove(panel);
    win.add(panel);
    //win.getContentPane().add(panel);
    win.validate();
    System.out.println("game over");
    public JPanel update_pane()
    JPanel pane = new JPanel(true);
    pane.setPreferredSize(new Dimension(400,400));
    pane.setLayout(null);
    pane.setBackground(Color.black);
    /*for(int i=0,num=0,pos=0;i<30;i++)
    if(i%10==0) { num++; pos=0;}
    monster_arr[i]= new monster(pos,(num*50)+5);
    pos+=25;
    if(monster_arr[9].getPosx()>=380)
    move_dirx=-1;
    incremnt_posy();
    else if(monster_arr[0].getPosx()<=0)
    move_dirx=+1;
    incremnt_posy();
    for(int i=0;i<30;i++)
    //System.out.println("i : "+i);
    monster_arr[i].setPosx(monster_arr[i].getPosx()+move_dirx);
    monster_arr[i].setBounds(monster_arr[i].getPosx(),monster_arr[i].getPosy(),20,29);// X , Y , Width , Heigh
    pane.add(monster_arr[i]);
    return pane;
    public void incremnt_posy()
    for(int i=0;i<30;i++)
    monster_arr[i].setPosy(monster_arr[i].getPosy()+5);
    if(monster_arr[i].getPosy()>351)
    game_playing=false;
    break;
    Monster Classimport javax.swing.*;
    import java.awt.*;
    class monster extends JLabel
    int posx, posy;
    //JLabel lab_img;
    int height, width;
    public monster(int x,int y)
    posx=x;
    posy=y;
    this.setIcon( new ImageIcon ("alien.gif"));
    public int getPosx()
    return posx;
    public int getPosy()
    return posy;
    public void setPosx(int x)
    posx=x;
    public void setPosy(int y)
    posy=y;
    Any assistance would be amazing i have come to a wits end
    Thanks for your time
    Edited by: mousehunt on Apr 2, 2009 4:51 AM
    Edited by: mousehunt on Apr 2, 2009 4:54 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Ok sorry i mark this as answered to get it out the way
    Thanks

  • Import javax.swing.* error

    Heya. I decided to learn java and i've been doing the tutorials, recently i started the swing tutorials and the learn by example page. However, whenever I try to import javax.swing.* it gives me an error. SO you know, i am using the J2SDK 1.4.2 and netbeans IDE 5.0. Here's the error text and what i type.
    import javax.swing.* ;
    the error is:
    illegal start of expression and then sometimes i get <identifier> expected.
    can anyone help me?

    To update. I figured out how to do this with a blank start file in netbeans, however it's awful to have to delete main and then make a new class file. So, is there anyway to get a blank template project or to import javax.swing.* without having to delete main and start with a blank file? SO, i guess my question has changed, but it's still about an import javax.swing.* error.
    thanks.

Maybe you are looking for