JFrame applications problem

Hi, i'm just starting out writing swing applications and i'm having a few problems.
Don't bother answering this if you think i'm too stupid because i don't want to waste your time.
Whenever i write a swing application, it compiles but when i try to run it i get: <b>Exception in thread "main" java.lang.NoSuchMethodError: main</b>
Heres my code:
<code>
import java.awt.*;
import javax.swing.*;
public class swingframe extends JFrame
     private JButton but;
     public swingframe()
               Container c=getContentPane();
               c.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
               c.setBackground(Color.black);
               but = new JButton("Wyld Stallyns Rule!!!");
               but.setBackground(Color.green);
               c.add(but);
</code>
Sorry again if i'm wasting your time.
<b>Thanks</b>

import java.awt.*;
import javax.swing.*;
public class SwingFrame extends JFrame{
   private JButton but;
   public SwingFrame(){
      Container c=getContentPane();
      c.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
      c.setBackground(Color.black);
      but = new JButton("Wyld Stallyns Rule!!!");
      but.setBackground(Color.green);
      c.add(but);
      this.setSize(200, 200);
      this.setDefaultCloseOperation( EXIT_ON_CLOSE );
   public static void main(String []args){
      new SwingFrame().show();
}

Similar Messages

  • Premiere Elements 12: start application problem - an incompatible display driver massage

    Premiere Elements 12: start application problem - "an incompatible display driver" massage 
    I did everything what I could find online forums. (Except messing with BIOS settings)
    - Updated video cards drivers
    - Set to “High-Performance GPU” in Catalasyt for application exe and gpusniff.exe
    - Added “run as administrator” privileges
    - Each time before trying to run the application I removed BadDriver.txt file
    My laptop specification:
    Product name: HP Pavilion dv6 Notebook PC
    Intel(R) Core(TM) i7-2630QM CPU @ 2.00GHz
    System memory: 8GB
    Memory slot 1: 4GB SODIMM Samsung 1333MHz
    Memory slot 2: 4GB SODIMM Samsung 1333MHz
    Windows 7 Professional 64-bit Service Pack 1
    Intel(R) HD Graphics Family 8.882.2.3000 (30/09/2011)
    Radeon (TM) HD 6770M 8.882.2.3000 (30/09/2011) (newer updates are not available)
    please help...

    cmbishop82
    Did you go through the drill
    a. video card driver version up to date according to the manufacturer of the video card
    b. if so, deletion of the BadDrivers.txt file....for Premiere Elements 12 in Windows 7, 8, or 8.1 64 bit, the path is:
    Local Disk C
    Program Data
    Adobe
    Premiere Elements
    and in the Premiere Elements Folder is the BadDrivers.txt file for version 12. The BadDrivers.txt file is a file in this Premiere Elements Folder which also contains folders. You do not want anything in those folders. All you want is the BadDrivers.txt file in the Premiere Elements Folder.
    Make sure that you have Folder Option Show Hidden Files, Folders, and Drives active so you can see that complete path.
    The rationale for the being of the BadDrivers.txt file has its origins in post 10 of the following older thread
    http://forums.adobe.com/message/3177024
    When you get the display card error message, is it before you import media into the project? And, when you get the message, does the program allow you to continue by pressing a Continue Button or are you stopped from going further?
    ATR

  • Tomcat Server Closes with JFrame Application

    When I open my JFrame Application, and decide to close it this application of mine closes together with my tomcat server... I suspect is the "System.exit(0);" in my JFrame application that causes it.
    Can anyone tell me what I should do to my JFrame application so when I closes it, it will not close my Tomcat server at the same time.
    Thank You : )
    Regards,
    RainbowEnergies

    It probably is the System.exit(0); You should remove that.
    Tomcat is a container which essentially means it's a sort of "main program" that calls your servlets, JSP programs, etc. as "subroutines". When a subroutine calls "exit", the main program will shutdown.
    If you need the JFrame to "exit" when it's being run independently of Tomcat, move the System.exit() call to the "public static void main()" method. Tomcat will never call your class's "main" method, since it uses its own.

  • N82 application problems

    Hello everyone. I bought N82 a few days ago and I have an application problems. My installed applications works for 6-7 hours. I can see them in applications folder and application manager. But 7 hours later, I can't see them in applications folder also application manager. Why it happens? Please help me!
    I tried those but I can't solved this problem:
    Soft format
    Hard format
    Reinstall N82's software ( V31) with Nokia Software Updater
    Formatting memory card and reinstall applications.
    Note: I don't have this problem with my videos and musics .Only applications. 
    Solved!
    Go to Solution.

    Finally I solved this problem. I bought a new memory card and then installed my app.I think Nokia's 2GB memory card have a problem. (System folder.)

  • Applications problem: "You cannot update this software since you have not owned the major version of this software."

    Hi all,
    RE: Applications problem: "You cannot update this software since you have not owned the major version of this software."
    Until recently, I have not encountered this problem.  And I am facing this problem for both my iPad and iPhone. 
    I only have 1 iTunes account and the most recent change was that I switched the location from Singapore to UK (I'm currently in the UK).  I also updated my applications a couple of times before since the change in location, so I doubt it's due to the location change.  I've tried signing out of the account in the iTunes accounts on the devices, then signing back in.  I've also tried restarting the devices (and for the iPad, I even updated the iOS). 
    Any idea what else I can do to try to rectify this?
    Thanks and regards,
    Tammy

    Hi there!
    Thanks for replying!
    1.  Yup, my iOS is the latest (6.0.1), and I have 7 apps on my iPhone that apparently have updates.  But it's been 6.0.1 for quite some time and I've also been able to update the apps till just this week.
    2.  I don't have a credit card associated with my account anymore.  Ever since I changed the location, I removed the credit card details.  But I didn't have problems with any of my apps (updating or downloading new ones) until this week.  Also, all the apps I've downloaded since I came to the UK are free apps. 
    I still don't know what's wrong. 

  • Java application problem

    I am using JDK1.4 and working on Windows Xp.
    I have written a code for application in java as follows:
    import javax.swing.*;
    public class sample
    JPanel panel;
    static JFrame frame;
    JButton but;
    public sample()
    frame=new JFrame("frame");
    panel=new JPanel();
    frame.getContentPane().add(panel);
    but=new JButton("click");
    panel.add(but);
    public static void main(String args[])
    sample s=new sample();
    frame.setSize(300,300);
    frame.setVisible(true);
    on executing program application window has appeared and it ran properly.
    Then I closed that application window.But after that in command prompt window curser was just blinking and it was not allow to enter also.
    I have tried pressing CTRL+C also.But situation in command prompt was same i.e curser in command prompt was just blinking.
    Then I closed cmd window ;but one error has occured saying that cmd window can not close .
    My friend has told me that she is also having windows xp and JDK1.4 ; ctrl+c is working properly in her command prompt.She has written the above same code in her computer and it executes properly.
    Even though she has not written following statement:
    "frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);"
    when she exits from application window ,her cmd window gave same problem of only blinking curser.But when she press CTRL+C ; her command prompt starts responding by giving root.But my command prompt is not giving
    positive responce to "ctrl+c" when I am exiting java application.
    Is it possible to solve this problem without giving statement
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ?
    Why my command prompt is not responding to CTRL+c?
    How can I tackle this problem ?
    Is there any other key which can be used in command prompt of Windows Xp?

    Is it possible to solve this problem without giving
    statement
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    ?this is because Swing have started some non-daemon helper threads for its internal purposes and the default close operation for frame is just HIDE_ON_CLOSE. So, the system will not exit because those non-daemon thread still not terminated.
    What is the problems setting the default close operation to JFrame.EXIT_ON_CLOSE ?

  • Java Swing application problem in Windows vista

    When we execute the Swing application in windows vista environment.
    The look and feel of the swing components are displayed improperly.
    Do we need to put any specific look and feel for windows vista environment or any specific hardware configuration is required to setup windows vista environment.
    Please give some inputs to solve the problem.
    We have tried with the following sample code to run in windows vista.
    * Vista.java
    * Created on December 5, 2006, 5:39 PM
    public class Vista extends javax.swing.JFrame {
    /** Creates new form Vista */
    public Vista() {
    initComponents();
    pack();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
    jButton1 = new javax.swing.JButton();
    jToggleButton1 = new javax.swing.JToggleButton();
    jPanel1 = new javax.swing.JPanel();
    jCheckBox1 = new javax.swing.JCheckBox();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTextArea1 = new javax.swing.JTextArea();
    jTextField1 = new javax.swing.JTextField();
    getContentPane().setLayout(null);
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jButton1.setText("Button 1");
    getContentPane().add(jButton1);
    jButton1.setBounds(20, 20, 170, 30);
    jToggleButton1.setText("Togle btn");
    getContentPane().add(jToggleButton1);
    jToggleButton1.setBounds(100, 80, 90, 20);
    jPanel1.setLayout(null);
    jCheckBox1.setText("jCheckBox1");
    jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    jCheckBox1.setMargin(new java.awt.Insets(0, 0, 0, 0));
    jPanel1.add(jCheckBox1);
    jCheckBox1.setBounds(10, 40, 130, 13);
    getContentPane().add(jPanel1);
    jPanel1.setBounds(10, 150, 200, 130);
    jTextArea1.setColumns(20);
    jTextArea1.setRows(5);
    jScrollPane1.setViewportView(jTextArea1);
    getContentPane().add(jScrollPane1);
    jScrollPane1.setBounds(210, 150, 164, 94);
    jTextField1.setText("jTextField1");
    getContentPane().add(jTextField1);
    jTextField1.setBounds(240, 30, 140, 30);
    pack();
    }// </editor-fold>//GEN-END:initComponents
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new Vista().setVisible(true);
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JToggleButton jToggleButton1;
    // End of variables declaration//GEN-END:variables
    }

    When we execute the Swing application in windows
    vista environment.
    The look and feel of the swing components are
    displayed improperly.Improperly means what? You must be aware that Vista's native L&F certainly isn't supported yet.

  • JFrame minimizing problem

    I am writing an application where i have many JFrames on the screen at the same time. The problem is that when i click on a menu item in one of the screens the rest of them get minimized. Is there any way of preventing this without using JInternalFrames.

    can you please supply source code, I may not be able to help but other's can.

  • JFrame Repaint problem

    I am new to Java Swing and I have a problem.
    I have a GUI program which extends JFrame and contains some business logic. In the middle of executing the business logic, I need to display a chart and I used another JFrame to display the chart. The chart did display but once the control return back to the original process, the chart Jframe turn blank. How can I get the display of the chart until user closes it?
    public class ChangeMetric extend JFrame implements ActionListener {
    public void actionPerformed(ActionEvent event) {
    JFrame jf = new JFrame();
    JPanel jp = new JPanel();
    jp.setSize(500,500);
    jf.getContentPane().add(jp);
    jf.setVisible(true);
    JOptionPane.showConfirmDialog(null, "Report has been saved to : " + path + "\n " +
                   "Do you want another report?", "Completed", JOptionPane.YES_NO_OPTION);
    //Jf turn blank after the JoptionPane displayed.
    Thanks in advance.
    Alex

    I need to display a chart and I used another JFrame to display the chart.An application should only have a single JFrame. Use a JDialog instead. You create it the same way you do a JFrame, the only difference is you specify the frame as the owner.
    Jf turn blank after the JoptionPane displayed.Then you must be doing something really wierd in your code. There is no reason for the option pane to have any effect on your dialog.
    And when you post your SSCCE, don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • JFrame.setSize() problem

    I'm facing a strange problem. I have a class derived from JFrame which is the main application frame window. Problem is I'm not able to set its size arbitrarily e.g. in following call to setSize(...) even if I replace 700 with 100 OR 1000 or whatever, the frame is always displayed of some fixed size . I can't find out why .. any clues ?
    JGuessFrame() {
    this.setSize(700, 700);   
    // Center the window on the screen
    setLocationRelativeTo(null);
    setDefaultLookAndFeelDecorated(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    try this:
    JGuessFrame() {
    this.setSize(700, 700);
    // Center the window on the screen
    setLocationRelativeTo(null);
    setDefaultLookAndFeelDecorated(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.pack(); // maybe this will help
    // if not then try this
    this.repaint();

  • Components getting distorted when the JFrame application is minimized

    Hello,
    I have developed a GUI application using Net Beans, the JFrame has a panel which has a JButton, JTextField, image icon (using label) and few other label's, when i click the button the text fields, image icon, button relocate using setBounds function and another panel is added dynamically which in turn contains few labels. When i click any of the label it will play music in real player software.
    But when i click any label the real player opens and the music is played but after clicking when i minimize the JFrame window the components are getting distorted.
    How to solve this problem.
    i have used
    java.swing.* package and
    java.awt.Desktop package for opening the music file in real player.
    Regards,
    Sandeep.

    Hello dvrsandeep,
    Maybe, you should not relocate your components using setBounds function. Use a LayoutManager Instead.

  • Designing JFrame Application in better way

    I am going to start the design of a Kiosk Based Application which consists of nearly dozens of screen and the application must be full screen and undecorated. In this situation what will be the best GUI design strategy?
    1) I have designed 3-4 screens using MVC style which uses JFrame. But while moving from one JFrame screen to another it flickers and shows the background and the switching is slow.
    2) Can I use JPanel in each screen design (this JPanel will have GUI for one screen) and set them visible as per the condition on single JFrame. Will this technique will be efficient or can I face any problem in future due to design of GUI only on one JFrame.

    This is the demonstration code on which I am working.
    In this application while moving from second to third screen flickering occurs while in other case the transition is smoother the problem is between second and third frame. How to avoid this, any tick? or by adding sleep?
    import java.awt.BorderLayout;
    import java.awt.EventQueue;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.HashMap;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    public class FrameExample {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    Controller      viewController      = new Controller();
                    MainView      main                = new MainView(viewController);
                    DetailView      detail                = new DetailView(viewController);
                    ThirdView      Third_Screen     = new ThirdView(viewController);
                    viewController.showView("Main");
        static class Controller {
            HashMap<String,JFrame> views;
            public Controller(){
                views = new HashMap<String,JFrame>();
            public void registerView(String name, JFrame view){
                views.put(name,view);
            public void showView(String name){
                if (views.containsKey(name)){
                    for (String key : views.keySet()){
                        views.get(key).setVisible(key.equals(name));
        static class MainView extends JFrame {
            final Controller viewController;
            public MainView(Controller controller){
                super();
                this.viewController = controller;
                setTitle("Main");
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                getContentPane().setLayout(null);
                JButton button = new JButton("Frame 1--Show Detail");
                button.setBounds(300,300,160,80);
                button.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                     try{
                     viewController.showView("Detail");                                 
                    //Thread.currentThread().sleep(100);               
                    }catch(Exception e1){}
                getContentPane().add(button, BorderLayout.SOUTH);
                setSize(1024, 786);
                setUndecorated(true);
                viewController.registerView(getTitle(), this);
        static class DetailView extends JFrame {
            final Controller viewController;
            public DetailView(Controller controller){
                super();
                this.viewController = controller;
                setTitle("Detail");
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                getContentPane().setLayout(null);
                JButton button = new JButton("Frame 2--Show ThirdView");
                button.setBounds(300,300,160,80);
                button.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        try{                         
                     viewController.showView("Third_Screen");                 
                   // Thread.currentThread().sleep(400);
                    }catch(Exception e2){}
                getContentPane().add(button, BorderLayout.SOUTH);
                setSize(1024, 786);
                setUndecorated(true);
                viewController.registerView(getTitle(), this);
        static class ThirdView extends JFrame {
            final Controller viewController;
            public ThirdView(Controller controller){
                super();
                this.viewController = controller;
                setTitle("Third_Screen");
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                getContentPane().setLayout(null);
                JButton button = new JButton("Frame 3--Show Main");
                button.setBounds(300,300,160,80);
                button.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        try{                         
                     viewController.showView("Main");                 
                    //Thread.currentThread().sleep(100);
                    }catch(Exception e2){}
                getContentPane().add(button, BorderLayout.SOUTH);
                setSize(1024, 786);
                setUndecorated(true);
                viewController.registerView(getTitle(), this);
    }

  • Modal dialog to a JFrame creates problem in windows XP

    I have a problem with JDialog(modal) when it is set to a JFrame.
    It works when the focus is on the dialog.
    If some other application is selected from the taskbar of the windows XP and selecting back the JFrame, the dialog is not poping up on to the frame but it is hided. The dialog can be accessed by selecting Alt+Tab.
    Any solution for this.Pl help.

    hi!
    you need to create a Short, Self Contained, Compilable and Executable, Example Program that demonstrates the incorrect behaviour, so that any one can easily understand where you are doing a mistake.
    And don't forget to use the Code Formatting Tags so the code retains its original formatting.
    :)

  • JFrame Closing problem in windowClosing event!

    Hi,
    I have a small question and need your help to solve this. I have a JFrame and I have overriden it's windowClosing method. Now Inside this method I pop a message and asks user if they really want to quit. If YES is clicked the Application exits and on any other click I just keep the JFrame showing. But whenever the user clicks NO or click the CLOSE BUTTON the Application doesn't exits but the JFrame hides and have no way to show it again. Here is code snippet:...
    frame.addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent e)
    int confirm = 0;
    confirm = JOptionPane.showOptionDialog(null,"Close","Close",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null, null, null);
    if(confirm == 0) //yes
    System.out.println("**** CLOSING THE JFRAME");
    System.exit(0);
    else
    //Here I still the JFrame is hidding itself as I want to stay it
    //visible.
    System.out.println(" DO NOT CLOSE THE JFRAME");
    return;                              
    How can I get arround this problem. I just want to exit the Application if the YES BUTTON is clicked else I want to keep the Application running and showing.
    Thanks for any help

    Use the windowClosing() method instead. When using it, if you don't call window.setVisible( false ), it won't get closed.myFrame.addWindowListener( new WindowAdapter() {
        public void windowClosing( WindowEvent we ) {
            int result = JOptionPane.showConfirmDialog( myFrame,
                "Are you sure you want to close the window?", "Close", JOptionPane.YES_NO_OPTION );
            if( result == JOptionPane.YES_OPTION ) {
                myFrame.setVisible( false );
    });

  • JFrame setlocation problems on linux

    When you drag a JFrame, you can move it anywhere you want, even if some of its boundary goes outside the screen...
    Fortunately It's true on windows, mac and linux SUN JREs.
    On windows and mac, you get the same effect if you decide to do it programatically with for example :
    package testframe;
    import javax.swing.JFrame;
    public class Main {
        public static void main(String[] args) {
        JFrame jf=new JFrame();
        jf.setVisible(true);
        jf.setSize(400, 400);
        jf.setLocation(-300, 50);
    }But this code doesn't work as expected on linux distros. I tried on kde, gnome and xfce, and I always get the same problem : the JRE (probably because of calls to window manager) refuses to place the window a little bit outside the screen boundaries. So in my example, jf.setLocation(-300,50) have the same effect as jf.setLocation(0,50).
    Of course, when the windows appear at the (0,50) coordinates, it's always possible on linux to move it manually to a negative x-coordinate place.
    setBounds method will lead to the same trouble...
    Of course this piece of code is only here to show exactly what's wrong on linux sun jre's. In my "real code", I need to deal with undecorated Jframes, so I have to manage myself the mousepressed and mousedragged events on my custom titlebar, and I would really want the linux version of my application behave the same as windows and mac versions ...
    The weird thing is that if I try to do that with JWindows in place of JFrames, it work's fine on Linux as well. But the problem is not here : in my case I need JFrames...
    Anyone knows how to fix this on linux ?

    When you drag a JFrame, you can move it anywhere you want, even if some of its boundary goes outside the screen...
    Fortunately It's true on windows, mac and linux SUN JREs.
    On windows and mac, you get the same effect if you decide to do it programatically with for example :
    package testframe;
    import javax.swing.JFrame;
    public class Main {
        public static void main(String[] args) {
        JFrame jf=new JFrame();
        jf.setVisible(true);
        jf.setSize(400, 400);
        jf.setLocation(-300, 50);
    }But this code doesn't work as expected on linux distros. I tried on kde, gnome and xfce, and I always get the same problem : the JRE (probably because of calls to window manager) refuses to place the window a little bit outside the screen boundaries. So in my example, jf.setLocation(-300,50) have the same effect as jf.setLocation(0,50).
    Of course, when the windows appear at the (0,50) coordinates, it's always possible on linux to move it manually to a negative x-coordinate place.
    setBounds method will lead to the same trouble...
    Of course this piece of code is only here to show exactly what's wrong on linux sun jre's. In my "real code", I need to deal with undecorated Jframes, so I have to manage myself the mousepressed and mousedragged events on my custom titlebar, and I would really want the linux version of my application behave the same as windows and mac versions ...
    The weird thing is that if I try to do that with JWindows in place of JFrames, it work's fine on Linux as well. But the problem is not here : in my case I need JFrames...
    Anyone knows how to fix this on linux ?

Maybe you are looking for

  • Macbook Pro's keyboard is typing random letters/symbols- can't figure out- HELP!

    OK, so everything was just fine, worked wonderfully, then I found my little chihuahua puppy walking on the keyboard, she is very tiny, so not heavy at all, & I caught it pretty quick... I DID see she may have had a little bit of wetness on the bottom

  • Spotlight doesn't find search results in .HTML file contents

    When I use Spotlight to search, it doesn't find any .HTML file contents. If I rename an .HTML file to use a .TXT extension, the contents are found. Is there a way to enable Spotlight to find contents in .HTML files?

  • Material with flag for deletion are not getting deleted

    Hi All, Classic Scenario ERP - Materials were marked for deletion on the client level SRM - COMMPR01 - Materials are marked for deletion Question - When we ran BBP_CCM_Transfer_Catalog and Publish the Master Catalog the materials are not getting dele

  • ITunes lip-syncing issues,

    Hi there, I was wondering if anyone can help me. I have recently bought a new laptop (inspiron 17R special edition) because of its supposed brilliance in media centre. However I have downloaded iTunes and my movies and the lip syncing is all out, I h

  • Photoshop crashes when dragging a layer

    Hello, I've been having an intermittent issue with dragging layers.  in the layers pallet - ps crashes It was doing this in CS3, and the started in CS4. Here's part of the crash report - Thread 0 Crashed: 0   com.apple.QD                  0x9129a288