Java Graphics -- Drawing Strings on JFrame

Hello and thank you. I'm relatively young and I apologize for asking noob questions. The problem I am having is that I realized after 3 hours of research and then writing this code that when multiple JPanels are added to a JFrame, they overlap (I think) over each other. As a result, the output of this program below is at the bottom right of the frame, the number 841 appears (the last number in my array) and everything else is blank.
And I could not at all understand how to create graphics objects. It kept giving me an error of not being able to be instantiated. And to be honest, I don't even really understand whats going on when I add the text to my JPanel. I never call paintComponents. And definately I could never even make a graphics object to provide it the parameter required. Anyway, I resolved to use Jpanels because they can be removed using the remove function of the JFrame. And It is vitally important that I can delete the strings off my frame. Here is my code:
package main;
import java.awt.*;
import javax.swing.*;
import java.util.*;
public class VisualFrame extends JFrame{
    ArrayList<JPanel> numbers = new ArrayList<JPanel>();
    public VisualFrame(){
        setSize(1000, 500);
        setTitle("Binary Search");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
    public void createPanels(int[] array){
        int x = 10;
        int y = 20;
        int xOffset = 50;
        int yOffset = 50;
        for(int i=0; i<array.length; i++){
            String num = Integer.toString(array);
numPanel panel = new numPanel(num, x, y);
numbers.add(panel);
add(panel);
x = x+xOffset;
if(x>this.getWidth()){
x = 10;
y = y+yOffset;
class numPanel extends JPanel{
String num;
int x;
int y;
public numPanel(String str, int x, int y){
num = str;
this.x = x;
this.y = y;
public void paintComponent(Graphics g){
g.setColor(Color.black);
g.setFont(new Font("Times", Font.BOLD, 12));
g.drawString(num, x, y);
My main method is inside of a different class:
    public static void main(String[] args){
        VisualFrame frame = new VisualFrame();
        frame.createPanels(array);
    }Firstly, do I even have the problem I'm having right? If so,
Is there a way to restrict the size of the panels to the length and width of what it contains?
Or can someone give me a good, very detailed link to how to use Graphics? Or perhaps someone could prove to me a good method.
Edited by: 989946 on Mar 8, 2013 6:45 PM

Why don't you start by learning from the experts?
The Java Tutorial has sections that show how to use Java functionality.
http://docs.oracle.com/javase/tutorial/
The Graphiics section covers GUI and Swing
http://docs.oracle.com/javase/tutorial/uiswing/index.html
>
Creating Graphical User Interfaces
Creating a GUI with Swing — A comprehensive introduction to GUI creation on the Java platform.
>
And that section has links for trails such as how to use ALL of the different swing components including frames and panels
http://docs.oracle.com/javase/tutorial/uiswing/components/index.html
>
Using Swing Components tells you how to use each of the Swing components — buttons, tables, text components, and all the rest. It also tells you how to use borders and icons.

Similar Messages

  • Help with drawing strings on JFrame?!?!

    Hey guys, I'm really new to Java (just started AP Comp Sci last month), and we had a project to build a Mastermind application using numbers, which I did. However, I'm trying to learn more on my own, and was hoping to use the example code my teacher gave me to output what I want to say to a JFrame instead of just the command prompt.
    Here is the code for my Mastermind class:
    Code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Mastermind extends JFrame
         public static void main(String args[])
              int master[] = new int[4];
              int win = 0;
              for(int x = 0; x<4; x++)
                   master[x] = (int)(Math.random()*10);
              System.out.println();
              do {
                   int guess[] = new int[4];
                   int countMaster[] = new int[4];
              String numguess = JOptionPane.showInputDialog("Enter your guess (4 digits, please)");
              for (int x = 0;x<4;x++)
                   guess[x] = (numguess.charAt(x)-48);
              int correctlyPlaced = 0;
              int correct = 0;
              for (int x = 0;x<4;x++)
                   if(master[x] == guess[x])
                        correctlyPlaced += 1;
              for (int x = 0; x<4;x++)
                             for (int y = 0; y<4;y++)
                                  if((guess[x]==master[y]) && (countMaster[y]==0)) {
                                       correct++;
                                       countMaster[y]=1;
                                       y=5;
              System.out.print("Guess:\t\t\t");
              for (int x = 0;x<4;x++) {
                   System.out.print(guess[x]);
              System.out.println();
              System.out.println("Correct:\t\t"+correct);
              System.out.println("Correctly Placed:\t"+correctlyPlaced);
              if (correctlyPlaced==4) {
                   win=1;
         } while(win<1);
         System.out.println("You win!");
              System.exit(0);
    And here is the example code that my teacher gave me for how to draw a string on a JFrame:
    Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Fonts extends JFrame {
         public Fonts()
              super("Using Fonts");
              setSize(420,125);
              show();
         public void paint(Graphics g)
              super.paint(g);
              g.setFont(new Font("Serif", Font.BOLD, 12));
              g.drawString("Serif 12 point bold.",20,50);
         public static void main(String args[])
              Fonts application = new Fonts();
              application.setDefaultCloseOperation (
                   JFrame.EXIT_ON_CLOSE);
    I would like to be able to put "Guess," "Correct," and "Correctly Placed," on a JFrame, with their respective variables. Any ideas? Thank you!!!

    800045 wrote:
    And DrClap, I get that, but I'm not sure how to put my existing code into the class file that uses the JFrame.You wouldn't put your existing code in there. Your existing code is designed to run as a console app and most of it is concerned with the machinery of getting input from the user. If you want to write it as a Swing app, then you wouldn't need any code which writes to a JFrame in the first place.
    So if your goal for learning on your own is to write GUI applications instead of console applications, then go off and read the Swing tutorials. Right now you're going down the wrong road. However if you're trying to learn something else on your own (I can't tell what that might be) then explain what it is you're trying to learn.

  • Java graphics app prob regarding painting........ app does NOT use applets

    Hi ,
    I basically want to write a java graphics game application ......At this point in time all I want to do is add a green rectangle to the content pane.......I can do this but I want to stick with OO concepts so I have various classes......the thing is ....when a user resizes the window the graphic I have painted dissapeared
    I will show the classes I have used and the code below......I want to do the program conforming to the way I was tought java which is to have a main controlling class that orchestrates communication between unrelated classes and their methods. In addition to my question if anyone sees stuff fundementally wrong with my code and has a better solution please feel free to enlighten me :-)
    main controlling class:
    import java.awt.Graphics;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2005</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class PoolApp {
    public PoolApp() {
    //creates new gamescreen object
    GameScreen aScreen = new GameScreen(this);
    public static void main(String[] args) {
    PoolApp poolApp1 = new PoolApp();
    public Graphics getPaintedTable(GameScreen aGameScreen) {
    Paint aPaint = new Paint(this);
    Graphics tblObj = aPaint.getTbleGraphic(aGameScreen);
    return tblObj;
    ------end main controlling class
    ------TLayer Class start
    import javax.swing.*;
    /* The purpose of this class was to create a generic frame that would
    be inherited from all screen classes ...I initially had this creating a black background that would be inherited from child classes but that created
    more problems when the screen was resized by one of the child classes*/
    public class TLayer extends JFrame {
    public TLayer() {
    -----TLayer Class end
    -----GameScreen class start--------
    public class GameScreen extends TLayer{
    private PoolApp thePoolApp;
    public GameScreen(PoolApp aPoolApp) {
    thePoolApp = aPoolApp; //set a reference from here to the controlling PoolApp initGameScreen(); //initialise and show GameScreen .....screen
    public void initGameScreen() {
    this.setSize(800,600);
    this.show();
    //now make a request to the poolapp controlling class to ask for a painted green table and get the paint class to paint it to screen
    thePoolApp.getPaintedTable(this);
    ----GameScreen class end------------
    ----PaintScreen class start-------------
    PoolApp thePoolApp;
    public Paint() {
    public Paint(PoolApp apoolApp) {
    thePoolApp = apoolApp;
    public Graphics getTbleGraphic(GameScreen aGameScreen) {
    Container theCont = aGameScreen.getContentPane(); //assign the gamescreen content pane to a container
    theCont.setSize(200,200); //set a viewable size to the container
    Graphics thetbl = theCont.getGraphics(); //get container graphics context and assign it to a graphics object
    thetbl.setColor(Color.green); //color the object
    thetbl.fillRect(30,30,20,60); //fill the rectangle
    return thetbl; //return the object
    ---PaintScreen class end---------------
    This code actually draws the green rectangle to the gamescreen from the paint class .......so it works to a degree! ......whenever I resize the window the painted image dissapears, could anyone suggest a way around this also ...am I going about this the correct way? Im open to making mass changes to better the program ......the only thing I do not want is to use applets! .....as I want to learn the fundementals of custom painting my stuff
    Any help is much needed and appreciated
    David

    Hi .....I managed to fix my problem .....but I have really had to get my head around method overiding! ......Your advice is taken onboard ...also Im going to try and find a straight forward diagram of the java graphics heirrachy ......well the parts that are reasnable to what Im doing ......Also from what I know and what you have said yes threads would definately be the way to go as far as animation and paintings concerned...I plan to do some serious research on that as I progress.
    I am going to post my basic working program ........I was wandering if you think this is an effiecent way I have done this? or if you could make any recommendations? its just I dont want to adopt this approach and find its no good when I get further into the programs development :-)) anyway heres the code :
    ------Class PoolApp start--------------
    public class PoolApp {
      public PoolApp() {
        GameScreen aGScreen = new GameScreen(this);
      public static void main(String[] args) {
        PoolApp poolApp1 = new PoolApp();
    }------Class PoolApp end--------------
    ------Class TLayer start--------------
    import javax.swing.*;
    import java.awt.Graphics;
    public class TLayer extends JFrame {
      public TLayer() {
         System.out.println("In TLayer default constructor");
         this.setSize(800,600);
    }------Class TLayer end--------------
    ------Class GameScreen start--------------
    import java.awt.Graphics;
    public class GameScreen extends TLayer {
      PoolApp thepoolApp;
      Table theTable;
      Graphics g;
      public GameScreen() {
       System.out.println("In gamescreen default constructor table");
      public GameScreen(PoolApp apoolApp) {
      thepoolApp = apoolApp;
      System.out.println("In gamescreen  constructor 2");
      addTable();
    public void addTable() {
    System.out.println("in addTable");
    this.show();
    //theTable = new Draw(this);
    //theTable.setTable();
    //theTable.paint(g);
    public void paint(Graphics g) {
         System.out.println("In Gamescreen paint ");
         theTable = new Table(this);
         theTable.paint(g);
    public void update(Graphics g) {
        System.out.println("In Gamescreen update ");
        theTable = new Table(this);
        theTable.paint(g);
    }------Class GameScreen end--------------
    ------Class Table start--------------
    import java.awt.Graphics;
    import java.awt.Container;
    import java.awt.Color;
    public class Table extends TLayer{
      GameScreen thegameScreen;
      public Table() {
          System.out.println("In Table default constructor");
      public Table(GameScreen agameScreen) {
        thegameScreen = agameScreen;
        System.out.println("In Table 2nd constructor");
      public void paint(Graphics theGraphic) {
        System.out.println("In Table paint ");
        Container tablecont = thegameScreen.getContentPane();
        theGraphic = tablecont.getGraphics();
        theGraphic.setColor(Color.green);
        theGraphic.fillRect(310,220,180,80);
      public void update(Graphics theGraphic) {
           System.out.println("In Table update");
       paint(theGraphic);
    }------Class Table end--------------
    To be honest I would rather have created a table object then added it to the content pane ....but when i did it that way ......and I resized the screen the green table graphic dissapeared .....I would also have prefered all painting of the table to be done in the table class but I had the same problem of the graphic dissapearing when the window was resized and this is the best solution I have come up with as yet ....:-) .....any recommendations are greatly appreciated
    Thanks
    David

  • Drawing onto multiple JFrames

    i'm writing code to make a JFrame that a moving image in it, using timers, but I keep getting runtime errors. I need a new way to draw onto a JFrame.
    here is some code:
    public void paint(Graphics g) {
    super.paint(g);
         g.drawImage( target, 10, 30, this );
         speedFrame.getGraphics().drawImage( bg, 0, 0, this );
         speedFrame.getGraphics().drawImage( hbar, 5, y, this );
         spotFrame.getGraphics().drawImage( bg2, 0, 0, this );
    spotFrame.getGraphics().drawImage( vbar, x, 20, this );
         if( playing == true )
              g.drawImage( ball, maxx, by, this );
    the part that I need help with is speedFrame.getGraphics().drawImage()

    Swing related questions should be posted in the Swing forum.
    This posting, from the Swing forum, contains a couple of examples on animation:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=631379

  • How to draw string vertically?

    Hi,
    The java drawString() method draws string horizontally by default, but I want to draw the string vertically, see an example below: I want to draw the string "abcdef" as below format:
    a
    b
    c
    d
    e
    f
    so, I thought of the AffineTransform, but I can not work it out.
    Who can help me? If you have other ways, they are welcome too.
    Thanks. Robin

    import java.awt.*;
    import java.awt.font.*;
    import java.awt.geom.AffineTransform;
    import java.awt.image.BufferedImage;
    import javax.swing.*;
    public class VText {
        public static void main(String[] args) {
            int w = 200, h = 300;
            BufferedImage image = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = image.createGraphics();
            g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                                RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
            g2.setBackground(UIManager.getColor("OptionPane.background"));
            g2.clearRect(0,0,w,h);
            g2.setPaint(Color.black);
            Font font = g2.getFont().deriveFont(18f);
            g2.setFont(font);
            FontRenderContext frc = g2.getFontRenderContext();
            String text = "Hello World";
            g2.drawString(text, 50, h - 25);
            String[] s = text.split("(?<=[\\w\\s])");
            float y = 25f;
            for(int j = 0; j < s.length; j++) {
                float width = (float)font.getStringBounds(s[j], frc).getWidth();
                LineMetrics lm = font.getLineMetrics(s[j], frc);
                float x = (w - width)/2;
                AffineTransform at = AffineTransform.getTranslateInstance(x, y);
                g2.setFont(font.deriveFont(at));
                g2.drawString(s[j], 0, 0);
                y += lm.getAscent();// - lm.getDescent();
            g2.dispose();
            JOptionPane.showMessageDialog(null, new ImageIcon(image), "",
                                          JOptionPane.PLAIN_MESSAGE);
    }

  • Java.lang.StringIndexOutOfBoundsException: String index out of range: -1

    hi am having this error when running my application am in jdeveloper 11.1.1.6.0
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1
         at java.lang.String.substring(String.java:1931)
         at car.deDeedandeSurvey.view.frameworkExt.CustomErrorHandler.displayProperly(CustomErrorHandler.java:66)
         at car.eDeedandeSurvey.view.frameworkExt.CustomErrorHandler.reportException(CustomErrorHandler.java:32)
         at oracle.adf.model.binding.DCBindingContainer.reportException(DCBindingContainer.java:423)
         at oracle.adf.model.binding.DCBindingContainer.reportException(DCBindingContainer.java:471)
         at oracle.adf.model.binding.DCIteratorBinding.getDataControl(DCIteratorBinding.java:2438)
         at oracle.adf.model.binding.DCBindingContainer.internalRefreshControl(DCBindingContainer.java:3069)
         at oracle.adf.model.binding.DCBindingContainer.refreshControl(DCBindingContainer.java:2908)
         at oracle.adf.model.binding.DCBindingContainer.refresh(DCBindingContainer.java:2894)
         at oracle.adfinternal.controller.util.model.DataBindingActivityImpl.beforeExecute(DataBindingActivityImpl.java:109)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.executeActivity(ControlFlowEngine.java:1015)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:921)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:820)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.invokeTaskFlow(ControlFlowEngine.java:243)
         at oracle.adfinternal.controller.state.ChildViewPortContextImpl.invokeTaskFlow(ChildViewPortContextImpl.java:104)
         at oracle.adfinternal.controller.state.ControllerState.createChildViewPort(ControllerState.java:1387)
         at oracle.adfinternal.controller.ControllerContextImpl.createChildViewPort(ControllerContextImpl.java:78)
         at oracle.adf.controller.internal.binding.DCTaskFlowBinding.createRegionViewPortContext(DCTaskFlowBinding.java:474)
         at oracle.adf.controller.internal.binding.DCTaskFlowBinding.getViewPort(DCTaskFlowBinding.java:392)
         at oracle.adf.controller.internal.binding.TaskFlowRegionModel.doProcessBeginRegion(TaskFlowRegionModel.java:164)
         at oracle.adf.controller.internal.binding.TaskFlowRegionModel.processBeginRegion(TaskFlowRegionModel.java:112)
         at oracle.adf.controller.internal.binding.TaskFlowRegionController.doRegionRefresh(TaskFlowRegionController.java:241)
         at oracle.adf.controller.internal.binding.TaskFlowRegionController.refreshRegion(TaskFlowRegionController.java:119)
         at oracle.adf.model.binding.DCBindingContainer.internalRefreshControl(DCBindingContainer.java:3204)
         at oracle.adf.model.binding.DCBindingContainer.refresh(DCBindingContainer.java:2876)
         at oracle.adf.model.binding.DCBindingContainer.internalRefreshControl(DCBindingContainer.java:3195)
         at oracle.adf.model.binding.DCBindingContainer.refresh(DCBindingContainer.java:2876)
         at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.prepareModel(PageLifecycleImpl.java:115)
         at oracle.adf.controller.faces.lifecycle.FacesPageLifecycle.prepareModel(FacesPageLifecycle.java:359)
         at car.eDeedandeSurvey.view.frameworkExt.CustomLifeCycle.prepareModel(CustomLifeCycle.java:15)
         at oracle.adf.controller.v2.lifecycle.Lifecycle$2.execute(Lifecycle.java:137)
         at oracle.adfinternal.controller.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:197)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.access$400(ADFPhaseListener.java:23)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$PhaseInvokerImpl.startPageLifecycle(ADFPhaseListener.java:238)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$1.after(ADFPhaseListener.java:274)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.afterPhase(ADFPhaseListener.java:75)
         at oracle.adfinternal.controller.faces.lifecycle.ADFLifecyclePhaseListener.afterPhase(ADFLifecyclePhaseListener.java:53)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:472)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:194)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.portlet.client.adapter.adf.ADFPortletFilter.doFilter(ADFPortletFilter.java:32)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.webcenter.framework.events.dispatcher.EventDispatcherFilter.doFilter(EventDispatcherFilter.java:44)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.wcps.client.PersonalizationFilter.doFilter(PersonalizationFilter.java:75)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.webcenter.content.integration.servlets.ContentServletFilter.doFilter(ContentServletFilter.java:168)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.webcenter.lifecycle.filter.LifecycleLockFilter.doFilter(LifecycleLockFilter.java:151)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:179)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

    The problem occurs at line 66 in class car.deDeedandeSurvey.view.frameworkExt.CustomErrorHandler, which is a non-ADF class, most probably it is a class of your own. Go to line 66 in this class and look at the source code. If it is not clear what happens there, set a breakpoint within the method car.deDeedandeSurvey.view.frameworkExt.CustomErrorHandler.displayProperly and debug it. If you do not have the original source code, then decompile this class and look at the source code. You can set a breakpoint at this line even if you do not have the source code.
    Dimitar

  • Question about the java doc of String.intern() method

    hi all, my native language is not english, and i have a problem when reading the java doc of String.intern() method. the following text is extract from the documentation:
    When the intern method is invoked, if the pool already contains a string equal to this String object as determined by the equals(Object) method, then the string from the pool is returned. Otherwise, this String object is added to the pool and a reference to this String object is returned.
    i just don't know the "a reference to this String object is returned" part, does the "the reference to this String" means the string that the java keyword "this" represents or the string newly add to the string pool?
    eg,
    String s=new String("abc");  //create a string
    s.intern();  //add s to the string pool, and return what? s itself or the string just added to string pool?greate thanks!

    Except for primitives (byte, char, short, int, long, float, double, boolean), every value that you store in a variable, pass as a method parameter, return from a method, etc., is always a reference, never an object.
    String s  = "abc"; // s hold a reference to a String object containing chars "abc"
    foo(s); // we copy the reference in variable s and pass it to the foo() method.
    String foo(String s) {
      return s + "zzz"; // create a new String and return a reference that points to it.
    s.intern(); //add s to the string pool, and return what? s itself or the string just added to string pool?intern returns a reference to the String object that's held in the pool. It's not clear whether the String object is copied, or if it's just a reference to the original String object. It's also not relevant.

  • Java.lang.StringIndexOutOfBoundsException: String index out of range: -99

    Hi.
    We are having a problem with the jstudio IDE Enterprise Edition.
    We are trying to create an CMP Bean using the IDE.
    The database table has 69 columns of various datatatypes. BUT as soon as i write the create method the following error is logged after all the 69 parameters are added in the create method
    PS : I have tried it on both Standard and Enterprise Edition .......They both give the same error.
    (Note this ocured when i had written all the 69 paramenters for the Database Table !)
    *********** Exception occurred ************ at Wed Sep 22 16:49:05 GMT+05:30 2004
    Annotation: Parser error
    java.lang.StringIndexOutOfBoundsException: String index out of range: -99
         at java.lang.String.<init>(String.java:192)
         at java.lang.String.copyValueOf(String.java:2185)
         at org.netbeans.modules.java.parser.DocumentModelBuilder.setBodyBounds(DocumentModelBuilder.java:105)
         at org.netbeans.modules.java.gj.V8TreeTranslator._case(V8TreeTranslator.java:437)
         at org.netbeans.lib.javac.v8.tree.Tree$MethodDef.visit(Tree.java:460)
         at org.netbeans.modules.java.gj.V8TreeTranslator._case(V8TreeTranslator.java:303)
         at org.netbeans.lib.javac.v8.tree.Tree$ClassDef.visit(Tree.java:407)
         at org.netbeans.modules.java.gj.V8TreeTranslator._case(V8TreeTranslator.java:188)
         at org.netbeans.lib.javac.v8.tree.Tree$TopLevel.visit(Tree.java:344)
         at org.netbeans.modules.java.gj.V8TreeTranslator.process(V8TreeTranslator.java:94)
         at org.netbeans.modules.java.gj.ParserEngine.completeRequest(ParserEngine.java:360)
         at org.netbeans.modules.java.gj.ParserEngine.parseObject(ParserEngine.java:176)
         at org.netbeans.modules.java.gj.JavaParserEngine.process(JavaParserEngine.java:72)
         at org.netbeans.modules.java.parser.ParsingSupport$Processor.process(ParsingSupport.java:711)
         at org.netbeans.modules.java.parser.ParsingSupport$Processor.parseLockModel(ParsingSupport.java:662)
    [catch] at org.netbeans.modules.java.parser.ParsingSupport$Processor.run(ParsingSupport.java:593)
         at org.openide.util.Task.run(Task.java:136)
         at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:328)
         at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:670)
    ==>
    WARNING - ErrorManager detected cyclic exception nesting:
         java.lang.StringIndexOutOfBoundsException: String index out of range: -99
    Be sure not to annotate an exception with itself, directly or indirectly.

    Hi
    Can you send me yoursample to me. I will check the code and let you know whats going wrong. mail your sample to [email protected]
    Thanks
    Vasu

  • Java.lang.StringIndexOutOfBoundsException: String index out of range: 8

    Hi Friends,
    I have a search window ,in one I/P Field i entered * and kept the default max hits to display as 100 records(This can be changed).
    Now when i click on Search i get 100 records being displayed,later when i change it to 150,200 Hits i am able to get them displayed(Records).
    But when i enter value greater than 200(i had entered 220) i am getting the following exception.
    java.lang.StringIndexOutOfBoundsException: String index out of range: 8
    Can anyone please help me out to resolve this issue.
    Thanks and regards,
    Chandrashekar.

    Hello Chandrashekar,
            It looks like in  the loop of number of records, you are fetching the record and processing the string either using charAt() method or subString method or any similar method.
    But in one of the record string after 200th record is having a string which when you are processing are having length less than 8.
    Say : String s = "Correct";
    will give StringIndexOutOfBoundsException: String index out of range: 8 as the length is only 7 and you are  cheking for char at position 8.
    Just check the processing you are doing within the record loop and also the records.
    Hope this helps.

  • Java.lang.StringIndexOutOfBoundsException: String index out of range: 3

    I have just downloaded Jdev (10.1.3.1) and am trying out the tutorial "Introduction to JavaServer Faces using JDeveloper".
    When I try to run the Welcome.jsp I get the following :
    java.lang.StringIndexOutOfBoundsException: String index out of range: 3
         at java.lang.String.substring(String.java:1765)
         at oracle.jdeveloper.compiler.OjcConfiguration.getSource(OjcConfiguration.java:276)
         at oracle.jdevimpl.runner.oc4j.Oc4jWorkspaceConfig.ensureJavaCompilerIsSet(Oc4jWorkspaceConfig.java:1081)
         at oracle.jdevimpl.runner.oc4j.Oc4jWorkspaceConfig.configureAll(Oc4jWorkspaceConfig.java:168)
         at oracle.jdevimpl.runner.oc4j.Oc4jStarter.preStart(Oc4jStarter.java:628)
         at oracle.jdevimpl.runner.oc4j.Oc4jStarter.start(Oc4jStarter.java:269)
         at oracle.ide.runner.RunProcess.startTarget(RunProcess.java:830)
         at oracle.jdeveloper.runner.JRunProcess.startTarget(JRunProcess.java:473)
         at oracle.jdevimpl.runner.run.RunningProcess.startTarget(RunningProcess.java:76)
         at oracle.ide.runner.RunProcess$2$1.run(RunProcess.java:768)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    #### Embedded OC4J Server could not be started up.
    What can I do to resolve this ?
    Thanks,
    K

    Found the problem.
    Solution : Do not install Jdev in a directory path which contains blanks spaces.

  • Java.lang.StringIndexOutOfBoundsException: String index out of range: -2

    Hello,
    I have a question about this error:
    Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -2
    I am doing my java development in IBM Rationale eclipse. I am compiling and running everything just fine. When I try to run my application on a command line I get this error. I don't know why this is happening since it is working perfectly in eclipse. I am running a .bat file and here is the .bat file:
    @echo on
    rem ---------------------------------------------------------------------------
    rem Script for launching Translation Application
    rem
    rem Environment Variable Prequisites
    rem
    rem
    rem ---------------------------------------------------------------------------
    cls
    SET DERBY_INSTALL=C:\Translation\Cloudscape_10.1
    SET TRANSLATION=C:\Translation
    set CLASSPATH=%DERBY_INSTALL%\lib\derby.jar;%DERBY_INS TALL%\lib\derbytools.jar;%TRANSLATION%\lib\Transla tion.jar;
    echo %CLASSPATH%
    C:\Translation\jdk\jre\bin\java -classpath %CLASSPATH%;C:\Translation\Conversions src.utilities.DataConversionUtilityDaily
    pause
    Here is the code that is erroring out:
    sqlStatement.append(text.deleteCharAt(text.length( )-2));
    this code is compiling and executing just fine in eclipse but when i try to run it on a command line it gives me the above error.
    Can someone help me find out why my program is not running?

    I am running this same java statement in eclipse and
    I am not getting this error and it runs just fine.
    so i am trying to find out what the difference. Well obviously the difference is that in eclispe the length isn't zero.
    I
    am running the same code with the same data and I am
    getting to different things. No you aren't.
    Because if you were you would be getting the same result.
    You are assuming that it is the same, when in fact it isn't.
    Something is different.

  • Writting java graphics and textual data from java application into MS word

    By using POI API, I could write textual data into MS word by using
    java application. Could any one help me out how to write
    Java graphics(i.e. Writting JPanel) and textual data(i.e.IOStream data) both into MS word document.
    Thank you for time spent.
    Thanks with regards,
    Mallik

    hi:
    Can any one help me out how to read and write in to the MsWord using POI...plz it is very urgent...plz give ur reply to [email protected]

  • Java.sql.SQLException: String index out of range: -8

    Hi Folks,
    I am experiencing the following error in my application and can't seem to fine where the error is occuring. Please help.
    java.sql.SQLException: String index out of range: -8
         at sanchez.jdbc.dbaccess.ScDBError.check_error(Unknown Source)
         at sanchez.jdbc.driver.ScPreparedStatement.executeQuery(Unknown Source)
         at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:205)
         at etrade.persistance.framework.dataaccess.request.SQLPreparedStatementRequestBuilder.sendRequest(Unknown Source)
         at etrade.persistance.framework.dataaccess.request.Request.sendRequest(Unknown Source)
         at etrade.persistance.framework.dataaccess.transactions.Transaction.executeTrxn(Unknown Source)
         at etrade.persistance.components.ComponentSupport.executeTrxn(Unknown Source)
         at etrade.services.atmdebitsrv.ProcessCardComponent.execute(ProcessCardComponent.java:53)
         at etrade.services.atmdebitsrv.ProcessCardBindingImpl.processCard(ProcessCardBindingImpl.java:12)
         at etrade.services.atmdebitsrv.ProcessCardBindingSkeleton.processCard(ProcessCardBindingSkeleton.java:56)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
         at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
         at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:402)
         at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:309)
         at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:333)
         at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
         at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
         at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
         at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:481)
         at org.apache.axis.server.AxisServer.invoke(AxisServer.java:323)
         at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:854)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:339)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
         at java.lang.Thread.run(Thread.java:568)

    Please post us the code for us to debug.

  • Is there a Java Graphic Package that doesn't depend on DISPLAY?

    Hi
    Is there a Java Graphic Package that doesn't depend on DISPLAY?. I need to generate some images on the web and I can't guarantee that the DISPLAY variable is set correctly.
    Regards,
    N�stor Bosc�n

    Hello,
    Previously to JDK 1.4 the DISPLAYwas mandatory and most of the production Web sites were running a virtual X server (XVFB) take a look to this document
    However using JDK 1.4 or after you should not need to set the display anymore. Java contains now a headless that you set the Java properties java.awt.headless to true (java -Djava.awt.headless=true ...)
    Regards
    Tugdual Grall

  • Is it possible to integrate a mentor graphics drawing file using labview or any labview toolkit..!!!

    I m having a mentor graphics drawing file having drawn with the components like resistor,capacitors etc..I need to develop an application to interface to the file using labview or adding a toolkit to labview to access the components like resistors etc .Can any body  help me about this....?
    Thanks in advance...!
    Certified Labview Associate Developer(CLAD)
    Don't Forget to Rate the answers.!!! You can do it in few seconds

    Hi Lynn ,
    Basically i want to read the mentor graphics drawing file data in a labview front panel, so that i can display the components as we see in the mentor graphics development enviornement and should be able to click on the components to perform the tests associated with the same.For this,i think i need to have the BOM kind of data only as i need the components data associated with the drawing file,after this i would create a custom control for each and every component and then call the tests associated with it as soon as the user clicks on the same.I hope you understand my requirements.
    Thanks & regards,
    Dinesh Kumar
    Certified Labview Associate Developer(CLAD)
    Don't Forget to Rate the answers.!!! You can do it in few seconds

Maybe you are looking for

  • IPhone 3GS Charging/Battery Problem: Hardware, Software, or Both?

    Hello everyone, I'm a long time Apple user, but this is the first time I've ever posted on the Apple Support forums. I hope you will please excuse the length of my post, as I believe that relaying the approximate sequence of events here is important

  • Problem in lsmw. step: display field mapping and conversion rule

    hi, The IDOC structure to be mapped is missing in step 5[lsmw using IDOC]. Hence target structures are missing in auto gnerated conversion program. As a result the the step Convert Data step is failing.[Converted data cant be generated] I am using st

  • Disable scrolling text?

    I have seen similar posts but have found no answer. I would like to limit text entered into a field by the actual parameters of the drawn text box. An option which was simple in Acrobat Professional (uncheck scroll long text). While I appreciate any

  • Table Statistics tab

    Hi, Is it possible to have a full timestamp on the LAST_ANALYZED and LAST_ANALYZED_SINCE names? Thanks, Alan

  • New Layer Being Created When Timeline Effect Added

    I am working on a Flash file in which I am adding a Timeline Effect (5 frame fade out). Recently, instead of the transition being applied to the layer, in the frame length specified, Flash adds another layer with the standard 30 frames and it deletes