Error after compiling because of scroll

I would like to get scrollbars (vertical and horizontal) after doing the Pascal's Triangle that appends in the JTextArea named "prog", inside the JPanel "dret".
I've tried lots of things in teh code, but I get, after compiling:
"Exception in thread "main" java.kang.IllegalArgumentException: adding container's parent to itself
at java.awt.Container.addImpl(Container.java:309)
at java.awt.Container.add(Container.java:210)
at cerni.<init>(cerni.java:218)
at cerni.main(cerni.java:261)
Here the java code:
import java.lang.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.IOException.*;
import javax.swing.text.*;
import java.util.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class cerni extends JFrame {
     //declaraci� de variables.
     JPanel principal, centre, esquerre, dret, intro, esquerrealt, esquerrebaix;
     JButton element2, element3, element4, element6;
     JTextArea prog;
     JTextField element1, element5, introtext;
     static String newline = System.getProperty("line.separator");
     //funci� binominal.     
     public static int binominal (int n, int p) {
          if (p * (n-p) == 0)
               return(1);
          else
               return(binominal(n-1, p-1) + binominal(n-1,p));
     //funci� cerni.
     public cerni() {
          //t�tol.
          super(" �-_JavaPascal_-`");
          //definici� de variables.
          principal = new JPanel();
          centre = new JPanel();
          esquerre = new JPanel();
          dret = new JPanel();
          intro = new JPanel();
          esquerrealt = new JPanel();
          esquerrebaix = new JPanel();     
          element2 = new JButton("Informaci�");
          element4 = new JButton("Fer el triangle");
          element3 = new JButton("Sortir");     
          element6 = new JButton("Netejar la pantalla");          
          element1 = new JTextField("");
          element5 = new JTextField(" Entreu el valor d' n+1 files del triangle de Pascal.");
          introtext = new JTextField(" Benvinguts al programa JavaPascal, el programa escrit i compilat en java que dibuixa el triangle de Pascal.");
          prog = new JTextArea();
          //propietats de texts.
          introtext.setFont(new Font("Serif", Font.ITALIC, 16));          
          prog.setFont(new Font("Serif", Font.ITALIC, 16));
          prog.setLineWrap(true);
          prog.setCaretPosition(prog.getText().length());
          element5.setEditable(false);
          introtext.setEditable(false);
          prog.setEditable(false);
          //minimissatge del principi.          
          JOptionPane.showMessageDialog(principal, " Benvinguts al programa JavaPascal.", " -> Bon dia!! <- ",JOptionPane.INFORMATION_MESSAGE);
          //bot� netejar.
          element6.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent e){
                    String o = new String();
                    prog.setText(o);
          //bot� informaci�.
          element2.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent e){
                    JOptionPane.showMessageDialog(principal, "El programa JavaPascal ha estat escrit per Cerni Pol durant els dies 11 i 12 de maig del 2002.\nAmb una estructura de JFrame i JPanels, m�s JButtons i components de text, l'aplicaci� en q�esti� us exposar�\nel triangle de Pascal, en tantes files com li demaneu, al camp de text de la dreta.\nNo �s recomanable demanar un n m�s gran de 25, per aix� tenir un millor rendiment en l'operaci� de la compu-\ntadora. (rendiment provat en un processador Pentium2 a 450 mhz)\nQue us ho passeu b� amb aquest programa.\n(Enjoy.)");
          //bot� sortir.
          element3.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent e){
                    System.exit (0);
          //bot� pascal.
          element4.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent e){
                    int n, p, c;
                    c = 10;
                    String s1 = element1.getText();
                    c = Integer.parseInt(s1);
                    n = 0;
                    p = 0;
                    for (n=0; n<c+1; n++){
                         prog.append(cerni.newline);
                         for (p=0; p<n+1;p++){
                              String s = Integer.toString(binominal (n,p));
                              prog.append(s);
                              prog.append(" ");
               prog.append(cerni.newline);     
          //panell esquerrealt.
          esquerrealt.setLayout(new GridLayout(4, 0));
     esquerrealt.setBorder(BorderFactory.createEmptyBorder(
     30, //top
     20, //left
     40, //bottom
     20) //dret
          esquerrealt.add(element5);
          esquerrealt.add(element4);
          esquerrealt.add(element1);
          esquerrealt.add(element6);
          //panell esquerrebaix.
          esquerrebaix.setLayout(new GridLayout(0, 2));
          esquerrebaix.setBorder(BorderFactory.createEmptyBorder(30, 30, 20, 30));
          esquerrebaix.add(element2);
          esquerrebaix.add(element3);     
          //panell esquerre.
          esquerre.setLayout(new BorderLayout());
          esquerre.add(esquerrealt, "North");
          esquerre.add(esquerrebaix, "South");
          JScrollPane dretScrollPane = new JScrollPane(dret);
          dretScrollPane.createVerticalScrollBar();
          dretScrollPane.createHorizontalScrollBar();          
          dretScrollPane.setVerticalScrollBarPolicy
          (JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
          dretScrollPane.setHorizontalScrollBarPolicy
          (JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
          dret.add(dretScrollPane);          
          //panell dret.          
          dret.setLayout(new BorderLayout());
          dret.add(prog, "Center");
          //panell centre.
          centre.setPreferredSize(new Dimension(800, 700));
          centre.setBorder(BorderFactory.createEmptyBorder(30, 30, 20, 30));     
          centre.setLayout(new GridLayout(0, 2));
          centre.add(esquerre);
          centre.add(dret);     
          //panell intro.          
          intro.setLayout(new BorderLayout());
          intro.add(introtext, "Center");
          //panell principal.
          principal.setLayout(new BorderLayout());
          principal.setBorder(BorderFactory.createEmptyBorder(30, 30, 20, 30));
          principal.add(centre, "Center");
          principal.add(intro, "North");
          setContentPane(principal);
     //main.     
     public static void main (String[] args) {
          JFrame principal = new cerni();
          principal.addWindowListener (new WindowAdapter () {
               public void windowClosing (WindowEvent e) {System.exit(0);}
     principal.show();
     principal.pack();
     principal.setSize(800, 700);
Thanks to help me.

Hi...
The line is error is below...
dret.add(dretScrollPane);You've already added dret to the scrollpane in the constructor of the scrollpane (some 6/7 lines above the line above). Simply add the scrollpane to the main frame (pane) now.
Merry Christmas

Similar Messages

  • How to see errors after compilation.

    Hello,
    I am new to SQL/Developer.
    How do we check the errors after running the script in sql/developer.
    Warning: execution completed with warning.
    I tried show errors but its not working.
    Please help.
    Thanks,
    Srikanth

    Hi,
    After you run your script, you execute show errors.
    Reagrds Salim.
    SQL> create or replace function ff return number
      2  is
      3  begin
      4  dbms_output.put_line(pp);
      5  end ;
      6  /
    Warning: Function created with compilation errors.
    SQL> show errors;
    Errors for FUNCTION FF:
    LINE/COL ERROR
    4/1      PL/SQL: Statement ignored
    4/22     PLS-00201: identifier 'PP' must be declared
    SQL>

  • Strange ora-1403 and 6508 errors after compiling forms in 10.1.2.0.2

    Hi, today we migrated our Application Server to 10.1.2.0.2 and totally unexpected (it was not mentioned in the upgrade guide of 400 pages...) we had to recompile all 9.0.4-executables
    So we installed Developer Suite 10.1.2.0.2 and recompiled all libraries, forms and menus. There were no errors reported, so everything should be valid.
    Now we can run the forms again - that is, they start without problems - but on some forms (so not all), after doing Run Query, we immediately get ORA-1403, followed by ORA-6508.
    Could this perhaps be caused by "something" in the Headstart-libraries that can not be used in 10.1.2?
    A quick respons would be perfect, because many users have problems now.
    Regards, JW

    Hi Josef,
    indeed i recompiled them all and the errors are raised in development (running standalone oc4j) and production environment (application server 10.1.2).
    Currently i'm migrating the forms to Headstart 65401 and i will update this thread with the results. I guess/hope that the obsolete forms functions/procedures caused these errors.
    Thanks, JW

  • Error after compiling DFF at Title: Additional Header Information

    Hi All,
    The following error message is apeared after creating DFF at Title: Additional Header Information
    "The descriptive flexfield "Additional Header Information" of application "Order Management" uses features which are only supported in oracle forms. This flexfield may not function in other environment such as OA Framework or PL/SQL APIs."
    The numbers of warning messages: 3
    Can anyone advice please? Will this problem affect customizations?
    Best Regards,
    Hans Chang

    Hi everyone
    The issue is solved and here is the answer.
    "Logon to Oracle E-Business Suite.
    Go to System Administrator (or System Administration) --> Oracle Applications Manager --> License Manager
    In the license manager screen click on the link Languages.
    Click on the NEXT button.
    Verify whether American English is set as Base Language
    If American English is not set as Base Language. Select American English Radio button in the Lower part of the screen. Click on the Submit button."
    Thanks
    Engin

  • Error after compile Exception in thread "main" java.lang.NoClassDefFoundErr

    Hi I am very new to Java programming, right now I am using a mac os 10.49
    I can create java documents using bbedit and then they compile when i type
    javac.
    But when i type java *.java I get the following error
    Exception in thread "main" java.lang.NoClassDefFoundError
    If I type java "filename"
    without the .java at the end of the file the terminal has no response
    I understand i am supposed to some how set the classpath but i do not know how to do this
    Also I can create and compile and then run my java in the eclipse program that i have installed, but not from terminal and im not sure why.
    Thanks for the help.

    I understand i am supposed to some how set the classpath but i do not know how
    to do thisThere is no need to set a system variable CLASSPATH, it is inflexible to do so, and it can lead to unpredictable behaviour.
    You should be able to compile and run programs from the command line, specifying the classpath as part of the commands you use.
    (1) For instance, you can create a file HelloWorld.java with the following contents:public class HelloWorld {
        public static void main(String args[]) {
            System.out.println("Hello world");
    }(2) From the command line (console) navigate to the folder (directory) containing this file and compile it with the commandjavac -cp . HelloWorld.javaThe "-cp ." part is what specifies the classpath. Note that it is a file that is being compiled so we specify the actual file name including the extension. At this point you should be able to check that the HelloWorld.class file has been created.
    (3) From the same folder (directory) you run the program withjava -cp . HelloWorldThe classpath is being specified in the same way as before. It is a class that is being invoked, so we don't specify a filename. (much less use wildcards like *).
    Documentation for the java and javac tools (and others) are linked to from this page: http://java.sun.com/javase/6/docs/index.html

  • How do i get error after compiling package

    Hi ,
    i am compiling some packages by sys schema of hr schema as
    alter package hr.example compile package
    but it shows compiled with error
    how can i see that errors as i dont know the password of hr schema ..
    Thanks in advance

    First of all you should not be using SYS to compile anything ... create a DBA account.
    Second there is not need to be HR to see the errors ... type "SHO ERR" and you should see the errors and if that does not work there is always the simple
    SELECT * FROM dba_errors;In the future please do not post questions without full version number and, when possible, screen scrapes (cut and paste) so we can see what you are doing.

  • Runtime error after compiling and linking functions containing XDK calls

    We have a preexisting application in C distributed across multiple shared objects - on HPUX.
    $ORACLE_HOME/xdk/include was included in the include path and the programs were compiled. Linking also was successful.
    However at runtime we get errors of the form:
    /usr/lib/dld.sl: Unresolved symbol: XmlCreate__FP6xmlerrPUce (code) from ./lib_my_so_name.so
    Clearly it's not able to locate the shared libraries corresponding to the xdk since XmlCreate() is not getting resolved.
    Where would these libraries be, what are their names on HPUX, and are they installed by default? If not is the installation procedure documented anywhere.
    We'll need this information for both HPUX and AIX.

    * Don't post that much code. There should never be a reason to. You should be able to break your code down into small enough pieces that you can post a small example that demonstrates your problem.
    * When you do post code, use [code] and [/code] tags to make it readable. You can use the code button on the message entry page.
    * The stack trace will tell you which line the NPE occurred on, where it was called from, where that was called from, etc. You can use that to help you find your error. Look at the line it's complaining about. What references are on that line followed by a dot, and what arrays do you try to access the elements of. One of those must be null.
    * Now that you know what[b] is null, put in a bunch of print statements to track [b]how it got to be null.

  • ERROR AFTER COMPILING

    I have writted a vi that runs correctly in design mode and runs
    correctly when compiled and installed on a hard drive that has LabVIEW
    also installed on it.
    When I try to run the compiled program on a computer that does not have
    LabVIEW resident on the hard drive the program does not run and I get
    the following error message:
    ERROR -1073807202 occured at in SpecanRemoteOp.vi
    Possible reasons:
    VISA: (Hex 0xBFFF009E) A code library required by VISA could not be
    located or loaded
    Am I missing a file in the compiled version ?
    If anyone has an idea please help

    Timothy,
    Thanks for the tip, I needed to add "visa.dll and visa32.dll" to the windowsa
    system directory.
    Chip
    Timothy John Streeter wrote:
    > Hi Donald
    >
    > Have you installed VISA on the new PC?
    >
    > If not you will have to.
    >
    > Tim
    >
    > "Donald J. Furlong" wrote:
    >
    > > I have writted a vi that runs correctly in design mode and runs
    > > correctly when compiled and installed on a hard drive that has LabVIEW
    > > also installed on it.
    > >
    > > When I try to run the compiled program on a computer that does not have
    > > LabVIEW resident on the hard drive the program does not run and I get
    > > the following error message:
    > >
    > > ERROR -1073807202 occured at in SpecanRemoteOp.vi
    > >
    > > Possible reasons:
    > > VISA: (Hex 0xBFFF009E) A code library required by V
    ISA could not be
    > > located or loaded
    > >
    > > Am I missing a file in the compiled version ?
    > > If anyone has an idea please help

  • Show errors package compile.

    Hi group
    Pls how can I see compilations errors after compile a package trough scripts.
    SQL> ALTER PACKAGE QUESTPA.QUEST_ADV_SEQUENCE_RULE_PAK COMPILE;
    Warning: Package altered with compilation errors.
    SQL> SHOW ERRORS
    No errors.
    SQL>
    Thanks

    Dear user12003066,
    If i am not missing anything you may use it like below;
    show errors package <package_name>;I presume it'll work.
    Ogan

  • I have previewed my book but after cliking BUY BOOK it compiles it OK but then it always states an error after of during uploading it to the store.  How can I rectify this?

    I have previewed my book but after cliking BUY BOOK it compiles it OK but then it always states an error after of during uploading it to the store.
    How can I rectify this?

    I have previewed my book but after cliking BUY BOOK it compiles it OK but then it always states an error after of during uploading it to the store.
    How can I rectify this?

  • Error in compiling Flex application  - After changing my query in BW

    Hi All!!
    I'm facing the following problem:
    I have created a VC model based on a BW Query View... I have changed the query in BW (added a new key figure) and then I've refreshed the Query View in my VC model...
    After the refresh, I get the error "Error in compiling Flex application (1). Consult log file for details" everytime I try to deploy...
    Have you faced a similar problem? Does this mean that I can no longer change any query or view used in VC models???
    Thanks in Advance!
    Cris

    Hi Prachi,
    I've tried all the options you listed and it still doesn't work... I even tried to create a new query as a copy of the first one... and the error persists...
    Any other good idea (the model I´m talking about is really huge.. creating it again from zero would be a nightmare!!!)?
    Thanks in advance,
    Cris

  • An error has occurred because a control with id '%spPlaceHolderMain%' could not be located or a different control is assigned to the same ID after postback.

    Hello All, When i try to do a filter on an entity and click filter button, i see the below error message being popped up. Can someone provide a solution to this ?
    "An error has occurred because a control with id '%spPlaceHolderMain%' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events
    to avoid this error."
    Please let me know the process to set the ID explicitly.

    Can you try resetting the IIS?

  • Trigger Compilation Errors after Full Import with Datapump

    Hello All,
    We did a full import with Oracle Datapump, and encountered some errors related to triggers:
    ORA-39082: Object type TRIGGER:"CONVERT3"."CUBCNVT_AUDIT_RESET" created with compilation warnings
    ORA-39082: Object type TRIGGER:"CONVERT3"."CUBCNVT_AUDIT_RESET" created with compilation warnings
    ORA-39082: Object type TRIGGER:"CONVERT3"."CUBCNVT_AUDIT" created with compilation warnings
    ORA-39082: Object type TRIGGER:"CONVERT3"."CUBCNVT_AUDIT" created with compilation warnings
    ORA-39082: Object type TRIGGER:"CONVERT3"."CURCNVT_AUDIT_RESET" created with compilation warnings
    ORA-39082: Object type TRIGGER:"CONVERT3"."CURCNVT_AUDIT_RESET" created with compilation warnings
    ORA-39082: Object type TRIGGER:"CONVERT3"."CURCNVT_AUDIT" created with compilation warnings
    ORA-39082: Object type TRIGGER:"CONVERT3"."CURCNVT_AUDIT" created with compilation warningsWe are wondering if there is some bug with the datapump on oracle 10.2.0.2. What caused such errors and how to resolve this trigger issue?
    Thanks!

    Hello,
    Show errors / at the end of the trigger and see if any of the dependent objects is missing resulting in error at compilation.
    Also you can try manually fixing the issue
    CREATE OR REPLACE TRIGGER table1_trg
       AFTER INSERT
       ON TABLE1    REFERENCING NEW AS new OLD AS old
       FOR EACH ROW
    DECLARE
       tmpvar   NUMBER;
    BEGIN
    Trigger code
    EXCEPTION
       WHEN OTHERS
       THEN
          -- Consider logging the error and then re-raise
          RAISE;
    END table1_trg;
    SHOW ERRORS;Regards

  • Deployment failure after installing SP11 - Error in Compiling Flex App

    After installing SP11 for Visual Composer, I am now not able to deploy any of my models, even though they compile successfully.  The following was installed:
    VCBASE11_0-10003602.SCA
    VCFRAMEWORK11_0-10003624.SCA
    VCFLEX11_0-10003616.SCA
    The specific error is as follows:
    <i>Error in compiling Flex application: Error: Failed to read stylesheet: /vc/skins/defaultSkins.css
          (D:\usr\sap\PLD\JC01\j2ee\cluster\server0\GUIMachine_Business_Packages\TestModel_25034\FLEX_COMPILATION_FOLEDR\AAD15H.mxml:23)
    Failed to compile AAD15H.mxml</i>
    "TestModel" is the name of my model in this example.  I would appreciate any assistance anyone can offer.
    Regards,
    Jim

    Hi Jim,
    I have never heard of similar errors. Have you had a look at the stylesheet that is referenced? Maybe the file is corrupt, permissions are wrong or the path has changed? Try to change the defaultSkins.css.
    You can also have a look at the source code after compiling. Select .mxml of iView AAD15H and have a look at line 23. Maybe you find some clues.
    Best Regards, Benni

  • I installed an ancient version, photoshop element 2, on PC under Windows 7 after change of computer station and it is impossible to register modification made; error message: impossible because saturated disc ....what is not the case: many space on the di

    I installed an ancient version, photoshop element 2, on PC under Windows 7 after change of computer station and it is impossible to register modification made; error message: impossible because saturated disc ....what is not the case: many space on the disc. How to repair this error please?

    Hello
    Thank you for your answer which is interesting because it is a disk of 2 TB... If I create a partition do you think it can solve my problem? I prefer this old version of Photoshop, very practical to use...

Maybe you are looking for

  • Read-only files and folders

    I would like to add ilustrations to mp3 files that I adeed to my iTunes library. However, some of the iTunes folders seem to be read-only. I tried to uncheck them but when I restart iTunes they are read-only again. Any advice ?

  • Using my Mac to Boot a PC with a bad hard drive...

    Hello all, I have a Dell laptop with a blown-out hard drive (big surprise). I want to figure out a way to access it from my Mac, I feel like there should be a way to do this... Do I have to be running Windows? (because I don't, and won't)

  • Anyway to add PSD files to bundle?

    Is there anyway to add PSD files to bundle? I have a panel for textures that require psd files to execute. Anyone know how I could add these to the zxp file?

  • Delivery date keeps changing..!

    I bought an iMac 21.5 inch on October 16, 2014 via phone.  I made the full payment with my credit card.  Received an confirmation e-mail stating that the delivery date is November 3rd, 2014.  The next day I received another e-mail saying that the del

  • Search Replace within a text

    //Create Method named ReplaceBlankWithDash(input string, input/output OutputTextData):Boolean InputTextData : TextData = new; OutputTextData : TextData = new; Success : Boolean = True; InputTextData.SetValue(string); while not (InputTextData.IsAtEnd(