CreateImage(int, int) problem -- or..?

I'm trying to get a program double buffered, and have followed the structure for doing so provided by Sun. However, the program does not work correctly.
Problem #1: I have to "manually" refresh the JFrame (put it behind a window, then bring it back to the foreground), and everything seems to work correctly.
Problem #2: When the program first starts, I get 2 NPE's.
Note: Both of these problems usually occur. Rarely, the entire thing runs perfectly with no problems at all.
Here is how the code is structured:
Graphics offScreen;
Image offScreenImage;
public void paint(Graphics screen)
update(screen);
public void update(Graphics toPaint)
if( offScreenImage == null )
offScreenImage = createImage(640, 480);     
offScreen = offScreenImage.getGraphics();
setBackground(Color.gray);          
board.draw(offScreen);
toPaint.drawImage(offScreenImage, 0, 0, null);     
} //end draw()
Also, the draw(Graphics) method from the board instance is:
public void draw(Graphics offScreen)
offScreen.drawImage(testImage, 25, 25, null);
What could be causing these problems? Is there anything special that needs to be done if I'm using separate object files to draw? The NPE's are always flagged at this line:
     board.draw(offScreen);
Any suggestions would be GREATLY appreciated.

problem #1: Try moving the initializing code from update to paint or make paint to call update. Paint is the method that is called first to paint the component, update is called to repaint it.
problem #2: "board.draw(offScreen);" can cause a NPE if a) board is null or b) offScreen is null. Which one is it?
Also, in swing you should override the paintComponent-method instead of paint. (And aren't swing components double buffered by default? I'm not sure about that...)

Similar Messages

  • SocketInputStream.read(byte[], int, int) extremely slow

    Hi everyone,
    I'm trying to send several commands to a server and for each command read one or more lines as response. To do that I'm using a good old Socket connection. I'm reading the response lines with BufferedReader.readLine, but it's very slow. VisualVM says, that SocketInputStream.read(byte[], int, int) is consuming most of the cpu time. A perl script, which does the same job, finishes in no time. So it's not a problem with the server.
    I'm runnning java version "1.6.0_12"
    Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
    Java HotSpot(TM) Server VM (build 11.2-b01, mixed mode) on Linux henni 2.6.25-gentoo-r7 #3 SMP PREEMPT Sat Jul 26 19:35:54 CEST 2008 i686 Intel(R) Core(TM)2 Duo CPU E6550 @ 2.33GHz GenuineIntel GNU/Linux and here's my code
    private List<Response> readResponse() throws IOException {
            List<Response> responses = new ArrayList<Response>();
            String line = "";
            while ( (line = in.readLine()) != null) {
                int code = -1;
                try {
                    code = Integer.parseInt(line.substring(0, 3));
                    line = line.substring(4);
                } catch (Exception e) {
                    code = -1;
                // TODO create different response objects ?!?
                NotImplemented res = new NotImplemented(code, line);
                responses.add(res);
                // we received an "end of response" line and can stop reading from the socket
                if(code >= 200 && code < 300) {
                    break;
            return responses;
        }Any hints are appreciated.
    Best regards,
    Henrik

    Though it's almost an sscce I posted there, I will try to shrink it a little bit:
    Dummy server:
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintStream;
    import java.net.ServerSocket;
    import java.net.Socket;
    public class Server {
        public Server() throws IOException {
            ServerSocket ss = new ServerSocket(2011);
            Socket sock = ss.accept();
            BufferedReader br = new BufferedReader(new InputStreamReader(sock.getInputStream()));
            PrintStream ps = new PrintStream(sock.getOutputStream());
            ps.println("200 Welcome on the dummy server");
            String line = "";
            while(line != null) {
                line = br.readLine();
                ps.println("200 Ready.");
        public static void main(String[] args) throws IOException {
            new Server();
    }the client:
    import java.io.IOException;
    import java.io.PrintStream;
    import java.net.InetSocketAddress;
    import java.net.Socket;
    import java.net.UnknownHostException;
    import java.util.Scanner;
    import de.berlios.vch.Config;
    public class Client {
        private Socket socket;
        private PrintStream out;
        private Scanner scanner;
        public Client(String host, int port, int timeout, String encoding)
            throws UnknownHostException, IOException {
            socket = new Socket();
            InetSocketAddress sa = new InetSocketAddress(host, port);
            socket.connect(sa, timeout);
            out = new PrintStream(socket.getOutputStream(), true, encoding);
            scanner = new Scanner(socket.getInputStream(), encoding);
        public synchronized void send(String cmd) throws IOException {
            // send command to server
            out.println(cmd);
            // read response lines
            readResponse();
        public void readResponse() throws IOException {
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine();
                System.out.println(line);
                int code = -1;
                try {
                    code = Integer.parseInt(line.substring(0, 3));
                    line = line.substring(4);
                } catch (Exception e) {
                    code = -1;
                if (code >= 200 && code < 300) {
                    break;
        public static void main(String[] args) {
            try {
                Client con = new Client("localhost", 2011, 500, "utf-8");
                con.readResponse();
                con.send("version 0.1");
                con.send("menu = new menu Feeds");
                con.send("menu.EnableEvent close");
                con.send("menu.SetColorKeyText -red 'Öffnen'");
                for (int i = 0; i < 100; i++) {
                    String groupId = "group"+i;
                    long start = System.currentTimeMillis();
                    con.send(groupId+" = menu.AddNew OsdItem '"+groupId+"'");
                    con.send(groupId+".EnableEvent keyOk keyRed");
                    long stop = System.currentTimeMillis();
                    System.out.println((stop-start)+"ms");
            } catch (Exception e) {
                e.printStackTrace();
    }This code makes me believe, it's not a java problem, but some system setting of my os.

  • GregorianCalendar method add(int,int) in websphere5.1

    This bug report landed in my lap. The program is registering payments, and when user is registering multiple payments he gets the duedate set to 1970 from the second payment and on. Someone wrote on the bug report "method add(int,int) in GregorianCalendar doesn't work in WebSphere 5.1".
    So, when t>0 in the following code, things go haywire. Anyone have experience with this?
    dueDateG.clear();
    dueDateG.setLenient(false);
    dueDateG.setTime(dueDate);
    if (t==0)   addMonth = 0;
    else        addMonth = freq;
    dueDateG.add(Calendar.MONTH, addMonth);
    date = dueDateG.getTime();
    dueDate = date;

    By "Websphere 5.1" are you meaning Websphere Application Server 5.1 or Websphere Application Developer 5.1?
    The former (as known as WAS) uses IBM JDK 1.4.X (I believe that's 1.4.1); the later (as known as WSAD) can be used with any version of WAS starting from 4.X I believe.
    Some things can have problems when you're using IBM JDK's instead of Sun's, for instance trying to use the javax.crypto.* classes, that are different from Sun's; but I don't know if GregorianCalendar has problems. The first thing to do is insulate the code that you sent and try running it in IBM's and Sun's JDK. If you get problems only with IBM's JDK, you'll need to rewrite your code.

  • CreateStatement(int, int) performance

    Hi, I have some performance problems with the method createStatement(int, int) when using it on large tables (containing about 2,000,000 records). Does anyone already had the same prob?
    I use the createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)
    The DB used is DB2/400 on IBM iSeries.
    How is that method implemented? Does it fetch all elements??? Does it creates temp indexes??? I'm forced to use that method to be able to use a ResultSet.absolute(int) after...
    I've read somewhere that depending on the JDBC driver, we better use a count(*) in the sql query than a ResultSet.last() then ResultSet.getRow() because the last() will fetch all records. Maybe is it the same problem?
    Or maybe does anyone know if there's an equivalent of the absolute(int) in sql?
    Could anyone help me to find a solution for better performances?

    Indeed my question was not very clear sorry.
    Here's the context :
    In a web app, a user wants to make a search on client members, let's say the table has about 2,000,000 records of data.
    I have to display a page navigation system, let's say the user can display 50 records by page. He must be able to navigate through page 1 to the last page back and forward and with a step of 2 or more, and he can always reach the first and last page in a single click.
    That's why I used a scrollable ResultSet so I could use the rs.absolute(i) to position the cursor on the page I want to display, instead of doing rs.next() until I reach the correct position.
    That system works fine as long as there's not too much records. But unfortunately, some search without any criteria can give the total table, and I'm not in position to say there must be restriction on the search. The client is king.
    So I just wondered if there's a solution with good performance to doing so?
    My english is not very fluent so I hope it's understable ^^

  • Why JTextArea.select(int,int) not Highlight in java 1.4

    Hi guys
    Does anybody know why JTextArea.select(int, int) not Highlight the selected text in java 1.4. But java 1.3 works. Does java 1.4 change to use other method to hightlight the selected text in JTextArea? Thanks in advance.
    Regards,
    Mark.

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SelTest extends JPanel {
      private JTextArea area;
      public SelTest() {
        setLayout( new BorderLayout() );
        area = new JTextArea( "This is a sample text", 20, 20 );
        JButton btn = new JButton( "Select" );
        btn.addActionListener( new ActionListener(){
          public void actionPerformed( ActionEvent ae ){
            selectText2();
        add( area, BorderLayout.CENTER );
        add( btn, BorderLayout.SOUTH );
      private void selectText2(){
        area.requestFocus(); // MOST IMPORTANT
        area.select( 1, 4 );
        System.out.println("selcted : " + area.getSelectedText() );
      public static void main(String[] args) {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        f.getContentPane().add( new SelTest() );
        f.pack();
        f.setVisible( true );
    }

  • SetSize(int,int) not working in JTextPane.. Please help

    Hi,
    I want to set size of JTextPane so that by default it should show atleast 2 lines.
    I am using setSize(int, int) , but its not working.
    Can anybody help me?

    hi
    From onwards, I will take care of it.. I will put my query in particular category only.
    Actually I tried this one also...
    Following is my method in which I want to set size of JtextPane
    public JPanel initComponents(Vector columnNames, Vector dbNames, Vector data) {
    fieldrefs = new JTextComponent[columnNames.size()];
    JPanel content = new JPanel();
    content.setLayout(new GridBagLayout());
    content.setSize(900,900);
    // Create Menubar
    JMenuBar menuBar = createMenuBar();
    setJMenuBar(menuBar);
    GridBagConstraints gbc = new GridBagConstraints();
    //some code
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.insets = new Insets(SG_SwingUtilities.BORDER_COMP, // (top, left, bottom, right)
    SG_SwingUtilities.BORDER_COMP, 0, 0);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    JLabel pathLabel = new JLabel(stringPath);
    Font font = new Font(null, Font.BOLD, 12);
    pathLabel.setFont(font);
    content.add(pathLabel, gbc);
    // Insert all the fields.
    for (int i = 0, j = 0; i < columnNames.size(); i++, j += 2) {
    int gridy = i + 1;
    String label = (String) columnNames.elementAt(i); // Name of column.
    gbc = new GridBagConstraints();
    gbc.gridy = gridy;
    gbc.insets = new Insets(SG_SwingUtilities.BORDER_COMP, SG_SwingUtilities.BORDER_COMP, 0, 0);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    content.add(new JLabel(label), gbc);
    if ((i == 4 || i == 5) || (i == 2 && (isMacroNode || isSystemNode))) {
    // tagstart and tagend are expanded in HORIZONTAL direction.
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    if(i==5)
         styledDocEnd = new DefaultStyledDocument();
    fieldrefs[i] = new JTextPane(styledDocEnd);
    }else
    styledDocStart = new DefaultStyledDocument();
    fieldrefs[i] = new JTextPane(styledDocStart);
    if (i == 5) {
         textarea2 = new JTextPane(styledDocEnd); // I want to set this JtextPane size      
    textarea2 = (JTextPane)fieldrefs;
         fieldrefs[i].setSize(100,500);
    tagEndField = new JPanel(new GridBagLayout());
    content.add(tagEndField, gbc);
    normalComponent2 = new JScrollPane(fieldrefs[i]);
    setNormalMode(2);
    // my code
    else {
    // TagStart      
         textarea1 = new JTextPane(styledDocStart); // I want to set this JtextPane size
         textarea1 = (JTextPane)fieldrefs[i];//me
         fieldrefs[i].setSize(100,500);
    tagStartField = new JPanel(new GridBagLayout());
    content.add(tagStartField, gbc);
    normalComponent1 = new JScrollPane(fieldrefs[i]);
    setNormalMode(1);
    /// my code
    fieldrefs[i].addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent me) {
    // DOUBLE (left) CLICK
    if (data != null && !data.isEmpty()) {
    if (data.elementAt(j) != null) {
    String insertData = data.elementAt(j) + "";
    insertData = insertData.replaceAll("\\&\\{\\}", ""); // remove dummy ref
    insertData = insertData.replaceAll("\r", "");
    fieldrefs[i].setText(insertData);
    if(i==4 || i==2)
    insertLineBreaks(textarea1);
    updateColors(textarea1.getText(),true); //me
    if(i==5)
    insertLineBreaks(textarea2);
         updateColors(textarea2.getText(),false); //me
    else if (i == 5) {
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    fieldrefs[i] = new JTextArea(3, 10);
    fieldrefs[i].setForeground(new Color(0, 0, 255));
    // ((JTextArea) fieldrefs[i]).setLineWrap(true);
    if (data != null && !data.isEmpty()) {
    if (data.elementAt(j) != null) {
    String insertData = data.elementAt(j) + "";
    insertData = insertData.replaceAll("\\&\\{\\}", ""); // remove dummy ref
    fieldrefs[i].setText(insertData);
    content.add(new JScrollPane(fieldrefs[i]), gbc);
    else {
    fieldrefs[i] = new JTextArea(2, 10); // description field.
    ((JTextArea) fieldrefs[i]).setLineWrap(true);
    if (data != null && !data.isEmpty()) {
    if (data.elementAt(j) != null) {
    fieldrefs[i].setText(data.elementAt(j) + "");
    content.add(new JScrollPane(fieldrefs[i]), gbc);
    //code
    return content;
    } // initComponents
    protected JTextComponent[] fieldrefs = null; is taken from super class
    Message was edited by:
    ring

  • Units of parameters width and height  passed in drawRect(int,int,int,int)

    Units of parameters width and height passed in drawRect(int,int,int,int)

    Units of parameters width and height passed in drawRect(int,int,int,int)They are just units in the User Space. Since you can change the
    scale of the AffineTransform associated with your graphics object,
    you can't be more specific than that.
    Initially the claim is that the units are 96 per inch, but that isn't true.
    For example, change the resolution of your screen and run the code
    again!

  • JFrame.setSize(int, int) - how set window dimensions?

    Hello,
    In my simpliest swing apps I can't set window dimensions by setSize(int, int). What am I doing wrong?
    //v 1.3
    import javax.swing.*;   
    public class HelloWorldSwing {
        public static void main(String[] args) {
            JFrame frame = new JFrame("HelloWorldSwing");
            final JLabel label = new JLabel("Hello World");
            frame.getContentPane().add(label);
         frame.setSize(200, 200); //won't change anything??
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
    }

    .pack() is resizing the frame. Move setSize() after it.

  • Differing charts of accounts: INT - INT

    Hi
      While assigning company code to credit control area the following error is coming
    " Differing charts of accounts: INT - INT "
    How to solve this.
    Thanks
    Anto

    Hi Joseph,
    One would think that this will be something done by your functional folks.
    This area falls under their part.
    If they are talking about a total client copy from 000, then that may be something wiith which you can help them.
    Hope that helps.
    Abhi

  • PreparedStatement.setDate(int, Date) problem in WHERE clause

    Hello all,
    First and foremost, thanks for the help. It is really appreciated.
    I am having the toughest time tracking down a problem with how I am handling date setting with my PreparedStatement. The kicker is that I am only having problems with the where clause date sets.
    The date is pulled out of the database, put into a string, modified, put back into a date, and then used to query via SQL.
    Data selected this way:
    "SELECT * FROM table_name"
    Data updated this way:
    "UPDATE table_name SET name = ? WHERE pk_id = ? AND pk_date = ?"
    The java.sql.Date object I use to PreparedStatement.setDate(int, Date) is exact to seconds. It works great if it is not in the where clause (eg Inserts work, Updates work without where clause) which leads me to believe there is truncation of data somewhere between setDate(int, Date) and the native SQL in Oracle 9i.
    Is that a correct assumption? How do I solve this?
    Thanks,
    John

    My assumption was correct. If a java.sql.DATE is pulled from a Oracle 9i database it may have more data in it than is allowed for in java.sql.Date. java.sql.Timestamp, on the other hand, does retain all data in the field.
    The correct code looks something like this
    prepStmt.setTimestamp(Timestamp.valueOf(timeString));
    cheers,
    John

  • Characters(char,int,int) problem ???

    Hello, I'm using SAX to parse an XML file, but i run into a problem with the characters() method (well that's what I think). I use it to get the contents of text nodes, but sometimes (actually, only once) it will return only half of the text. But, you will tell me, this should be normal since the parser is allowed to call it twice in a row.
    But I create a StringBuffer myStringBuffer, then in characters(char[] buffer,int offset,int length) i do myStringBuffer.append(buffer,offset,length) and in endElement i try to process myStringBuffer, but still it contains only half of the text. This is all the more strange to me that my XML file is full of text nodes much longer than the troublesome one and i have no problem with those...and when i extract this s***** node and put it into another XML file, it works fine.
    So I'm somehow confused.
    Thanks in advance.

    Your logic certainly looks like it should work, but obviously it doesn't. Here's what I do:
    1. In the startElement() method, create an empty StringBuffer.
    2. In the characters() method, append the characters to it. Incidentally you don't need to create a String like you do, there's an "append(char[] str, int offset, int len)" method in StringBuffer which is very convenient in this case.
    3. In the endElement() method, use the contents of the StringBuffer.
    As for why parsers split text nodes, don't try to second-guess that. It's not your business as a user of the SAX parser. Some parsers will read the XML in blocks, and if a block happens to end in the middle of a text node, it splits the text node there. Others will see the escape "&amp;" in a text node and split the node into three parts, the part before the escape, a single "&" character, and the part after it. Saves on string manipulation, you see. There could be other reasons, too.

  • Web Services int.java Problem

    Hi, I'm totally new to Web Services can have a problem with JBuilder trying to generate a file named int.java from the WSDL. The WSDL is supplied by a TDA in my company and I've noticed that it has a few descriptions that include <restriction base="int"/>. When I import the WSDL and select the option to generate local server and then try to compile from the default generated files, it's looking for String.java (that's OK, even though it doesn't find it) and also int.java...which doesn't make sense to me, so it FAILS to compile properly. I've also noticed that there is a deployment file WSDD that has a type of "java:int" in it.
    This may be a basic issue, but I'm new to Web Services this week so any help would be appreciated.
    Thanks, Paul.

    Ok, I will make this simplier. Couple questions.
    Is it possible to use cfargument in a web service?
    I looked at the samples out there and they all just have
    queries that take a
    form variable (#form.name#) since it was being passed by a
    form.
    Is it possible to have one web service function invoke
    another function in
    the same cfc?
    If you have one function that calls another to first validate
    the user and
    then invoke another to get the search results, do all have to
    be remote or
    can you have the search be private since you dont want it
    invoked remotely.
    I.E.
    <cffunction name="search" access="remote"
    returntype="query">
    <cfset authenticate = authenticateUser(#username#)>
    <cfif authenticate EQ 'yes'>
    <cfset myResults = searchProperty(#mlsnumber#)>
    </cfif>
    <cfreturn my Results>
    </cffunction>
    I tried a simple city search and tried to pass a variable
    argument.
    <cfinvoke
    webservice="
    http://74.86.90.210/realitorToolBox/model/webservices/CityGateway.cfc?wsdl"
    method="findCity" city = "clinton" returnvariable="aQuery"/>to:
    <cffunction name="findCity" access="remote"
    returntype="query"> <cfquery name="getCities"
    datasource="MLSListings"> Select city FROM residential WHERE
    city = '#city#' </cfquery> <cfreturn getCities>
    </cffunction>And I still get a function cannot be found, even
    though I used the cfcexplorer to verify that it does exist on the
    remote server.Any ideas?

  • Int delta problem

    hi to all
            I am trying  load data into DSO 0crm_proh from the datasource 0crm_srv_process_h.  i cant do it it show up an error i have checked with all the target there are no data request is available.
    Delete init. request REQU_4EHGGTDUIKLI78GA0WUGE4V28 before running init. again with same selection
    help me in sloving this issue
    thank u
    gopu77

    Hi,
        irrespective of the load being Success or fail, a flag is been when schedule Init delta.so, it doesn't allows you to reschedule init delta again.to deselect
                                 Infopackage -
    >Scheduler menu--->Initialization Option for Source system-->Uncheck the falg
    and try to run init again.
    Best way is to run Full load first and then Init with the flag initialize without data transfer   set and then delta
    Thanks
    Sandeep

  • Graphics.drawImage(Image, int, int, Observer) fails on custom CompositeMode

    We created some custom CompositeModes for which the following trivial example code is representative:
    import java.awt.*;
    import java.awt.image.*;
    public class AddARGBComposite implements Composite
         static private AddARGBComposite instance = new AddARGBComposite();
         final private float alpha;
         public static AddARGBComposite getInstance( final float alpha )
              if ( alpha == 1.0f ) { return instance; }
              return new AddARGBComposite( alpha );
         private AddARGBComposite()
              this.alpha = 1.0f;
         private AddARGBComposite( final float alpha )
              this.alpha = alpha;
         public CompositeContext createContext( ColorModel srcColorModel, ColorModel dstColorModel, RenderingHints hints )
              return new CompositeContext()
                   public void compose( Raster src, Raster dstIn, WritableRaster dstOut )
                        final int[] srcPixel = new int[ 4 ];
                        final int[] dstInPixel = new int[ 4 ];
                        for ( int x = 0; x < dstOut.getWidth(); x++ )
                             for ( int y = 0; y < dstOut.getHeight(); y++ )
                                  src.getPixel( x, y, srcPixel );
                                  dstIn.getPixel( x, y, dstInPixel );
                                  final float srcAlpha = srcPixel[ 3 ] / 255.0f * alpha;
                                  dstInPixel[ 0 ] = Math.min( 255, Math.round( srcPixel[ 0 ] * srcAlpha + dstInPixel[ 0 ] ) );
                                  dstInPixel[ 1 ] = Math.min( 255, Math.round( srcPixel[ 1 ] * srcAlpha + dstInPixel[ 1 ] ) );
                                  dstInPixel[ 2 ] = Math.min( 255, Math.round( srcPixel[ 2 ] * srcAlpha + dstInPixel[ 2 ] ) );
                                  dstInPixel[ 3 ] = 255;
                                  dstOut.setPixel( x, y, dstInPixel );
                   public void dispose()
    }Using this CompositeMode for composing two images using the trivial method fails :
    BufferedImage image1, image2;
    Graphics2D g = image1.getGraphics();
    g.setComposite( AddARGBComposite.getInstance( 0.5f )  );
    g.drawImage( image2, 0, 0, null );Using a trivial AfifneTransform, it also fails because for integer translation, Graphics seems to fall back to the integer method above:
    AffineTransform at = new AffineTransform();
    g.drawImage( image2, at, null );But for non-trivial AffineTransforms, it works perfectly:
    at.scale( 0.5f, 0.5f );
    g.drawImage( image2, at, null );We reproduced this on the Linux64 and Windows64 platform both with an Nvidia-graphics device and latest Sun Java 6 update 16.
    Is the bug on our side missing something in the CompositeMode implementation or is this a bug in java.awt?
    Thanks in advance for any helpful comments.

    First, can you explain what you mean by fail - Is your compose method never called? Does it get called, but the results are unexpected? What are the results? Or is just as if image2 was never drawn?
    Second, In you're test case, what types are image1 and image2?
    BufferedImage image1, image2; //<-----
    Graphics2D g = image1.getGraphics();
    g.setComposite( AddARGBComposite.getInstance( 0.5f )  );
    g.drawImage( image2, 0, 0, null );You're making two assumptions in your AddARGBComposite code: 1) The source image has an alpha channel and is un-premultiplied, and 2) both the source and destination images are in rgb space. This could conceivably cause certain combinations of image types to fail, which is why I ask what types your image1 and image2 are. All other things considered, it seems to work on my machine. Though I'm in a Windows32 environment with 1.6.0_16.
    From experience though, there is a problem with creating a custom composite and using GUI widgets under the new D3D graphics pipeline that was made the default since java 1.6.10 (I think that's when it was made default, I can't remember).
    Basically, one or all of src, dstIn, and dstOut use a DataBuffer of type D3DNativeDataBuffer. And traditional calls into this native DataBuffer to retrieve or set data elements end up creating a non-trivial object or two. Multiply that object creation by the many thousands of pixels in a single image and you have a noticiable slow down. It's a similar reason why drawing a BufferedImage.TYPE_CUSTOM is pretty slow.
    Again, this only applies to throwing GUI widgets into mix, not drawing one user-created BufferedImage ontop of another.

  • Printlinst (int,int) in primities cannot be applied to (int[]

    hey guys im having a problem with my printlist (myArray);
    can you help me please
    replies returned asap would be much appreciated
    import java.util.*;
    public class primitives
    public static void main(String[]args)
    int n;
    int [ ] myArray;
    myArray = new int[n];
    Scanner kybd=new Scanner(System.in);
    public static int add(int[] myArray, int next, int newData)
    if (next < myArray.length)
    myArray[next]=newData;
    next++;
    System.out.println(newData +"added");
    next = add( myArray, next, 12) ;
    next= add( myArray, next, 16);
    next = add( myArray, next, -1);
    printlist(myArray, next);
    else
    System.out.println("array full ");
    return next;
    public static void printlist (int myArray, int next)
    for (int i =0; i < myArray.length; i++)
    { System.out.print(myArray,next);
    }

    ali88 wrote:
    hey guys im having a problem with my printlist (myArray);
    can you help me please
    replies returned asap would be much appreciatedYour question has nothing to do with Sun Instant Messaging server, I suggest you ask on the Java programming forum:
    http://forums.sun.com/forum.jspa?forumID=31
    Regards,
    Shane.

  • How does repaint(int,int,int,int) work?

    Hi there,
    I ant to force the update of a rectangular region of a canvas, but
    issuing repaint(x,y,w,h) does not seem to reach the update method.
    repaint() without arguments works fine.
    Is there anything else to set up in order to get repaint(x,y,w,h)
    properly?
    Regards

    Thanks for the hint, but revalidate is Swing and
    Canvas is AWT. Can it be that the repaint(int,...)
    doesn't work that well in AWT?

Maybe you are looking for

  • Installed new SSD. How do I get my files back from Time Machine?

    Hi all, if you take the time to read my issue, thanks a lot. I appreciate any help you can offer, and sorry if anything is unclear... The 1tb drive eventually failed on my 2009 27", quad core i7 imac. I had USB backup using time machine to an externa

  • Field REBZG in FI tables

    Hi, We see that field REBZG in table BSAD, which is most of the times empty, sometimes it gets updated with either letter ‘V’ or with the FI document number. In which cases the field is filled with the FI document and why ( related to clearing docume

  • NullPonterException while executing web service

    Hello, all. I have a strange problem with web services created via workshop 8.1beta. If I try to use JMS-XML method of invoking web service, the whole process seems ok. My code in method of a web service executes without problems, but the service res

  • Oracle EBS R12: E-Business Essentials

    I plan to take the Oracle EBS R12: E-Business Essentials exam... is there any good way to study for this? Any online reference, pdf or cds anyone has used? Any info would be helpful, thanks. -J

  • How do I get into my iphone if I forget the passcode?

    I have forgotten my passcode and now am locked out. How do I get back into the device?