Odd behavior in class using Random

Hi all, I am learning C# and built a simple Windows Form app using C# 2010 to experiment with generating random numbers. The app has two buttons and a list box. The code in the button click event is the following:
private void button1_Click(object sender, EventArgs e)
Random rx = new Random();
listBox1.Items.Clear();
for (int i = 0; i<3;i++)
listBox1.Items.Add(rx.NextDouble());
This behaves as expected generating 3 random numbers between 0 and 1.
In the second button click event I have the following code which is similar tothe previous snippet, but uses a function to get the random number:
private void button2_Click(object sender, EventArgs e)
listBox1.Items.Clear();
for (int i = 0; i < 3; i++)
listBox1.Items.Add(GetRnd());
private double GetRnd()
Random rx = new Random();
return rx.NextDouble();
This also works, but I noticed that each time I clicked the button I would generally get the same 2 or 3 random number. After some research and experimentation I concluded that the random # generator was being called so quickly between each iteration that
the same time seed was being used. To solve the problem I moved the Random rx declaration outside of the GetRnd function.
This fixed this issue. I then wanted to see how this function would behave if I placed it in a class:
class clsExample
//Declarations...
Random rx = new Random();
private static double GetRnd()
//Random rx = new Random();
return rx.NextDouble();
This does not work. The source editor places a red squiggly line under the instance name "rx" in the function's return statement. The message provided by the editor: An object reference is required for the non-static field , method or property
'WindowsFormsApplication1.clsExample.rx'.
This error goes away if I instantiate the Random class inside the function, as shown in the snippet above. But if I do this then the randoms numbers repeat. What am I missing? Why does this solution work in the form class and not in the class that I added?
As always, thank you for your help! Saga
Insanity is the prelude to discovery

It seemed to me, from the code you posted previously, that you maybe wanted to use something static. So, rather than remove the static modifier from the method, as Stefan suggested, it might be preferable to add a static modifier to the rx field instead.
// I changed the class name
public class MyRandom
//Declarations...
private static Random rx = new Random();
public static double GetRnd()
return rx.NextDouble();
Then, you'd use it like this:
listBox1.Items.Add(MyRandom.GetRnd());
~~Bonnie DeWitt [C# MVP]
http://geek-goddess-bonnie.blogspot.com

Similar Messages

  • Writing a class using random generator in bluej

    Hello
    Im trying to write a class for a deck of cards. Im using a random generator but I dont know how to write the instance variable.
    I have to make 4 suits heart, club, spade, dimonds. and 13 for face value. I know how to random generate numbers. Like if I were making a slot machine to give me 3 numbers in a rage from 0-10. Thats just numbers. How do I random generate values of 1-13 and have it output a random suit? Also how do I make it say if its a jack king or queen? Do I need a constructor or how would I make the card with the face value of 13 suit heart and the card be a queen.
    before jumping down my throat about this being a homework assignment...yes it is but this step Im seeking help on there is no example for this type of generating.
    Thanks for any help
    Rewind

    Well, this is far from bullet-proof, but I think gets the basic idea across. This does sampling with replacement; if you wanted to do something like shuffle a deck of cards you'll need a smarter approach than this.
    import java.util.*;
    public class RandomCards {
      public static void main(String[] args) {
        Suit suit=new Suit();
        for (int i=0; i < 10; i++) {
          System.out.println(suit.nextSuit());
      private static class Suit {
        public static final String HEART="Heart";
        public static final String DIAMOND="Diamond";
        public static final String SPADE="Spade";
        public static final String CLUB="Club";
        private final String[] SUITS={ HEART, DIAMOND, SPADE, CLUB };
        private Gen suitGen=new Gen(0,3);
        public String nextSuit() {
          return SUITS[suitGen.nextInt()];
      private static class Gen {
        private int floor,ceiling;
        private Random rand;
        public Gen(int floor, int ceiling) {
          this.floor=floor;
          this.ceiling=ceiling;
          rand=new Random();
        public int nextInt() {
          return rand.nextInt(ceiling-floor)+floor;

  • Odd behavior when using custom Composite/CompositeContext and antialiasing

    Hi,
    I created a custom Composite/CompositeContext class and when I use it with antialiasing it causes a black bar to appear. I seems it has nothing to do with the compose() code but just that fact that I set my own Composite object. The submitted code will show you what I mean. There are 3 check boxes 1) allows to use the custom Composite object, 2) allows to ignore the compose() code in the CompositeContext and 3) toggles the antialiasing flag in the rendering hints. When the antialiasing flag is set and the Composite object is used the bar appears regardless of if the compose() method is executed or not. If the Composite object is not used the bar goes away.
    The Composite/CompositeContext class performs clipping and gradient paint using a Ellipse2D.Float instance.
    a) When the Composite is not used the code does a rectangular fill.
    b) When the Composite is used it should clip the rectangular fill to only the inside of a circle and do a gradient merge of background color and current color.
    c) If the compose() method is ignored then only the background is painted.
    d) When antialiasing is turned on the black bar appears, i) if you ignore the compose() method it remains, ii) if you do not use the Composite object the bar disappears (???)
    NOTE: the compose method's code is only for illustration purposes, I know that AlphaComposite, clipping and/or Gradient paint can be used to do what the example does. What I am trying to find out is why the fact of simply using my Composite object with antialiasing will cause the odd behavior.  Been trying to figure it out but haven't, any help is appreciated.
    Thx.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class TestCustomComposite2
    extends JFrame
    implements ActionListener {
        private JCheckBox useCompositeChk, useAntialiasingChk, useCompositeContextChk;
        private Shape clippingShape = new Ellipse2D.Float(100, 100, 100, 100);
        private MergeComposite composite = new MergeComposite();
        public TestCustomComposite2() {
            super("Test Custom Composite");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel cp = (JPanel) getContentPane();
            cp.setLayout(new BorderLayout());
            cp.add(new TestCanvas(), BorderLayout.CENTER);
            JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
            panel.add(useCompositeChk = new JCheckBox("Use Composite", true));
            useCompositeChk.addActionListener(this);
            panel.add(useCompositeContextChk = new JCheckBox("Use Composite Context", true));
            useCompositeContextChk.addActionListener(this);
            panel.add(useAntialiasingChk = new JCheckBox("Use Antialiasing"));
            useAntialiasingChk.addActionListener(this);
            cp.add(panel, BorderLayout.SOUTH);
            pack();
            setVisible(true);
        public void actionPerformed(ActionEvent evt) {
            useCompositeContextChk.setEnabled(useCompositeChk.isSelected());
            invalidate();
            repaint();
        private class TestCanvas
        extends JComponent {
            public TestCanvas() {
                setSize(300, 300);
                setPreferredSize(getSize());
            public void paint(Graphics gfx) {
                Dimension size = getSize();
                Graphics2D gfx2D = (Graphics2D) gfx;
                gfx2D.setColor(Color.GRAY);
                gfx2D.fillRect(0, 0, size.width, size.height);
                RenderingHints rh = null;
                if(useAntialiasingChk.isSelected()) {
                    rh = gfx2D.getRenderingHints();
                    gfx2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                Rectangle r = clippingShape.getBounds();
                //gfx2D.setColor(Color.GREEN);
                //gfx2D.drawRect(r.x, r.y, r.width, r.height);
                gfx2D.setColor(Color.YELLOW);
                gfx2D.fill(clippingShape);
                Composite oldComposite = null;
                if(useCompositeChk.isSelected()) {
                    oldComposite = gfx2D.getComposite();
                    gfx2D.setComposite(composite);
                gfx2D.setColor(Color.ORANGE);
                gfx2D.fillRect(r.x, r.y, r.width + 1, r.height + 1);
                if(oldComposite != null)
                    gfx2D.setComposite(oldComposite);
                if(rh != null)
                    gfx2D.setRenderingHints(rh);
        public class MergeComposite
        implements Composite, CompositeContext {
            public CompositeContext createContext(ColorModel srcColorModel,
                                                  ColorModel dstColorModel,
                                                  RenderingHints hints) {
                return this;
            public void compose(Raster src,
                                Raster dstIn,
                                WritableRaster dstOut) {
                if(!useCompositeContextChk.isSelected())
                    return;
                int[] srcPixel = null;
                int[] dstPixel = null;
                for(int sy = src.getMinY(); sy < src.getMinY() + src.getHeight(); sy++) {
                    for(int sx = src.getMinX(); sx < src.getMinX() + src.getWidth(); sx++) {
                        int cx = sx - dstOut.getSampleModelTranslateX();
                        int cy = sy - dstOut.getSampleModelTranslateY();
                        if(!clippingShape.contains(cx, cy)) continue;
                        srcPixel = src.getPixel(sx, sy, srcPixel);
                        int ox = dstOut.getMinX() + sx - src.getMinX();
                        int oy = dstOut.getMinY() + sy - src.getMinY();
                        if(ox < dstOut.getMinX() || ox >= dstOut.getMinX() + dstOut.getWidth()) continue;
                        if(oy < dstOut.getMinY() || oy >= dstOut.getMinY() + dstOut.getHeight()) continue;
                        dstPixel = dstIn.getPixel(ox, oy, dstPixel);
                        float mergeFactor = 1.0f * (cy - 100) / 100;
                        dstPixel[0] = merge(mergeFactor, srcPixel[0], dstPixel[0]);
                        dstPixel[1] = merge(mergeFactor, srcPixel[1], dstPixel[1]);
                        dstPixel[2] = merge(mergeFactor, srcPixel[2], dstPixel[2]);
                        dstOut.setPixel(ox, oy, dstPixel);
            protected int merge(float mergeFactor, int src, int dst) {
                return (int) (mergeFactor * src + (1.0f - mergeFactor) * dst);
            public void dispose() {
        public static void main(String[] args) {
            new TestCustomComposite2();
    }

    I got a better version to work as expected. Though there will probably be issues with the transformation to display coordinates as mentioned before. At least figured out some of the kinks of using a custom Composite/CompositeContext object.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class TestCustomComposite2
    extends JFrame
    implements ActionListener {
        private JCheckBox useCompositeChk, useAntialiasingChk, useCompositeContextChk;
        private Shape clippingShape = new Ellipse2D.Float(100, 100, 100, 100);
        private MergeComposite composite = new MergeComposite();
        public TestCustomComposite2() {
            super("Test Custom Composite");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel cp = (JPanel) getContentPane();
            cp.setLayout(new BorderLayout());
            cp.add(new TestCanvas(), BorderLayout.CENTER);
            JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
            panel.add(useCompositeChk = new JCheckBox("Use Composite", true));
            useCompositeChk.addActionListener(this);
            panel.add(useCompositeContextChk = new JCheckBox("Use Composite Context", true));
            useCompositeContextChk.addActionListener(this);
            panel.add(useAntialiasingChk = new JCheckBox("Use Antialiasing"));
            useAntialiasingChk.addActionListener(this);
            cp.add(panel, BorderLayout.SOUTH);
            pack();
            setVisible(true);
        public void actionPerformed(ActionEvent evt) {
            useCompositeContextChk.setEnabled(useCompositeChk.isSelected());
            invalidate();
            repaint();
        private class TestCanvas
        extends JComponent {
            public TestCanvas() {
                setSize(300, 300);
                setPreferredSize(getSize());
            public void paint(Graphics gfx) {
                Dimension size = getSize();
                Graphics2D gfx2D = (Graphics2D) gfx;
                gfx2D.setColor(Color.GRAY);
                gfx2D.fillRect(0, 0, size.width, size.height);
                RenderingHints rh = null;
                if(useAntialiasingChk.isSelected()) {
                    rh = gfx2D.getRenderingHints();
                    gfx2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                Rectangle r = clippingShape.getBounds();
                //gfx2D.setColor(Color.GREEN);
                //gfx2D.drawRect(r.x, r.y, r.width, r.height);
                gfx2D.setColor(Color.YELLOW);
                gfx2D.fill(clippingShape);
                Composite oldComposite = null;
                if(useCompositeChk.isSelected()) {
                    oldComposite = gfx2D.getComposite();
                    gfx2D.setComposite(composite);
                gfx2D.setColor(Color.ORANGE);
                gfx2D.fillRect(r.x, r.y, r.width + 1, r.height + 1);
                if(oldComposite != null)
                    gfx2D.setComposite(oldComposite);
                if(rh != null)
                    gfx2D.setRenderingHints(rh);
        public class MergeComposite
        implements Composite, CompositeContext {
            public CompositeContext createContext(ColorModel srcColorModel,
                                                  ColorModel dstColorModel,
                                                  RenderingHints hints) {
                return this;
            public void compose(Raster src,
                                Raster dstIn,
                                WritableRaster dstOut) {
    //            dumpRaster("SRC   ", src);
    //            dumpRaster("DSTIN ", dstIn);
    //            dumpRaster("DSTOUT", dstOut);
    //            System.out.println();
                if(dstIn != dstOut)
                    dstOut.setDataElements(0, 0, dstIn);
                if(!useCompositeContextChk.isSelected())
                    return;
                int[] srcPixel = null;
                int[] dstPixel = null;
                int w = Math.min(src.getWidth(), dstIn.getWidth());
                int h = Math.min(src.getHeight(), dstIn.getHeight());
                int xMax = src.getMinX() + w;
                int yMax = src.getMinY() + h;
                for(int x = src.getMinX(); x < xMax; x++) {
                    for(int y = src.getMinY(); y < yMax; y++) {
                        try {
                            // THIS MIGHT NOT WORK ALL THE TIME
                            int cx = x - dstIn.getSampleModelTranslateX();
                            int cy = y - dstIn.getSampleModelTranslateY();
                            if(!clippingShape.contains(cx, cy)) {
                                dstPixel = dstIn.getPixel(x, y, dstPixel);
                                dstOut.setPixel(x, y, dstPixel);
                            else {
                                srcPixel = src.getPixel(x, y, srcPixel);
                                dstPixel = dstIn.getPixel(x, y, dstPixel);
                                float mergeFactor = 1.0f * (cy - 100) / 100;
                                dstPixel[0] = merge(mergeFactor, srcPixel[0], dstPixel[0]);
                                dstPixel[1] = merge(mergeFactor, srcPixel[1], dstPixel[1]);
                                dstPixel[2] = merge(mergeFactor, srcPixel[2], dstPixel[2]);
                                dstOut.setPixel(x, y, dstPixel);
                        catch(Throwable t) {
                            System.out.println(t.getMessage() + " x=" + x + " y=" + y);
            protected int merge(float mergeFactor, int src, int dst) {
                return (int) (mergeFactor * src + (1.0f - mergeFactor) * dst);
            protected void dumpRaster(String lbl,
                                      Raster raster) {
                System.out.print(lbl + ":");
                System.out.print(" mx=" + format(raster.getMinX()));
                System.out.print(" my=" + format(raster.getMinY()));
                System.out.print(" rw=" + format(raster.getWidth()));
                System.out.print(" rh=" + format(raster.getHeight()));
                System.out.print(" tx=" + format(raster.getSampleModelTranslateX()));
                System.out.print(" ty=" + format(raster.getSampleModelTranslateY()));
                System.out.print(" sm=" + raster.getSampleModel().getClass().getName());
                System.out.println();
            protected String format(int value) {
                String txt = Integer.toString(value);
                while(txt.length() < 4)
                    txt = " " + txt;
                return txt;
            public void dispose() {
        public static void main(String[] args) {
            new TestCustomComposite2();
    }

  • Very odd behavior regarding variable naming with DataService.fill()

    I'm experiencing this odd behavior in LCDS 2.5, wich pertains
    to variable naming for the objects returned by a DataService.fill()
    call. I ceated a simple destination with a Java adapter. the Server
    side Java data object is defined as follows)
    package test;
    public class RepositoryObject
    private String m_strObjectId;
    private boolean m_bIsValid;
    private long m_lSize;
    [public setters and getters here]
    On Flex side, the ActionScript value object is defined as
    follows:
    package test
    [Bindable]
    [RemoteClass(alias="test.RepositoryObject")]
    public class RepositoryObject
    public var m_strObjectId:String;
    public var m_bIsValid:Boolean;
    public var m_lSize:Number;
    public function RepositoryObject()
    The FDS destination definition (in
    data-management-config.xml):
    <destination id="testDs">
    <adapter ref="java-dao" />
    <properties>
    <source>test.TestDS</source>
    <scope>application</scope>
    <metadata>
    <identity property="m_strObjectId"/>
    </metadata>
    <network>
    <session-timeout>20</session-timeout>
    <paging enabled="false" pageSize="10" />
    <throttle-inbound policy="ERROR" max-frequency="500"/>
    <throttle-outbound policy="REPLACE"
    max-frequency="500"/>
    </network>
    <server>
    <fill-method>
    <name>getObjects</name>
    </fill-method>
    </server>
    </properties>
    </destination>
    What I figured while debugging into the client was is the
    data returned by the service (I'm using the mx:DataService call)
    returns objects whose variable names
    do not match my definition:
    m_strObjectId becomes objectId
    m_lSize becomes size
    m_bIsValid becomes isValid
    I wonder why that renaming??? Basically "m_str" prefix was
    stripped and capital "O" became lower case "o" for my first
    variable etc.
    For instance, in a datagrid cell renderer I could not
    reference the returned value as {data.m_strObjectId}, but if I use
    {data.objectId}, it works.
    Any ideas why this behavior (which I found confusing and odd)
    would be greately appreciated.
    Robert

    The latter, as "getM_strObjectId " is an ugly name... don't
    tell me that causes issue...ok kidding, I got you. The
    setter/getter names are important in this context.
    Thanks a lot.
    Robert

  • Laptop battery odd behavior

    I recently purchased the HP PROBOOK 430 G1 13.3 128GB i3-4010u. I'm using it primarily for college for light workloads since I have a custom built PC I used for extensive tasks. However, even with the light workloads, I'm experiencing this odd behavior from my laptops battery. The laptop battery meter goes to 8 percent randomly. I have to put my laptop to sleep then wake it up or reset it then it returns to the normal battery levels. Again there's no pattern to it, it's completely random. I have obversed it since July 22nd when I first got it and got nothing. It probably happened 10-15 times. I don't want to send it in yet for a repair since I can't replicate the problem.
    I'm using HPFanControl by troubadix at constant medium fan level so I know it's not heating issues. I also never go above 50c
    I also ran the battery diagnostic in BIOS and it gave me no errors.
    I also tried to discharged my laptop and it still happened.
    Help?

    Hi @jlakersman,
    Your  HP ProBook 430 G1 is a commercial product and to get your issue more exposure I would suggest posting in the commercial forums. Here is a link to the Commercial Notebook forum.
    Please click “Accept as Solution ” if you feel my post solved your issue.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
    Thank you,
    BHK6
    I work on behalf of HP

  • I need help with this program ( Calculating Pi using random numbers)

    hi
    please understand that I am not trying to ask anymore to do this hw for me. I am new to java and working on the assignment. below is the specification of this program:
    Calculate PI using Random Numbers
    In geometry the ratio of the circumference of a circle to its diameter is known as �. The value of � can be estimated from an infinite series of the form:
    � / 4 = 1 - (1/3) + (1/5) - (1/7) + (1/9) - (1/11) + ...
    There is another novel approach to calculate �. Imagine that you have a dart board that is 2 units square. It inscribes a circle of unit radius. The center of the circle coincides with the center of the square. Now imagine that you throw darts at that dart board randomly. Then the ratio of the number of darts that fall within the circle to the total number of darts thrown is the same as the ratio of the area of the circle to the area of the square dart board. The area of a circle with unit radius is just � square unit. The area of the dart board is 4 square units. The ratio of the area of the circle to the area of the square is � / 4.
    To simuluate the throwing of darts we will use a random number generator. The Math class has a random() method that can be used. This method returns random numbers between 0.0 (inclusive) to 1.0 (exclusive). There is an even better random number generator that is provided the Random class. We will first create a Random object called randomGen. This random number generator needs a seed to get started. We will read the time from the System clock and use that as our seed.
    Random randomGen = new Random ( System.currentTimeMillis() );
    Imagine that the square dart board has a coordinate system attached to it. The upper right corner has coordinates ( 1.0, 1.0) and the lower left corner has coordinates ( -1.0, -1.0 ). It has sides that are 2 units long and its center (as well as the center of the inscribed circle) is at the origin.
    A random point inside the dart board can be specified by its x and y coordinates. These values are generated using the random number generator. There is a method nextDouble() that will return a double between 0.0 (inclusive) and 1.0 (exclusive). But we need random numbers between -1.0 and +1.0. The way we achieve that is:
    double xPos = (randomGen.nextDouble()) * 2 - 1.0;
    double yPos = (randomGen.nextDouble()) * 2 - 1.0;
    To determine if a point is inside the circle its distance from the center of the circle must be less than the radius of the circle. The distance of a point with coordinates ( xPos, yPos ) from the center is Math.sqrt ( xPos * xPos + yPos * yPos ). The radius of the circle is 1 unit.
    The class that you will be writing will be called CalculatePI. It will have the following structure:
    import java.util.*;
    public class CalculatePI
    public static boolean isInside ( double xPos, double yPos )
    public static double computePI ( int numThrows )
    public static void main ( String[] args )
    In your method main() you want to experiment and see if the accuracy of PI increases with the number of throws on the dartboard. You will compare your result with the value given by Math.PI. The quantity Difference in the output is your calculated value of PI minus Math.PI. Use the following number of throws to run your experiment - 100, 1000, 10,000, and 100,000. You will call the method computePI() with these numbers as input parameters. Your output will be of the following form:
    Computation of PI using Random Numbers
    Number of throws = 100, Computed PI = ..., Difference = ...
    Number of throws = 1000, Computed PI = ..., Difference = ...
    Number of throws = 10000, Computed PI = ..., Difference = ...
    Number of throws = 100000, Computed PI = ..., Difference = ...
    * Difference = Computed PI - Math.PI
    In the method computePI() you will simulate the throw of a dart by generating random numbers for the x and y coordinates. You will call the method isInside() to determine if the point is inside the circle or not. This you will do as many times as specified by the number of throws. You will keep a count of the number of times a dart landed inside the circle. That figure divided by the total number of throws is the ratio � / 4. The method computePI() will return the computed value of PI.
    and below is what i have so far:
    import java.util.*;
    public class CalculatePI
      public static boolean isInside ( double xPos, double yPos )
         double distance = Math.sqrt( xPos * xPos + yPos * yPos );        
      public static double computePI ( int numThrows )
        Random randomGen = new Random ( System.currentTimeMillis() );
        double xPos = (randomGen.nextDouble()) * 2 - 1.0;
        double yPos = (randomGen.nextDouble()) * 2 - 1.0;
        int hits = 0;
        int darts = 0;
        int i = 0;
        int areaSquare = 4 ;
        while (i <= numThrows)
            if (distance< 1)
                hits = hits + 1;
            if (distance <= areaSquare)
                darts = darts + 1;
            double PI = 4 * ( hits / darts );       
            i = i+1;
      public static void main ( String[] args )
        Scanner sc = new Scanner (System.in);
        System.out.print ("Enter number of throws:");
        int numThrows = sc.nextInt();
        double Difference = PI - Math.PI;
        System.out.println ("Number of throws = " + numThrows + ", Computed PI = " + PI + ", Difference = " + difference );       
    }when I tried to compile it says "cannot find variable 'distance' " in the while loop. but i thought i already declare that variable in the above method. Please give me some ideas to solve this problem and please check my program to see if there is any other mistakes.
    Thanks a lot.

    You've declared a local variable, distance, in the method isInside(). The scope of this variable is limited to the method in which it is declared. There is no declaration for distance in computePI() and that is why the compiler gives you an error.
    I won't check your entire program but I did notice that isInside() is declared to be a boolean method but doesn't return anything, let alone a boolean value. In fact, it doesn't even compute a boolean value.

  • IMac 21" late 09: Slow, screen flickering/tearing and odd behavior - the problem that puzzles everyone

    PLEASE HELP!
    My iMac 21" late -09, started acting a bit wierd a year ago. Things got worse rapidly, it got slower, the screen flickers/tears (see link below), short moments of lost internet connection, lost connection whit the keyboard (might be keyboard that is broken), almost overheats when gaming and odd behavior on some webbsites whit galleries and/or videos.
    Let's begin whit the screen: it's not vertikal lines or major distortions, just a subtle horisontal line that "wanders" from bottom to topp and some lagging from time to time. Looks like this: http://cl.ly/3i2W2o3S1D2T
    The wierd thing is that hi-res does not mean more "tearing". Yes the lagg and risk of tearing increases, but the connection seems to be: lots of movement=tearing. So a pixeld 240p video of people dancing can be way worse than a news debbate in1080p!?!
    Lost connection whit internet and keyboard rarely happens and is probably due to something else, but thought that was good to have in mind.
    Odd behavior: galleries ex: when browsing images on Facebook in fullscreen, the image sometimes jumps around in the beginning and when clicking on next the same picture might appear again or just nothing at all. When scrolling down overwiewing a gallery, the updating stops and you can't scroll down further. This problem appers mainly on FB, deviantart also acts a bit wierd but there is often small issues whit image sites. Doesn't help to switch browsers either!
    Videos: Youtube is horrible to use, stops loading, dosen't start loading, erases everything loaded (grey bar disapears and reloads), refuse to switch ressolution and suddenly stops the video like it was done! "ehh.. wasn't this 2min long? Not anymore, now its 34sec!". Mainly a Youtube problem but many similar sites can be a bit problematic to use.
    NO, it's not the HTML-5 problem or any standard flash issue and using a different browser dosen't help!
    Worst is the fact that most of these errors are not constant! One day your watching youtube or mabey a movie in VLC, a bit laggy, but almost no problem. Next day **** brakes lose and after 2hours of struggling you are ready to stabb yourself in the face!
    What i tried: Most easy buggfixes that might cause the above problems, updating most things, Switched from OS X SL to OS X ML, complete reinstall and some things i probably forgot by now. Then went to MacStore for repair, they didn't find anything wrong and said it worked fine after the standard diagnostic/repair program!?! Went home and everything was the same! Went a second time to MacStore, same result.
    So I'v reinstalled a few times and it seems to improve the Mac. But 2-3weeks later every error is back, even if I barely installed or downloaded anything!?!
    Any idea what this could be? Or is the graphic card broken and MacStore has a blind, inbred muppet as a technician?

    No I didn't. The first time i explained the problem thoroughly and thought that they just couldn't miss such a visual error. I was wrong. The second time the technician wasn't there so i showed the above clip to the salesstaff and explained everything onceagain. Later the technician called me and we talked for 10min.
    Btw, the problems always "manifests themselves", just varies between strenght and frequence.
    But all other issues aside, what could cause the tearing of the screen as seen int the above clip?

  • Accessing a different class using ActionPerformed

    hi
    im trying to access a method in a different class using
    public void actionPerformed (ActionEvent e) {
              if(e.getSource() == AuthorCombo) {
                   ComboAction();
              else if(e.getSource() == SearchButton){
                        SearchSystem();
    }and then using
    public class Book extends ViewPanel{
    public void SearchSystem(){// this is used to get the information from
                      //the combo boxs whixh can latter show
                      //the data in the text area
    tempBookNoList.clear();
              for(int a=0; a<AuthorList.size(); a++) {
                                  if(((String)AuthorCombo.getSelectedItem()
                                  ==AuthorList.get(a))
                                  &&((String)BookCombo.getSelectedItem()
                                  ==BookList.get(a))) {
                                       tempBookNoList.add((String)BookNoList.get(a));
                        String result = (String)tempBookNoList.get(a);
                        InfoArea.setText ((String)tempBookNoList.get(a));
    }          }//End neither random situation.to manipulate some data within the other class
    i keep getting the error
    .\ViewPanel.java:314: cannot resolve symbol
    symbol : method SearchSystem ()
    location: class ViewPanel
                        SearchSystem();
    ^
    1 error
    can anyone help me spot the problem

    in that case i do not know what could be the cause in this program
    the only area i think it could be is when the SearchSystem method in the Book class gets using the Action Performed method in the Viewpanel method, shown below
    public class Book extends ViewPanel{
    public void SearchSystem(){// this is used to get the information from
                      //the combo boxs whixh can latter show
                      //the data in the text area
              for(int a=0; a<AuthorList.size(); a++) {
                                  if(((String)AuthorCombo.getSelectedItem()
                                  ==AuthorList.get(a))
                                  &&((String)BookCombo.getSelectedItem()
                                  ==BookList.get(a))) {
                                  InfoArea.setText((String)BookNoList.get(a));
                   }which is called using
    public void actionPerformed (ActionEvent e) {
              if(e.getSource() == AuthorCombo) {
                   ComboAction();
              else if(e.getSource() == SearchButton){
                        theBook.SearchSystem();
    }but i cant see this being a problem as it all compiles

  • Odd behavior when duplicating pages

    I have run into some odd behavior when duplicating pages.
    First I spent many hours trying to acomplish a double trigger effect in which the last trigger opened a large image in a pop up window. Thanks to help from agm 123 and Sachin Hasija  see the posts here: http://forums.adobe.com/message/5186239#5186239
    And the result here: http://ljusa.businesscatalyst.com/stockholm--1.html
    I had to do a number of work arounds, but succeeded and will help anyone interested to reproduce this type of effect.
    My next step was to recreate this effect for another 50 pages. The best way I have found is to duplicate the first page. This is where it gets weird.
    When I create a duplicate and replace the images in the newly created pages (done by changing the fill to the new image) with different ones and save it the changes are effected on the original page, not the clone. No big problem, just switch the names and continue.
    The next problem that occurs is that when I go to make further copies a variety of odd behaviors creep in. The biggest problem is a repositioning or resizing of photo frames/containers. The images do not change, just move as the frame resizes. When I try to resize the frame it snaps back to it's larger new size. This is a phenomenon that I have seen in other instances in work with lightboxes and slideshows. It seems that some other unseen element has jumped into the frame with the original frame.
    The method I have used to create these pages is as described in the post at: http://forums.adobe.com/message/5186239#5186239
    It involves creating a blank composition widget and then placing a composition lightbox widget trigger into the blank hero.
    I have already invested more time than I should have on this and would like to keep it simple, yet as I have 50 pages to go I could start from scratch if someone has a better method of doing this.
    Suggestions?

    Just an update.
    I haven't seen the naming problem with duoplicates reoccur. I am however still stuggling with duplicates.
    I have a page with 5 image frames linked to images which in turn trigger a lightbox. When I create a duplicate of a page there is always at least one of my image frames that moves and or a link to an image that is dead. The only recourse I have had is to recreate one of the lifgtboxes for each new page I create. With all the formatting this is time consuming.
    I have tried copying and pasting the entire page into a blank page, but then there are even more problems.
    I have also tried to save my lightbox as a graphic style, but that dooesn't seem to work either.
    Please Help! I've got at least 45 more of these pages to replicate1

  • Photoshop CS4 - odd behavior in titling

    All,
    I edit video almost every night and every weekend and have been doing this for several years now.  Suddenly, I'm seeing an odd behavior now that I've never seen before. 
    I created a title that consists only of a red circle and have it as one of my title templates.  I've used the red circle template across many projects without problems  I use it to highlight an athlete in the video.  I use keying so that the circle stays around the athlete for the entire clip so that a coach can focus on the specific athlete during the action.  My videos are used by college coaches for recruiting high school athletes.
    In the last few days, when I select the red circle title and the Motion bar under Video Effects under Effects Control so I can perform the keying, the video will flip to black so that all I see is the red circle on a black background.  If I drag the scrubber a little, the video reappears with the red circle overlayed, but as soon as I release the scrubber, the video goes black again. This makes it impossible to change the key values for the title since I can't see the video.
    For trouble-shooting, I created a new red circle title from scratch but it behaves the same.  I tried using a completely different title but it behaves the same.
    I assume I inadvertantly hit a switch somewhere that has changed the behavior, but I can't figure this out.  If someone can tell me what I'm doing wrong, I would greatly appreciate your help.
    Thanks,
    Dan
    Windows 7 64-bit
    Adobe Production Premium CS4
    Adobe PPro CS4 4.2.1
    Canon AVCHD video with output typically to H.264
    Asus Laptop G74Sx with 8g RAM and Intel Core i7-2630QM CPU @2GHz

    What exaxctly are you talking about? Using the graphic in Premiere? If so, this is probably a more appropriate question for the PPro forum. That aside, why even bother? Premiere's title tool can do circles with transparency no problem and then After Effects has this neat parametric Circle effect and a motio0n tracker, too. Sounds like you love doing things the hard way....
    Mylenium

  • HELP! Odd behavior in Photoshop CS6. Anyone have a solution?

    Hi I am having really odd behavior in CS6. I have reset and cleared preferences. As you can see from the screenshot I have a rectangle shape layer but I have not assigned any shape layer effects to it.  PS is adding a black border on its own and I have no idea how to get rid of it. I have been using photoshop for 20 years and this is driving me nuts. I've never seen this behavior before. If I add a color overlay the line is still there. If I rasterize the shape layer then add a color overly  the outline disappears. But I don't want to raterize my shape layers. Anyone know how to get rid of it? Thank you in advance to anyone who might have a solution.

    You appear to be on Windows, so I couldn't help you anyway.
    But for the benefit of Photoshop Windows users, please consider the following:
    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    A screen shot of your settings or of the image could be very helpful too,
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • Generating unique no.'s using random function

    Hi,
    I'm trying to generate unique values for row and column say from 0-3
    and I read some where that if we use random.nextInt() we will get unique values but I'm getting repeated values.I'll appreciate if anyone can help me in this matter.Here's the code:
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    public class random{
    public static void main(String args[])
    int b[]=new int[4];
    int c[]=new int[4];
    int i;
    Date date;
    Random random;
    date=new Date();
    random = new Random(date.getTime());
    for(i=0;i<4;i++)
    digit = random.nextInt(4);
    b=digit;
    for(i=0;i<4;i++)
    digit = random.nextInt(4);
    c[i] = digit;
    for(i=0;i<4;i++)
    System.out.println("column array is" + c[i]);
    for(i=0;i<4;i++)
    System.out.println("row array is" + b[i]);
    }//end main
    }//end class
    Thanks
    Suneetha.

    here is my code for generating a random number but not a unique number. with a big enough number the possibility getting a unique is high so you may modify it to suit you need:
      private void initial_node()
        float Qxyd = -1, Qyzd = -1, Cxyd = -1, Cyzd = -1;
        long seed;
        Q_table = new float[row][col];
        seed = (long)( Math.random() * System.currentTimeMillis() * 100000000 );
        Random rand1 = new Random( seed );
        seed = (long)( Math.random() * System.currentTimeMillis() * 100000000 );
        Random rand2 = new Random( seed );
        seed = (long)( Math.random() * System.currentTimeMillis() * 100000000 );
        Random rand3 = new Random( seed );
        seed = (long)( Math.random() * System.currentTimeMillis() * 100000000 );
        Random rand4 = new Random( seed );
        for( int i = 0; i < row; i++ )
          do
            Qxyd = (float)( rand1.nextFloat() + (float)rand1.nextFloat() / 3 );
          while( Qxyd < 0.35 || Qxyd == -1 );
          Q_table[5] = Math.abs( Qxyd );
    do
    Qyzd = (float)( rand2.nextFloat() + (float)rand2.nextFloat() / 7 );
    while( Qyzd < 0.45 || Qyzd == -1 );
    Q_table[i][3] = Math.abs( Qyzd );
    do
    Cxyd = (float)( rand3.nextFloat() + (float)rand3.nextFloat() / 9 );
    while( Cxyd > 0.15 || Cxyd == -1 );
    Q_table[i][8] = Math.abs( Cxyd );
    do
    Cyzd = (float)( rand4.nextFloat() + (float)rand4.nextFloat() / 11 );
    while( Cyzd > 0.10 || Cyzd == -1 );
    Q_table[i][9] = Math.abs( Cyzd );

  • Issues Exiting Sleep Mode and Odd Behavior On Restart with GPU

    I'm running a completely stock HP P7-1240 desktop except for an EVGA GeForce GTX 750 TI SC GPU. The GPU runs fine when the computer is up and running (which is odd because the forums have several other threads mentioning that the 700 series should be incompatible with my BIOS).
    However, there are two main strange problems that have arisen since installing the GPU. One is that, whenever the computer enters sleep mode, it refuses to wake back up properly. It seems to me that the computer activates but does not send any signals out from the back panel (at the very least, no video signal because my monitors stay blank). On a rare occasion, it will wake back up properly, but at least 90% of the time, it needs to be restarted. Upon restart, sometimes the same issue occurs (no video output), and the computer needs to be restarted a second time before it will boot up again.
    This leads to the second problem. When starting, the computer goes to a black screen listing basic computer specs (see attached photo. At this screen, the computer does not respond to any input.  It proceeds to beep 3 times, all the same length and pitch spaced about 30 seconds apart. After the third beep, the screen goes black and then the computer boots up normally with no further odd behavior.
    Without the GPU, none of these issues happen. At the very least, not regularly.
    I have seen another thread mentioning that, although the HP support page for my desktop does not list it, there is a BIOS update for my motherboard that has fixed issues relating to more modern GPU's. By nature of it being a BIOS update that does not (appear to) officially support Windows 7, I'm hesitant to move forward with that potential solution.
    Although I'm planning to build myself a new computer from scratch at some point, I was hoping to at least get another year out of this machine, if not 2.  While this issue doesn't appear to be immediately threatening the stability of the computer, I can't help but think that this is an issue I should iron soon to avoid future issues (not to mention it would save me a fair amount of electricity to be able to enter sleep mode on a regular basis).
    Any suggestions would be greatly appreciated!
    This question was solved.
    View Solution.

    Hello @johnmwalker,
    I understand that you are having some issues with your HP Pavilion p7-1240 Desktop PC waking up from sleep mode. I am not sure how much can be done for the delay on your startup with an OEM BIOS you are limited in what you can do and since your graphic card works I think you would be better off not messing too much with the BIOS at this point. The one thing I would try is going into the BIOS using the HP Support document:BIOS Setup Utility Information and Menu Options, and under Advanced > Power-On Options set POST Messages to Disable and POST Delay (in seconds) to None.
    Now the waking from sleep mode issue  could just be the hybrid sleep setting causing you an issue with sleep mode. Use the following steps to disable hybrid sleep:
    Step 1. Click Start
    Step 2. Click Control Panel.
    Step 3. Click System and Security
    Step 4. Click Power Options
    Step 5. Click High Performance from Power Options
    Step 6. Click Change plan settings
    Step 7. Select Change advanced power settings
    Step 8. Click the plus (+) sign next to Sleep
    Step 9. Click the plus (+) sign next to Allow hybrid sleep
    Step 10. Select Off from the drop-down menu
    Step 11. Click OK
    Please re-post if you require additional support. Thank you for posting on the HP Forums. Have a great day!
    Please click the "Thumbs Up" on the bottom right of this post to say thank you if you appreciate the support I provide!
    Also be sure to mark my post as “Accept as Solution" if you feel my post solved your issue, it will help others who face the same challenge find the same solution.
    Dunidar
    I work on behalf of HP
    Find out a bit more about me by checking out my profile!
    "Customers don’t expect you to be perfect. They do expect you to fix things when they go wrong." ~ Donald Porter

  • Odd Behavior with Multi-page Forums

    I have observed an odd behavior, when navigating multi-page forums.
    As an example, I use the Premiere Elements Tips & Tricks sub-forum often, to link to helpful articles. It is, like most, a multi-page forum.
    As the order of the articles will change, as new replies are added, I often need to navigate to multiple pages, to find the one that I need. My bookmark opens that forum onto Page 1, which is normal. I then scroll that page, looking for what I want. If it is not there, I will use either the Next, or the Page 2 buttons to move on. As I have scrolled to the bottom of Page 1, the Next (or Page 2) page will open at the bottom, rather than at the top, the first time that I do this. Pages 3, and above, will always open at the top. Also, if I go back to Page 2, it now opens at the top. I only see this, when going from Page 1, to Page 2, and then, only the first time. Odd, but no deal breaker, as I just manually scroll back to the top of Page 2, and then scroll down, looking for a particular article.
    I am on Chrome and Win XP-Pro SP-3. I have not yet tried in IE 7 - my latest version.
    Has anyone else experienced this little anomaly?
    Hunt

    Adobe-admin,
    Sorry, but I am out of "points... "
    Thank you for the input. I just found it slightly odd behavior, and all that it means is a bit of scrolling, now that I know what to expect. In most cases, the average user probably does not go to Page 2 of a forum, but many of us do. If it becomes a pain, I'll just jump quickly to Page 3, and then back to Page 2.
    Hey, Adobe never promised to make my life perfect - just better... I can easily live with this, but thought I'd ask, in case it was OE on my part.
    Appreciated,
    Hunt

  • How can I Access the Flash "Slide class" using flex and ActionScript 3?

    Hi,
    I hope someone can help me solve a problem...
    I'm using the flex SwfLoader to load a flash side
    presentation as follows...
    <mx:SWFLoader id="ss_slides" source="ss_slides.swf"
    width="320" height="240"/>
    I would like to access the flash "Slide Class" using flex so
    I can make the following call...
    Slide.gotoNextSlide();
    Anyone know how I can do that?
    Would it be through the SwfLoader Object?
    Is there another way?
    F.Y.I. Here is a snippets about the Slide class from the
    Flash 8 help...
    Using the Slide class (Flash Professional only)
    You use the methods and properties of the Slide class to
    control slide
    presentations you create using the Screen Outline pane for a
    Flash Slide
    Presentation, to get information about a slide presentation
    (for example, to
    determine the number of child slides contained by parent
    slide), or to navigate
    between slides in a slide presentation (for example, to
    create "Next slide" and
    "Previous slide" buttons).
    You can also use the built-in behaviors that are available
    in the Behaviors
    panel to control slide presentations. For more information,
    see Adding controls
    to screens using behaviors (Flash Professional only) in Using
    Flash.
    Thanks,
    Chris S.

    Hi Chris,
    You cannot access the methods of the Flash 8 movie from Flex.
    And you can't do it the other way around either.
    The only way to communicate is to create a LocalConnection on
    each side.
    M.

Maybe you are looking for

  • Getting a problem while executing RFFOEDI1 program

    We are running a job which has the RFFOEDI1 as the one of the steps. This program is existing in two jobs. One job is for Proposal run and the other one is for payment processing. The job which is used for Proposal run is coming out with an error - 

  • T440s touchpad and trackpoint issue

    I have a new T440s which came with Windows 8, and I upgraded to 8.1 Nothing strange installed in it. Sometimes touchpad and/or trackpoint don't work at all after turning on, rebooting or recovering from a suspended state. It never fails while the sys

  • To see the share the scrap in PPM

    Dear gurus I wish to see the PPM for the characteristics after UD. I check in characteristics overview but I can see the share of scrap in % (i.e.-66.67%), kindly suggest the way to see in PPM Best Regards MK

  • Measuring point for Power Factor Meter

    Dear All Experts, I need to create PF meter as Measuring Point. I have created characteristic PF without any unit of measure assigned to it since PF is a ratio. Now if I create Measuring point using characteristic PF system does not allow me to creat

  • Kadmin: Missing parameters in krb5.conf required for kadmin client while in

    Hi all When i am going to run commands like kadmin addprinc -randkey kadmin ktadd -k i am receiving kadmin: Missing parameters in krb5.conf required for kadmin client while ininitializing kadmin interface any ideas?? What kind of parameters are missi