LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-23-2009, 07:46 AM   #1
siegel
LQ Newbie
 
Registered: Apr 2009
Posts: 1

Rep: Reputation: 0
Exception in thread "main" java.lang.StackOverflowError+ at sun.awt.Win32GraphicsConf


Hello,

i am beginner in Java Programming. I cannot find my problem (Exception in thread "main" java.lang.StackOverflowError). I did also in goolge, but without result.

Can somebody help me, please?

It would be great of you.

Yours,
sigi

import java.awt.Color;
import java.awt.Font;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class FrameBsp extends JFrame {

private static final long serialVersionUID = 1L;
private FrameBsp siegel = new FrameBsp();
private JLabel labelHallo = new JLabel("Ich bin ein Label!");
private JButton jButtonAbbrechen = new JButton();

FrameBsp() {

super("erster eigener Frame");
siegel.setSize(200, 400);
siegel.setBackground(Color.blue);
siegel.labelHallo.setBounds(80,140, 100, 50);
siegel.labelHallo.setFont(new Font("Serif", 1, 22));

siegel.jButtonAbbrechen.setBounds(80,140,180,130);
siegel.jButtonAbbrechen.setText("Ich bin wieder da!");
//Frame Layout
siegel.getContentPane().setLayout(null);
siegel.getContentPane().add(labelHallo);
this.siegel.getContentPane().add(jButtonAbbrechen);

siegel.setVisible(true);
//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {

FrameBsp framebsp = new FrameBsp();
}
}
 
Old 04-23-2009, 09:04 AM   #2
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 88
Quote:
Originally Posted by siegel View Post
private FrameBsp siegel = new FrameBsp();
Hi siegel,

The problem is the line shown above - you are instantiating the class outside a method, and then again in the main() method. Remove this line and all the uses of the siegel instance variable (or replace them with this and your code will work fine. you would need to add framebsp.setVisible(true) to main() before you see anything), though.

Oh, BTW, this post would have been better in the programming forum . Welcome aboard.

Last edited by Robhogg; 04-23-2009 at 09:06 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception in thread "main" java.lang.NoClassDefFoundError: org/aspectj/lang/Signature canonas Linux - Software 3 06-16-2008 05:00 AM
Exception in thread "main" java.lang.ClassFormatError: onmyown.Main (unrecognized cla zimboney Fedora 4 07-20-2007 02:00 PM
Exception in thread "main" java.lang.UnsupportedClassVersionError manolakis Programming 2 01-20-2007 11:56 AM
Java error "Exception in thread "main" java.lang.StackOverflowError" nro Programming 1 09-04-2004 04:47 AM
Exception in thread "main" java.lang.NoClassDefFoundError: Lobais Linux - Software 19 06-23-2004 09:42 AM


All times are GMT -5. The time now is 06:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration