Changing Graphics object

Hoa can I change the color properties of the graphics object of one component in another component?

The short answer is you can't. Graphics objects are not part of the state of a
component -- they are created when rendering needs to be done and
are disposed afterwards. Also, the same graphics object is shared: the same
graphics objects is adjusted and used to repaint a frame and all its components,
for example.
Components do have some "graphical" state, however, like their foreground
and background color and font. What is your goal?

Similar Messages

  • How to change font/ font color etc in a graphic object using JCombobox?

    Hello
    My program im writing recently is a small tiny application which can change fonts, font sizes, font colors and background color of the graphics object containing some strings. Im planning to use Jcomboboxes for all those 4 ideas in implementing those functions. Somehow it doesnt work! Any help would be grateful.
    So currently what ive done so far is that: Im using two classes to implement the whole program. One class is the main class which contains the GUI with its components (Jcomboboxes etc..) and the other class is a class extending JPanel which does all the drawing. Therefore it contains a graphics object in that class which draws the string. However what i want it to do is using jcombobox which should contain alit of all fonts available/ font sizes/ colors etc. When i scroll through the lists and click the one item i want - the graphics object properties (font sizes/ color etc) should change as a result.
    What ive gt so far is implemented the jcomboboxes in place. Problem is i cant get the font to change once selecting an item form it.
    Another problem is that to set the color of font - i need to use it with a graphics object in the paintcomponent method. In this case i dnt want to create several diff paint.. method with different property settings (font/ size/ color)
    Below is my code; perhaps you'll understand more looking at code.
    public class main...
    Color[] Colors = {Color.BLUE, Color.RED, Color.GREEN};
            ColorList = new JComboBox(Colors);
    ColorList.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ev) {
                     JComboBox cb = (JComboBox)ev.getSource();
                    Color colorType = (Color)cb.getSelectedItem();
                    drawingBoard.setBackground(colorType);
              });;1) providing the GUI is correctly implemented with components
    2) Combobox stores the colors in an array
    3) ActionListener should do following job: (but cant get it right - that is where my problem is)
    - once selected the item (color/ font size etc... as i would have similar methods for each) i want, it should pass the item into the drawingboard class (JPanel) and then this class should do the job.
    public class DrawingBoard extends JPanel {
           private String message;
           public DrawingBoard() {
                  setBackground(Color.white);
                  Font font = new Font("Serif", Font.PLAIN, fontSize);
                  setFont(font);
                  message = "";
           public void setMessage(String m) {
                message = m;
                repaint();
           public void paintComponent(Graphics g) {
                  super.paintComponent(g);
                  //setBackground(Color.RED);
                  Graphics2D g2 = (Graphics2D) g;
                  g2.setRenderingHint             
                  g2.drawString(message, 50, 50);
           public void settingFont(String font) {
                //not sure how to implement this?                          //Jcombobox should pass an item to this
                                   //it should match against all known fonts in system then set that font to the graphics
          private void settingFontSize(Graphics g, int f) {
                         //same probelm with above..              
          public void setBackgroundColor(Color c) {
               setBackground(c);
               repaint(); // still not sure if this done corretly.
          public void setFontColor(Color c) {
                    //not sure how to do this part aswell.
                   //i know a method " g.setColor(c)" exist but i need to use a graphics object - and to do that i need to pass it in (then it will cause some confusion in the main class (previous code)
           My problems have been highlighted in the comments of code above.
    Any help will be much appreciated thanks!!!

    It is the completely correct code
    I hope that's what you need
    Just put DrawingBoard into JFrame and run
    Good luck!
    public class DrawingBoard extends JPanel implements ActionListener{
         private String message = "message";
         private Font font = new Font("Serif", Font.PLAIN, 10);
         private Color color = Color.RED;
         private Color bg = Color.WHITE;
         private int size = 10;
         public DrawingBoard(){
              JComboBox cbFont = new JComboBox(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
              cbFont.setActionCommand("font");
              JComboBox cbSize = new JComboBox(new Integer[]{new Integer(14), new Integer(13)});
              cbSize.setActionCommand("size");
              JComboBox cbColor = new JComboBox(new Color[]{Color.BLUE, Color.RED, Color.GREEN});
              cbColor.setActionCommand("color");
              JComboBox cbBG = new JComboBox(new Color[]{Color.BLUE, Color.RED, Color.GREEN});
              cbBG.setActionCommand("bg");
              add(cbFont);
              cbFont.addActionListener(this);
              add(cbSize);
              cbSize.addActionListener(this);
              add(cbColor);
              cbColor.addActionListener(this);
              add(cbBG);
              cbBG.addActionListener(this);
         public void setMessage(String m){
              message = m;
              repaint();
         protected void paintComponent(Graphics g){
              super.paintComponent(g);
              Graphics2D g2 = (Graphics2D)g;
              g2.setColor(bg);//set background color
              g2.fillRect(0,0, getWidth(), getHeight());          
              g2.setColor(color);//set text color
              FontRenderContext frc = g2.getFontRenderContext();
              TextLayout tl = new TextLayout(message,font,frc);//set font and message
              AffineTransform at = new AffineTransform();
              at.setToTranslation(getWidth()/2-tl.getBounds().getWidth()/2,
                        getWidth()/2 + tl.getBounds().getHeight()/2);//set text at center of panel
              g2.fill(tl.getOutline(at));
         public void actionPerformed(ActionEvent e){
              JComboBox cb = (JComboBox)e.getSource();
              if (e.getActionCommand().equals("font")){
                   font = new Font(cb.getSelectedItem().toString(), Font.PLAIN, size);
              }else if (e.getActionCommand().equals("size")){
                   size = ((Integer)cb.getSelectedItem()).intValue();
              }else if (e.getActionCommand().equals("color")){
                   color = (Color)cb.getSelectedItem();
              }else if (e.getActionCommand().equals("bg")){
                   bg = (Color)cb.getSelectedItem();
              repaint();
    }

  • Problem with decimal data visualization in a circular graphic object type

    When we are design a report using Crystal Reports 2008 we found the following problem. When we insert an object of type circle graphic selecting the option in the graphics wizard for view in the legend data both in value and percentage (u2018bothu2019 design) we cant show them in a two decimals format at the same time.
    Using the option u2018number formatu2019 and indicating two decimals only affects the value but not the percentage.
    Show both the value and the percentage with two decimals at same time itu2019s a necessary requirement for our report design.
    Is there any way to show both the value and the percentage in a circle graphic object with two decimals at the same time?
    Thanks.

    hello Jose,
    i am not sure what you mean by "circular graphic object type".
    there's nothing in the standard cr 2008 build that has this that i've ever found that creates a circle other than inserting a box and changing the rounding on the corners. if you're using a 3rd party product or add-on you'll need to contact whoever built it.
    cheers,
    jamie

  • Best way to draw thousands of graphic objects on the screen

    Hello everybody, I'm wanting to develop a game where at times thousands of graphic objects are displayed on-screen. What better way to do this in terms of performance and speed?
    I have some options below. Do not know if the best way is included in these options.
    1 - Each graphical object is displayed on a MovieClip or Sprite.
    2 - There is a Bitmap that represents the game screen. All graphical objects that are displayed on screen have your images stored in BitmapData. Then the Bitmap that represents the game screen copies for themselves the BitmapData of graphical objects to be screened, using for this bitmapData.copyPixels (...) or BitmapData.draw  (...). The Bitmap that represents the screen is added to the stage via addChild (...).
    3 - The graphical objects that are displayed on screen will have their images drawn directly on stage or in a MovieClip/Sprite added to this stage by addChild (...). These objects are drawn using the methods of the Graphics class, as beginBitmapFill and beginFill.
    Recalling that the best way probably is not one of these 3 above.
    I really need this information to proceed with the creation of my game.
    Please do not be bothered with my English because I'm using Google translator.
    Thank you in advance any help.

    Thanks for the information kglad. =)
    Yes, my game will have many objects similar in appearance.
    Some other objects will use the same image stored, just in time to render these objects is that some effects (such as changing the colors) will be applied in different ways. But the picture for them all is the same.
    Using the second option, ie, BitmapDatas, which of these two methods would be more efficient? copyPixels or draw?
    Thank you in advance any help. =D

  • How does one Float a Graphic Object with Text? (Don't want the Graphics Frame stationary)

    I now know just enough InDesign to be dangerous.  So, help me from blowing myself up.
    SITUATION:
    I desire a Callout/Quote Box to emphase a quote--to separate it from the flowing text of the manuscript.  So, I created a curved-edge rectangle (graphic object) to make the "box", then filled it with the quoted text).  All was well in the land of Adobe Novice UNTIL I deleted some text above the newly-created graphic box/quote box.  I need the graphic to flow with (stay embedded in; hold its position in) the text outside the manuscript, not say anchored to page.
    QUESTION:
    Is there a way to have a graphic object which is placed in a manuscript flow with the manuscript text, so that it "holds its position" relative to the text.  For example, if I delete a paragraph of text above the graphic object, I want the graphic object to adjust accordingly.
    ASIDE:
    I am open to any other tricks or methods others use to insert callout or quote-boxes within the flowing text of a manuscript/book.
    Thanks in advance.

    Create your callout. If you will use it often, you can actually grab it and drag it to the desktop for reuse in any Document; it becomes an InDesign Snippet (.inds).
    Copy the callout graphic, insert your text curser into the text frame where you want the callout. You've just Anchored an Object.
    This is where you want to read up on Anchored Objects. You can highlight and baseline shift the callout (often necessay for anchored objects) , change leading, apply text wrap with standoff (you would select it with the selection tool for this), all of which are way beyond what I have ever tried, but managed it in less than 3 minutes. Basically treat it as a selection of type. The challenges will be line breaks, keep with, gosh knows.
    Bob mentioned CS5.5 has more friendly features, which I am not familiar with, and are beyond quick replies.
    Work through the above at your discretion, ask more DIRECT questions as needed, and you will get help. 

  • I cant get it to work! NullPointerExeption at first awt.Graphics Object

    I am writing a game with AWT having it as an applet. I intend NOT to use anything outside of Java 1.1
    For my Game i thought that i ATLEAST need the following classes:
    MainGame, Level, Unit.
    I Started writing Level. wrote a fewe methods for it such as
    drawGras(int grastype) And started to write MainGame to see if they would work together. it's is/is going to be my first Java application where i actually know what object orienting is... I have already wrote a game in Java but with out knowing what a class or what object orienting realy is(the game works rather good to) but this time i wanted to use object orienting but came up with problems =( if first posted in "New to Javaprogramming" but they couldn't help me and advice me here
    My previous post: http://forum.java.sun.com/thread.jsp?forum=54&thread=290558
    Here's my code:
    import java.awt.*;
    public class MainGame extends java.applet.Applet
         implements Runnable {
         Thread runner;
         Image ImgLevel, ImgUnit;
         public MainGame() {
              Level nr1 = new Level();
              nr1.init();
              nr1.setGround(300);
              nr1.drawGras(1);
              nr1.CalcGraphics();
              nr1.drawSky(1);
              Image ImgLevel = nr1.getLevelImage();
         public void paint(Graphics g) {
              g.drawImage(ImgLevel,0,0,this);
         public void update(Graphics g) {
              paint(g);
         public void init() {
              MainGame Game = new MainGame();
         public void stop() {
              runner = null;
              System.exit(1);
         public void start() {
              if(runner == null) {
                   runner = new Thread(this);
                   runner.start();
         void Pause(int time) {
             try {
                 Thread.sleep(time);
             } catch(InterruptedException e) {
               System.out.println(e.toString());
         public void run() {
              Thread thisThread = Thread.currentThread();
                   while(thisThread == runner) {
    class Level extends java.applet.Applet {
        Font BigText = new Font("Arial", Font.PLAIN, 36);
        Font Normal = new Font("Arial", Font.PLAIN, 14);
        Font Bold = new Font("Arial", Font.BOLD, 14);
        Graphics GrLevel;
        int pattern, sky, GroundtoWalk, Ground;
        Color BgColor = new Color(166,202,240);
        Color gras1 = new Color(0,255,0);
        Color gras2 = new Color(0,200,0);
        Color gras3 = new Color(0,100,0);
        Image ImgLevel;
        void setBgColor(int r, int g, int b) {
            BgColor = new Color(r,g,b);
        void CalcGraphics() {
            ImgLevel = createImage(800,600);
            GrLevel = ImgLevel.getGraphics();
        void setGround(int GrounD) {
            Ground = GrounD;
        void GroundToWalkADD(int addToGround) {
            GroundtoWalk = Ground + addToGround;
        void setGroundToWalk(int GrToWalk) {
            GroundtoWalk = GrToWalk;
        public void init() {
              System.out.println("Init 1"); // This was placed here when i was checking how far it got when debuging
              CalcGraphics();
              System.out.println("Init 2");
              drawGras(1);
              System.out.println("Init 3");
              repaint();
              System.out.println("Init 4");
        Image getLevelImage() {
            return ImgLevel;
        public void paint(Graphics g) {
              g.drawImage(ImgLevel,0,0,this);
        public void update(Graphics g) {
            paint(g);
        void drawGras(int pt) {
         GrLevel.setColor(BgColor);
         GrLevel.fillRect(0,0,800,600);
         switch(pt) {
              case 1:
                   GrLevel.setColor(gras1);
                   GrLevel.fillRect(0,GroundtoWalk,800,300);
                   GrLevel.setClip(0,GroundtoWalk,800,300);
                   for(int i = 0; 890>i;i=i+5) {
                        GrLevel.setColor(gras2);
                        GrLevel.drawLine(0+i,GroundtoWalk,-190+i,GroundtoWalk+300);
                   for(int i=950; 0<i; i=i-5) {
                        GrLevel.setColor(gras3);
                        GrLevel.drawLine(890-i,GroundtoWalk,1000-i,GroundtoWalk+300);
              break;
              case 2:
                   GrLevel.setColor(gras2);
                   GrLevel.fillRect(0,GroundtoWalk+5,800,300);
                   for(int i = 0; 890>i;i=i+5) {
                        GrLevel.setColor(gras3);
                        GrLevel.drawLine(0+i,GroundtoWalk,-190+i,GroundtoWalk+300);
                   for(int i=950; 0<i; i=i-5) {
                        GrLevel.setColor(gras1);
                        GrLevel.drawLine(890-i,GroundtoWalk,1000-i,GroundtoWalk+300);
              break;
              case 3:
                   GrLevel.setColor(gras3);
                   GrLevel.fillRect(0,GroundtoWalk+10,800,300);
                   for(int i = 0; 800>i; i=i+20) {
                        GrLevel.fillArc(0+i,GroundtoWalk,20,20,180,-180);
              break;
         pattern = pt;
        int getGrasPattern() {
             return pattern;
        void drawSky(int cl) {
                GrLevel.setColor(BgColor);
                GrLevel.fillRect(0,0,800,155);
                switch(cl) {
                    case 1:
                   for(int y = 0;y<7;y++) {
                   for(int x = 0;x<800;x=x+20) {
                                GrLevel.setColor(Color.white);
                                GrLevel.drawArc(x,y*20,20,20,180,180);
                                GrLevel.setColor(Color.red);
                                GrLevel.drawArc(x,y*20+4,20,20,180,180);
                                GrLevel.setColor(Color.yellow);
                                GrLevel.drawArc(x,y*20+2,20,20,180,180);
                                GrLevel.setColor(Color.green);
                                GrLevel.drawArc(x,y*20+8,20,20,180,180);
                                GrLevel.setColor(Color.blue);
                                GrLevel.drawArc(x,y*20+12,20,20,180,180);
                                GrLevel.setColor(Color.pink);
                                GrLevel.drawArc(x,y*20+16,20,20,180,180);
              break;
              case 2:
                        GrLevel.setColor(Color.gray);
              break;
         sky = cl;
         GrLevel.setFont(BigText);
         GrLevel.setColor(Color.black);
         GrLevel.fillRect(0,0,800,50);
         GrLevel.setColor(Color.white);
         GrLevel.drawString("Score Tabel - comming someday",((size().width)/2)-260, 40);
        int getSkyTyp() {
             return sky;
    }I tested running the code of class Level by puting it into Level.java and compiled it...ran it with appletviewer and it worked as it was intended to.
    But when i compiled it with MainGame... and in the HTML started MainGame.class,.....applet didn't intializeand i got the following error messege:
    Init 1
    java.lang.NullPointerException
            at Level.CalcGraphics(MainGame.java:84)
            at MainGame.<init>(MainGame.java:11)Line 82: void CalcGraphics() {
    Line 83: ImgLevel = createImage(800,600);
    Line 84: GrLevel = ImgLevel.getGraphics(); // The First awt.Graphics object
    Line 85: }
    Line 9:      public MainGame() {
    Line 10:     Level nr1 = new Level();
    Line 11:     nr1.CalcGraphics(); // calling the method above -> same error first awt.Graphics Object.
    If i change it os that "drawGras" comes first it's first awt.Graphics Line will show the same error
    Hope some one can and will help me

    As per the documentation of
    java.awt.Component.createImage(int,int):
    Creates an off-screen drawable image to be used for
    double buffering.
    Parameters:
    width - the specified width
    height - the specified height
    Returns:
    an off-screen drawable image, which can be used for
    double buffering. The return value may be null if the
    component is not displayable. This will always happen
    if GraphicsEnvironment.isHeadless() returns true.
    Since:
    JDK1.0 its not
    ImgLevel = createImage(800,600); that's making the problem but The first awt.Graphics Object in class Level, no mather which on it is =((
    >
    The key part is '...may be null if the component is
    not displayable.'
    You should put your graphics initialization code in
    start(), which will be called when your applet is
    ready to go. Before then, your applet is not
    displayable. (Also, remember to dispose() your
    graphics in your stop() method, if not sooner.)for the part writen above...I'll try to change it like you are saying.
    Thanx for your help!

  • Flash IDE, opaque white screen from inside a graphic object

    I'm sorry if this has been answered, I couldn't find anything about it.
    When I'm editing a graphic object on the stage (not from the library) everything else is under this opaque white screen so I can't see their true color.
    Is there a way to disable it?
    Thanks.

    No. It's a convenience feature to help you retain alignment and get sort of an onion skin idea of where you are.
    Tou can always take a screenshot and put it in a locked background layer under your clip of your content to simulate the full color. It's all about how complex you need it to be.
    If the background is animated then the good old way is the only way. Copy the frames from inside the clip (hopefully not to complex), make a new layer in the content you want to edit it in with full color, paste frames, make changes, then copy it back into your previous MovieClip.
    I myself always desire that semi-transparent white to make the clips contents obvious but I have wanted to disable that before to ink dropper select some colors.

  • Table linking graphics object to a smartform

    Hello,
    We are changing logos/ bitmap images that contains our address ( because we are moving to another place).
    Is anyone aware of a table that links the graphics object to a smartform?  For eg, All the texts in a smartform is available in table STXFTX. This helps to have a where used list kind of report.
    We are not able to find that can give us a hwere used list of graphic objects loaded via se78.
    If anyone could give some pointers, that owuldbe of great help.
    Thanks
    Ganesh.S

    You would need to scan the source code for each of your generated function modules.  The graphics calls are directly embedded in the generated code and are called at runtime via function SSFCOMP_PRINT_GRAPHIC.  Check one of your functions and you will see how this works.

  • Printing graphics object in Landscape or portrait mode

    Hello,
    I have a graphics 2d object (a Tree Diagram) which is inside a JScrollPane,and the JSCrollPane is on a JPanel. it's length and width is more than one page. I am using a printable object to print the object. The task I need to do is,
    (1). compress the width and length of the diagram, so that if can fit into one page, else split the diagram into pages, so that each part of it can be printed on different pages(page size A4) and then later those pages can be merged accordingly.
    I am not able to find, how to split the graphic object(the tree diagram into pages), shoul d I try doing it using x and y co ordinate of the graphic object.

    * PrintUtilities.java
    * Created on January 17, 2007, 7:25 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package action.vector.bam;
    * @author serjith
    import java.awt.*;
    import javax.swing.*;
    import java.awt.print.*;
    import javax.print.attribute.HashPrintRequestAttributeSet;
    import javax.print.attribute.PrintRequestAttributeSet;
    /** A simple utility class that lets you very simply print
    * an arbitrary component. Just pass the component to the
    * PrintUtilities.printComponent. The component you want to
    * print doesn't need a print method and doesn't have to
    * implement any interface or do anything special at all.
    * <P>
    * If you are going to be printing many times, it is marginally more
    * efficient to first do the following:
    * <PRE>
    * PrintUtilities printHelper = new PrintUtilities(theComponent);
    * </PRE>
    * then later do printHelper.print(). But this is a very tiny
    * difference, so in most cases just do the simpler
    * PrintUtilities.printComponent(componentToBePrinted).
    * 7/99 Marty Hall, http://www.apl.jhu.edu/~hall/java/
    * May be freely used or adapted.
    public class PrintUtilities implements Printable {
    private Component componentToBePrinted;
    public static void printComponent(Component c) {
    new PrintUtilities(c).print();
    public PrintUtilities(Component componentToBePrinted) {
    this.componentToBePrinted = componentToBePrinted;
    public void print() {
    PrinterJob printJob = PrinterJob.getPrinterJob();
    PrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
    PageFormat pgFormat = printJob.pageDialog(set);
    printJob.setPrintable(this,pgFormat);
    //printJob.setPrintable(this);
    if (printJob.printDialog())
    try {
    printJob.print();
    } catch(PrinterException pe) {
    System.out.println("Error printing: " + pe);
    public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
    if (pageIndex > 0) { // requires change since it is bigger than a single page
    return(NO_SUCH_PAGE);
    } else {
    Graphics2D g2d = (Graphics2D)g;
    g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
    disableDoubleBuffering(componentToBePrinted);
    int W = componentToBePrinted.getWidth();
    int H = componentToBePrinted.getHeight();
    //Component newComp = componentToBePrinted.getGraphics().clipRect();
    System.out.println("WorkSpace Height "+H+" Width "+W);
    pageFormat.getHeight();
    pageFormat.getWidth();
    pageFormat.setOrientation(PageFormat.LANDSCAPE);
    //componentToBePrinted.paint(g2d);
    componentToBePrinted.printAll(g2d);//.paintAll(g2d);
    enableDoubleBuffering(componentToBePrinted);
    return(PAGE_EXISTS);
    /** The speed and quality of printing suffers dramatically if
    * any of the containers have double buffering turned on.
    * So this turns if off globally.
    * @see enableDoubleBuffering
    public static void disableDoubleBuffering(Component c) {
    RepaintManager currentManager = RepaintManager.currentManager(c);
    currentManager.setDoubleBufferingEnabled(false);
    /** Re-enables double buffering globally. */
    public static void enableDoubleBuffering(Component c) {
    RepaintManager currentManager = RepaintManager.currentManager(c);
    currentManager.setDoubleBufferingEnabled(true);
    =============================================================
    Please find this code, which I am trying to use, here I am passing the JPanel
    try{                   
    PrintUtilities.printComponent(actWorkSpace);
    }catch(Exception ex){
    ex.printStackTrace();
    the actWorkSpace is a JPanel with graphics as mentioned above, which is being passes to PrintUtilities.printComponent();
    the output is only just a single page with just a portion of the graphics on the JPanel, pls help...... it is urgent....

  • Question on Graphics Object

    Dear all,
    A Graphics object draw on some surface. It would be appreciated if anyone could explain to me which surface is the Graphics object is drawn on? How to determine? How to change it?
    Many thanks!
    Francis

    Hello,
    A graphics object is a graphic context : Every objects where you can draw something can be associated to a Graphics object.
    For example, an image, an paper of a printer can have a Graphics abject.
    Graphics contains graphical objects like in ps.
    See Graphics objects as links.

  • Rotate Graphics object

    I need to implement rotation on graphics objects in a project that does NOT used graphics2d. Changing the code so that it does not use Graphics but Graphics2D would take a really long time. Is there a way to cast from one type of object to the other or is there some fast way to convert the code?

    I am not sure what you are asking for. Are you saying that the Graphics object that you have been using so far in your project is not an instance of Graphics2D, i.e., if your Graphics object is g then
    g instanceof Graphics2D evaluates to false?
    I don't even know how to get an such an instance, so in that case I may not be able to help you. All Graphics objects that I have encountered are instances of Graphics2D although references to this object may have been declared as Graphics. If that is also the case for your Graphics object, then all you need to do is to declare a new Graphics2D reference and set it to point to your Graphics object cast into Graphics2D (which is one line of code, which I showed you earlier). Then you could rename all usages of the old reference to the new reference (if you are using an IDE, then chances are that it will have refactoring support that will make this easy).
    *Actually, you do not need to rename all usages, only those usages where you call a method that is not in Graphics.*
    I don't think you need to convert any of you shapes. I don't understand what you mean by converting shapes to 2D shapes.
    Edited by: James_Vagabond on Jan 3, 2008 9:12 AM

  • How to use change document object ?

    Friends,
    I am learning to use the Change Document object for one of my Z table. I have created a change doc object using SCDO. I have now written a test report in which i am issuing the SELECT statement for fetching old and new values from the Z table and passing them to the FM generated by SCDO.
    I am not able to see the changes in the CDHDR and CDPOS tables. I am doubtful abt the values being passed to the FM. Here are the values i am passing:
    CALL FUNCTION 'YTEST_WRITE_DOCUMENT'
      EXPORTING
        objectid                      = 'YTEST'
        tcode                         = 'se38'
        utime                         = sy-uzeit
        udate                         = sy-datum
        username                      = sy-uname
      PLANNED_CHANGE_NUMBER         = ' '
       OBJECT_CHANGE_INDICATOR        = 'U'
      PLANNED_OR_REAL_CHANGES       = ' '
      NO_CHANGE_POINTERS            = ' '
       UPD_ICDTXT_YTEST               = 'U'
        n_ztest_cle                   = wa_ztest_cle
        o_o_ztest_cle                 = o_ztest_cle
      UPD_ZTEST_CLE                 = ' '
      tables
        icdtxt_ytest                  = itab_cdtxt.
    Is the object ID the same as the Change Document Object name ??
    Please help.
    Thanks,
    Ram.

    Well, i found a way out for the problem i was facing. I was not setting the "UPD_ZTEST_CLE " FM parameter. When i set it to 'U', the changes got reflected in the CDHDR and CDPOS tables.
    Can i reward myself as i solved this by myself ???

  • Getting "An attempt is made to create or change an object ..." in one env.

    I have a colleague who wrote some JAX-WS client code using what WebLogic 10.3.3 provides out of the box. His code is creating a "wsse:Security" element by using SOAPFactory and SOAPElement and related classes. This has worked fine on a couple of dev boxes. They've now promoted the deployment to the next environment, and now the attempt to add the constructed "Security" element fails with:
    org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
    They have verified the problem environment is running the same version of the JDK and WebLogic, but they haven't yet confirmed they have the same WebLogic patches.
    I repeat, this is working fine on his development environment and on at least two development servers, and is having this problem on the next environment down the line towards production.
    I looked for some other experiences with this error, and the only substantive code suggestion I found from that was to add all the used namespaces to the envelope. He did that, but it didn't make a difference.
    The relevant block of code is the following (it fails on the last line):
                        SOAPEnvelope envelope = soapMsgContext.getMessage().getSOAPPart().getEnvelope();
                        SOAPFactory soapFactory = SOAPFactory.newInstance();
                        // WSSecurity <Security> header
                        SOAPElement wsSecHeaderElm = soapFactory.createElement(
                                  "Security",
                                  AUTH_PREFIX,
                                  AUTH_NS);
                        QName wsSecHdrMustUnderstandAttr = new QName("S:mustUnderstand");
                        wsSecHeaderElm.addAttribute(wsSecHdrMustUnderstandAttr, "1");
                        SOAPElement userNameTokenElm = soapFactory.createElement("UsernameToken",
                                  AUTH_PREFIX,
                                  AUTH_NS);
                        Name userNameTokenIdName = soapFactory.createName(
                                  "id",
                                  "wsu",
                                  "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
                        userNameTokenElm.addAttribute(userNameTokenIdName, "Id-8zvykuwmK8yg6dxn3632nQJB");
                        SOAPElement userNameElm = soapFactory.createElement("Username",
                                  AUTH_PREFIX,
                                  AUTH_NS);
                        userNameElm.addTextNode(userName);
                        SOAPElement passwdElm = soapFactory.createElement("Password",
                                  AUTH_PREFIX,
                                  AUTH_NS);
                        Name passwdTypeAttr = soapFactory.createName("Type");
                        passwdElm.addAttribute(passwdTypeAttr, "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
                        passwdElm.addTextNode(password);
                        userNameTokenElm.addChildElement(userNameElm);
                        userNameTokenElm.addChildElement(passwdElm);
                        // add usernametoken to Security header
                        wsSecHeaderElm.addChildElement(userNameTokenElm);
                        // create SOAPHeader instance for SOAP envelope
                        SOAPHeader sh = envelope.getHeader();
                        // add SOAP element for header to SOAP header object
                        sh.addChildElement(wsSecHeaderElm);
    -------------------------

    if it matters, after extensive gnarly debugging, we found the problem was this expression:
    new QName("S:mustUnderstand")
    When we changed this to properly specify the prefix and namespace, the environment it was failing on worked.
    What was odd about this is that other server environments seemingly using the same jars (we turned on verbose:class to verify this) had no problem with this code.
    What was really annoying about this problem is that the error message could have been much more informative. I'm sure the code reporting the error must have known it was this attribute that was having the problem, but it only gave us a very vague error message about the entire element we were creating, which had several sub-elements.

  • Trying to move a graphics object using buttons.

    Hello, im fairly new to GUI's. Anyway I have 1 class which makes my main JFrame, then I have another 2 classes, one to draw a lil square graphics component (which iwanna move around) which is placed in the center of my main frame and then another class to draw a Buttonpanel with my buttons on which is placed at the bottom of my main frame.
    I have then made an event handling class which implements ActionListner, I am confused at how I can get the graphics object moving, and where I need to place the updateGUI() method which the actionPerformed method calls from inside the event handling class.
    I am aware you can repaint() graphics and assume this would be used, does anyone have a good example of something simular being done or could post any help or code to aid me, thanks!

    Yeah.. here's an example of custom painting on a JPanel with a box. I used a mouse as it was easier for me to setup than a nice button panel on the side.
    Anyways... it should make it pretty clear how to get everything setup, just add a button panel on the side. and use it to move the box instead of the mouse.
    -Js
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.event.MouseEvent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.event.MouseInputAdapter;
    public class MoveBoxAroundExample extends JFrame
         private final static int SQUARE_EDGE_LENGTH = 40;
         private JPanel panel;
         private int xPos;
         private int yPos;
         public MoveBoxAroundExample()
              this.setSize(500,500);
              this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
              this.setContentPane(getPanel());
              xPos = 250;
              yPos = 250;
              this.setVisible(true);     
         private JPanel getPanel()
              if(panel == null)
                   panel = new JPanel()
                        public void paintComponent(Graphics g)
                             super.paintComponent(g);
                             g.setColor(Color.RED);
                             g.fillRect(xPos-(SQUARE_EDGE_LENGTH/2), yPos-(SQUARE_EDGE_LENGTH/2), SQUARE_EDGE_LENGTH, SQUARE_EDGE_LENGTH);
                   MouseInputAdapter mia = new MouseInputAdapter()
                        public void mousePressed(MouseEvent e)
                            xPos = e.getX();
                            yPos = e.getY();
                            panel.repaint();
                        public void mouseDragged(MouseEvent e)
                            xPos = e.getX();
                            yPos = e.getY();
                            panel.repaint();
                   panel.addMouseListener(mia);
                   panel.addMouseMotionListener(mia);
              return panel;
         public static void main(String args[])
              new MoveBoxAroundExample();
    }

  • Error releasing transport request for change document object

    Hi Gurus,
    I created a new change document object for a Z-table. When i try to release the transport request in the development system it terminated with a message "Export application-defined objects       17.12.2009 11:07:45 Not yet executed". The transport request continued to be in the "Release started" status and i am not able to release it.
    I checked in the co file & data file directory for this request, The co file is available but the data file is not created.
    Could you please let me know how to solve this?
    Regards,
    Immanuel.

    It was a problem with some basis settings. Was rectified by the basis team.

Maybe you are looking for