Search Results

Search found 1800 results on 72 pages for 'square eyes'.

Page 6/72 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Take input through Buttons in java

    - by stash211
    I understand that the title might not be descriptive enough, but I'm making a magic square game in Java and basically, I'm trying to replicate user input as found in the sudoku game here: http://www.websudoku.com/. What I have is a n x n grid of Buttons (not JButton) as the board and what I want the user to be able to do is when the user clicks on one of the buttons, similar to the game above, it allows the user to type in his guess in the button itself instead of popping up a dialog box with an input field of some sort. I don't know where to start, I am a beginner in Java (not very beginner, but my knowledge with the various Java APIs is very limited), so I'm trying to find out if this would be possible and if it is, how would I go about doing it? Thanks for any help.

    Read the article

  • Painting component inside another component

    - by mike_hornbeck
    I've got a task to display painted 'eyes' with menu buttons to change their colors, and background color. Next animate them. But currently I'm stuck at painting, sinc in my JFrame I've Created JPanel containing panels with drawn eyes and buttons. Buttons are rendered properly but my eyes canvas is not shown. I've tried changing paint to paintComponent, setting contentPane differently but still nothing works. import java.awt.*; import javax.swing.*; public class Main extends JFrame { public static void main(String[] args) { final JFrame frame = new JFrame("Eyes"); frame.setPreferredSize(new Dimension(600, 450)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel players = new JPanel(new GridLayout(1, 3)); players.add(new JButton("Eyes color")); players.add(new JButton("Eye pupil")); players.add(new JButton("Background color")); JPanel eyes = new JPanel(); Eyes e = new Eyes(); eyes.add(e); eyes.setPreferredSize(new Dimension(600, 400)); JPanel content = new JPanel(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); frame.setContentPane(content); content.add(players); content.add(eyes); // frame.getContentPane().add(content); frame.pack(); frame.setVisible(true); } } class Eyes extends JPanel { public Eyes(){ } public void paint(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); BasicStroke bs = new BasicStroke(3.0f); g2d.setBackground(Color.green); g2d.setStroke(bs); g2d.setColor(Color.yellow); g2d.fillOval(50, 150, 200, 200); g2d.fillOval( 350, 150, 200, 200); g2d.setColor(Color.BLACK); g2d.drawOval(49, 149, 201, 201); g2d.drawOval(349, 149, 201, 201); g2d.fillOval(125, 225, 50, 50); g2d.fillOval(425, 225, 50, 50); } } This is what I should get : This is what I have : When I've tried painting it directly in JFrame it works almost perfect, apart of background not being set. Why setBackgroundColor doesn't influence my drawing in any way ?

    Read the article

  • What algorithm to use to fill a KenKen square board with cages?

    - by JimmyBoh
    I am working on recreating KenKen, a popular math puzzle involving a blank grid that is divided into "cages". Each cage is just a collection of adjacent squares and has a clue which is generally a number and an operand, shown below: What type of algorithm would be best to fill the square with cages? Assume the maximum number of cells per cage would be 3 and the board is 4x4 in size, like in the example above.

    Read the article

  • Add kilometers to a map point

    - by proveyourselfthom
    Good morning. I would like to know how do I add kilometers to a map point (latitude / longitude). For example: The city Jaraguá do Sul is in latitude -26.462049, longitude -49.059448. I want to add 100 kilometers up, down, and on the sides. I want to do a square and get the new points. How do I do that? I tried it: <?php $distance = 100; $earthRadius = 6371; $lat1 = -26.4853239150483; $lon1 = -49.075927734375; $bearing = 0; $lat2 = asin(sin($lat1) * cos($distance / $earthRadius) + cos($lat1) * sin($distance / $earthRadius) * cos($bearing)); $lon2 = $lon1 + atan2(sin($bearing) * sin($distance / $earthRadius) * cos($lat1), cos($distance / $earthRadius) - sin($lat1) * sin($lat2)); echo 'LAT: ' . $lat2 . '<br >'; echo 'LNG: ' . $lon2; ?> But it's returning wrong cordinates. Thank you! Thank you very much.

    Read the article

  • Is the Asus Lion Square compatible with an AMD Athlon II AM3?

    - by wag2639
    I bought an Asus Lion Square compatible with a AMD Athlon II X3 435 Socket AM3 processor? I know strictly speaking, the Lion Square specifies AM2 but I'm a little confused since AM2 and AM3 are suppose to be socket compatible (I'm a little confused here as well but I assume it means an AM3 board will support AM2/AM2+ CPUs). However, will there be a problem with chip height and spacing? Or do people have experience asking ASUS for a standoff adapter?

    Read the article

  • How often is software speed evident in the eyes of customers?

    - by rwong
    In theory, customers should be able to feel the software performance improvements from first-hand experience. In practice, sometimes the improvements are not noticible enough, such that in order to monetize from the improvements, it is necessary to use quotable performance figures in marketing in order to attract customers. We already know the difference between perceived performance (GUI latency, etc) and server-side performance (machines, networks, infrastructure, etc). How often is it that programmers need to go the extra length to "write up" performance analyses for which the audience is not fellow programmers, but managers and customers?

    Read the article

  • Retrieving an element by array index in jQuery vs the each() function.

    - by Alex Ciminian
    I was writing a "pluginable" function when I noticed the following behavior (tested in FF 3.5.9 with Firebug 1.5.3). $.fn.computerMove = function () { var board = $(this); var emptySquares = board.find('div.clickable'); var randPosition = Math.floor(Math.random() * emptySquares.length); emptySquares.each(function (index) { if (index === randPosition) { // logs a jQuery object console.log($(this)); } }); target = emptySquares[randPosition]; // logs a non-jQuery object console.log(target); // throws error: attr() not a function for target board.placeMark({'position' : target.attr('id')}); } I noticed the problem when the script threw an error at target.attr('id') (attr not a function). When I checked the log, I noticed that the output (in Firebug) for target was: <div style="width: 97px; height: 97px;" class="square clickable" id="8"></div> If I output $(target), or $(this) from the each() function, I get a nice jQuery object: [ div#8.square ] Now here comes my question: why does this happen, considering that find() seems to return an array of jQuery objects? Why do I have to do $() to target all over again? [div#0.square, div#1.square, div#2.square, div#3.square, div#4.square, div#5.square, div#6.square, div#7.square, div#8.square] Just a curiosity :).

    Read the article

  • Python beautifulsoup trying to remove html tags 'span'

    - by Michelle Jun Lee
    I am trying to remove [<span class="street-address"> 510 E Airline Way </span>] and I have used this clean function to remove the one that is in between < > def clean(val): if type(val) is not StringType: val = str(val) val = re.sub(r'<.*?>', '',val) val = re.sub("\s+" , " ", val) return val.strip() and it produces [ 510 E Airline Way ]` i am trying to add within "clean" function to remove the char '[' and ']' and basically i just want to get the "510 E Airline Way". anyone has any clue what can i add to clean function? thank you

    Read the article

  • Making Visual C++ DLL from C++ class

    - by prosseek
    I have the following C++ code to make dll (Visual Studio 2010). class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; }; double x, y; void move(double dx, double dy); virtual double area(void) = 0; virtual double perimeter(void) = 0; static int nshapes; }; class __declspec(dllexport) Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { }; virtual double area(void); virtual double perimeter(void); }; class __declspec(dllexport) Square : public Shape { private: double width; public: Square(double w) : width(w) { }; virtual double area(void); virtual double perimeter(void); }; I have the __declspec, class __declspec(dllexport) Circle I could build a dll with the following command CL.exe /c example.cxx link.exe /OUT:"example.dll" /DLL example.obj When I tried to use the library, Square* square; square->area() I got the error messages. What's wrong or missing? example_unittest.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall ... Square::area(void)" (?area@Square@@UAENXZ) ADDED Following wengseng's answer, I modified the header file, and for DLL C++ code, I added #define XYZLIBRARY_EXPORT However, I still got errors. example_unittest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __th iscall Circle::Circle(double)" (__imp_??0Circle@@QAE@N@Z) referenced in function "protected: virtual void __thiscall TestOne::SetUp(void)" (?SetUp@TestOne@@MAEXXZ) example_unittest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __th iscall Square::Square(double)" (__imp_??0Square@@QAE@N@Z) referenced in function "protected: virtual void __thiscall TestOne::SetUp(void)" (?SetUp@TestOne@@MAEXXZ) example_unittest.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall Square::area(void)" (?area@Square@@UAENXZ) example_unittest.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall Square::perimeter(void)" (?perimeter@Square@@UAENXZ) example_unittest.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall Circle::area(void)" (?area@Circle@@UAENXZ) example_unittest.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall Circle::perimeter(void)" (?perimeter@Circle@@UAENXZ)

    Read the article

  • C++ beginner question regarding chars

    - by Samwhoo
    I'm just messing around with some C++ at the moment trying to make a simple tic-tac-toe game and I'm running into a bit of a problem. This is my code: #include <iostream> using namespace std; class Square { public: char getState() const; void setState(char); Square(); ~Square(); private: char * pState; }; class Board { public: Board(); ~Board(); void printBoard() const; Square getSquare(short x, short y) const; private: Square board[3][3]; }; int main() { Board board; board.getSquare(1,2).setState('1'); board.printBoard(); return 0; } Square::Square() { pState = new char; *pState = ' '; } Square::~Square() { delete pState; } char Square::getState() const { return *pState; } void Square::setState(char set) { *pState = set; } Board::~Board() { } Board::Board() { } void Board::printBoard() const { for (int x = 0; x < 3; x++) { cout << "|"; for (int y = 0; y < 3; y++) { cout << board[x][y].getState(); } cout << "|" << endl; } } Square Board::getSquare(short x, short y) const { return board[x][y]; } Forgive me if there are blatantly obvious problems with it or it's stupidly written, this is my first program in C++ :p However, the problem is that when I try and set the square 1,2 to the char '1', it doesn't print out as a 1, it prints out as some strange character I didn't recognise. Can anyone tell me why? :) Thanks in advance.

    Read the article

  • Parenting Opengl with Groups in LibGDX

    - by Rudy_TM
    I am trying to make an object child of a Group, but this object has a draw method that calls opengl to draw in the screen. Its class its this public class OpenGLSquare extends Actor { private static final ImmediateModeRenderer renderer = new ImmediateModeRenderer10(); private static Matrix4 matrix = null; private static Vector2 temp = new Vector2(); public static void setMatrix4(Matrix4 mat) { matrix = mat; } @Override public void draw(SpriteBatch batch, float arg1) { // TODO Auto-generated method stub renderer.begin(matrix, GL10.GL_TRIANGLES); renderer.color(color.r, color.g, color.b, color.a); renderer.vertex(x0, y0, 0f); renderer.color(color.r, color.g, color.b, color.a); renderer.vertex(x0, y1, 0f); renderer.color(color.r, color.g, color.b, color.a); renderer.vertex(x1, y1, 0f); renderer.color(color.r, color.g, color.b, color.a); renderer.vertex(x1, y1, 0f); renderer.color(color.r, color.g, color.b, color.a); renderer.vertex(x1, y0, 0f); renderer.color(color.r, color.g, color.b, color.a); renderer.vertex(x0, y0, 0f); renderer.end(); } } In my screen class I have this, i call it in the constructor MyGroupClass spriteLab = new MyGroupClass(spriteSheetLab); OpenGLSquare square = new OpenGLSquare(); square.setX0(100); square.setY0(200); square.setX1(400); square.setY1(280); square.color.set(Color.BLUE); square.setSize(); //spriteLab.addActorAt(0, clock); spriteLab.addActor(square); stage.addActor(spriteLab); And the render in the screen I have @Override public void render(float arg0) { this.gl.glClear(GL10.GL_COLOR_BUFFER_BIT |GL10.GL_DEPTH_BUFFER_BIT); stage.draw(); stage.act(Gdx.graphics.getDeltaTime()); } The problem its that when i use opengl with parent, it resets all the other chldren to position 0,0 and the opengl renderer paints the square in the exact position of the screen and not relative to the parent. I tried using batch.enableBlending() and batch.disableBlending() that fixes the position problem of the other children, but not the relative position of the opengl drawing and it also puts alpha to the glDrawing. What am i doing wrong?:/

    Read the article

  • GAME MAKER Problem with sprites! Can't see the sprite after mouse action

    - by user46882
    I have got a problem in Game Maker Pro: http://www.directupload.net/file/d/3646/egdpdu6u_gif.htm At the start we see a white square moving. If I press a key the square stop to move and the background changes to white. If the background changes to white a new animation/sprite should play on the same position where the white square was. BUT IT DOESNT! (Actually it is still there! It just does not move and this is fine) The animation is basically a sprite animation with some outlines of the square. If I press a key again, the background changes to white and we see the animation of the sprite.. but we do not see the animation of the sprites when it does not move. And this is strange!! I want to have the animation of the square when it doesn't move. But I don't get it.. by the way.. the .gif is a old version. I allready fixed the problem with the moving animation.. but I am still not able to play the animation if the square does not fly. The color of the animation is allready set to green or something! for better contrast. But still.. can't see it. Here is the code: obj.weisse.kugel.stepevent = the white square with the movements and sprite animations etc. if (global.kweiss == 1 ) { // vspeed = 8; //visible = true // sprite_index=spr_weisse_kugel; image_speed = 0; image_index = 0; } else if (global.kweiss == 0) { sprite_index=spr_animation_fade_out; image_speed =0.2; image_index=image_number-1 vspeed = 0; //visible = false // } then I have 1 create event for all the global.variables obj.global_var globalvar kweiss; kweiss = 1; globalvar kschwarz; kschwarz = 0; and then I have 1 controll stepevent in a new obj: if device_mouse_check_button_pressed (0, mb_left) { if background_color = c_black { background_color = c_white } else { background_color = c_black } // change of the square to white if (global.kweiss = 0) { global.kweiss = 1; } else { global.kweiss = 0; } if (global.kschwarz = 0) // change the square to black (other bullets.. we do not need this at the moment!) { global.kschwarz = 1; } else { global.kschwarz = 0; } Many thanks in advance

    Read the article

  • What kind of eye wear can I use to protect my eyes from staring at a screen all day?

    - by dr dork
    Many of us stare at computer screens all day. Lately, my eyes have been irritated from prolonged staring at my computer screens. Does anyone use or know of any eye wear technology that helps with this? About five years back, I bought a pair of prescription-1 eye glasses that had a no-glare layer put on them. It slightly helped, so I'm considering getting another pair. Is this the best option I have at this point? Thanks so much in advance for your wisdom!

    Read the article

  • What kind of eye wear can I use to protect my eyes from being irritated from staring at a screen all

    - by dr dork
    Many of us stare at computer screens all day. Lately, my eyes have been irritated from prolonged staring at my computer screens. Does anyone use or know of any eye wear technology that helps with this? About five years back, I bought a pair of non-prescription eye glasses that had a no-glare layer put on them by an optometrist. It slightly helped, so I'm considering getting another pair. Is this the best option I have at this point? Thanks so much in advance for your wisdom!

    Read the article

  • AS3 URLRequest in for Loop problem

    - by Adrian
    Hi guys, I read some data from a xml file, everything works great besides urls. I can't figure what's the problem with the "navigateURL" function or with the eventListener... on which square I click it opens the last url from the xml file for(var i:Number = 0; i <= gamesInput.game.length() -1; i++) { var square:square_mc = new square_mc(); //xml values var tGame_name:String = gamesInput.game.name.text()[i];//game name var tGame_id:Number = gamesInput.children()[i].attributes()[2].toXMLString();//game id var tGame_thumbnail:String = thumbPath + gamesInput.game.thumbnail.text()[i];//thumb path var tGame_url:String = gamesInput.game.url.text()[i];//game url addChild(square); square.tgname_txt.text = tGame_name; square.tgurl_txt.text = tGame_url; //load & attach game thumb var getThumb:URLRequest = new URLRequest(tGame_thumbnail); var loadThumb:Loader = new Loader(); loadThumb.load(getThumb); square.addChild(loadThumb); // square.y = squareY; square.x = squareX; squareX += square.width + 10; square.buttonMode = true; this.addEventListener(MouseEvent.CLICK, navigateURL); } function navigateURL(event:MouseEvent):void { var url:URLRequest = new URLRequest(tGame_url); navigateToURL(url, "_blank"); trace(tGame_url); } Many thanks!

    Read the article

  • C# iterator is executed twice when composing two IEnumerable methods

    - by achristoph
    I just started learning about C# iterator but got confused with the flow of the program after reading the output of the program. The foreach with uniqueVals seems to be executed twice. My understanding is that the first few lines up to the line before "Nums in Square: 3" should not be there. Can anyone help to explain why this happens? The output is: Unique: 1 Adding to uniqueVals: 1 Unique: 2 Adding to uniqueVals: 2 Unique: 2 Unique: 3 Adding to uniqueVals: 3 Nums in Square: 3 Unique: 1 Adding to uniqueVals: 1 Square: 1 Number returned from Unique: 1 Unique: 2 Adding to uniqueVals: 2 Square: 2 Number returned from Unique: 4 Unique: 2 Unique: 3 Adding to uniqueVals: 3 Square: 3 Number returned from Unique: 9 static class Program { public static IEnumerable<T> Unique<T>(IEnumerable<T> sequence) { Dictionary<T, T> uniqueVals = new Dictionary<T, T>(); foreach (T item in sequence) { Console.WriteLine("Unique: {0}", item); if (!uniqueVals.ContainsKey(item)) { Console.WriteLine("Adding to uniqueVals: {0}", item); uniqueVals.Add(item, item); yield return item; Console.WriteLine("After Unique yield: {0}", item); } } } public static IEnumerable<int> Square(IEnumerable<int> nums) { Console.WriteLine("Nums in Square: {0}", nums.Count()); foreach (int num in nums) { Console.WriteLine("Square: {0}", num); yield return num * num; Console.WriteLine("After Square yield: {0}", num); } } static void Main(string[] args) { var nums = new int[] { 1, 2, 2, 3 }; foreach (int num in Square(Unique(nums))) Console.WriteLine("Number returned from Unique: {0}", num); Console.Read(); } }

    Read the article

  • How to make smooth movements in OpenGL?

    - by thyrgle
    So this kind of on topic to my other OpenGL question (not my OpenGL ES question but OpenGL the desktop version). If you have someone press a key to move a square how do you make the square movement naturally and less jumpy but also at the same speed I have it now? This is my code for the glutKeyboardFunc() function: void handleKeypress(unsigned char key, int x, int y) { if (key == 'w') { for (int i = 0; i < 12; i++) { if (i == 1 || i == 7 || i == 10 || i == 4) { square[i] = square[i] + 1; } } glutPostRedisplay(); } if (key == 'd') { for (int i = 0; i < 12; i++) { if (i == 0 || i % 3 == 0) { square[i] = square[i] + 1; } } glutPostRedisplay(); } if (key == 's') { for (int i = 0; i < 12; i++) { if (i == 1 || i == 7 || i == 10 || i == 4) { square[i] = square[i] - 1; } } glutPostRedisplay(); } if (key == 'a') { for (int i = 0; i < 12; i++) { if (i == 0 || i % 3 == 0) { square[i] = square[i] - 1; } } glutPostRedisplay(); } } I'm sorry if this doesn't quite make sense I'll try to rephrase it in a better way if it doesn't make sense.

    Read the article

  • How to draw an unfilled square on top of a stream video using a mouse and track the object enclosed

    - by Haxed
    Hi, I am making an object tracking application. I have used Emgucv 2.1.0.0 to load a video file to a picturebox. I have also taken the video stream from a web camera. Now, I want to draw an unfilled square on the video stream using a mouse and then track the object enclosed by the unfilled square as the video continues to stream. This is what people have suggested so far:- (1) .NET Video overlay drawing(DirectX) - but this is for C++ users, the suggester said that there are .NET wrappers, but I had a hard time finding any. (2) DxLogo sample DxLogo – A sample application showing how to superimpose a logo on a data stream. It uses a capture device for the video source, and outputs the result to a file. Sadly, this does not use a mouse. (3) GDI+ and mouse handling - this area I do not have a clue. And for tracking the object in the square, I would appreciate if someone give me some research paper links to read. Any help as to using the mouse to draw on a video is greatly appreciated. Thank you for taking the time to read this. Many Thanks

    Read the article

  • Define a positive number to be isolated if none of the digits in its square are in its cube [closed]

    - by proglaxmi
    Define a positive number to be isolated if none of the digits in its square are in its cube. For example 163 is n isolated number because 69*69 = 26569 and 69*69*69 = 4330747 and the square does not contain any of the digits 0, 3, 4 and 7 which are the digits used in the cube. On the other hand 162 is not an isolated number because 162*162=26244 and 162*162*162 = 4251528 and the digits 2 and 4 which appear in the square are also in the cube. Write a function named isIsolated that returns 1 if its argument is an isolated number, it returns 0 if its not an isolated number and it returns -1 if it cannot determine whether it is isolated or not (see the note below). The function signature is: int isIsolated(long n) Note that the type of the input parameter is long. The maximum positive number that can be represented as a long is 63 bits long. This allows us to test numbers up to 2,097,151 because the cube of 2,097,151 can be represented as a long. However, the cube of 2,097,152 requires more than 63 bits to represent it and hence cannot be computed without extra effort. Therefore, your function should test if n is larger than 2,097,151 and return -1 if it is. If n is less than 1 your function should also return -1. Hint: n % 10 is the rightmost digit of n, n = n/10 shifts the digits of n one place to the right. The first 10 isolated numbers are N n*n n*n*n 2 4 8 3 9 27 8 64 512 9 81 729 14 196 2744 24 576 13824 28 784 21952 34 1156 39304 58 3364 195112 63 3969 250047

    Read the article

  • Technical differences between square and hexagon for a grid?

    - by Marlon Dias
    I'm developing a 2D city-building game and trying to decide on the type of grid. There will be vehicles, so the unit movement is important too. I know there are visual differences for using Squares or Hexagons, what I want know is: What are the issues for programming each type of grid regarding implementation and performance? Is there a tradeoff or specific benefit for using one of them in a game context?

    Read the article

  • How can I create a square 10x10 grid using nested for loops in Java? [migrated]

    - by help
    I'm trying to create a 10x10 grid using for loops in Java. I'm able to create rows going up and down but not repeating. for(int i = 1; i < temperatures.length; i++) { temperatures[i] = (temperatures[i-1] + 12) / 2; //takes average of 12 and previous temp } } public void paint(Graphics g) { for(int y = 1; y < 9; y++) { g.setColor(Color.black); g.drawRect(10, 10, 10, 10); g.drawRect(10, 10, 10, 20); g.drawRect(10, 10, 10, 30); g.drawRect(10, 10, 10, 40); g.drawRect(10, 10, 10, 50); g.drawRect(10, 10, 10, 60); g.drawRect(10, 10, 10, 70); g.drawRect(10, 10, 10, 80); g.drawRect(10, 10, 10, 90); g.drawRect(10, 10, 10, 100); for(int x = 1; x < 9; x++) { g.setColor(Color.black); g.drawRect(10, 10, 10, 10); g.drawRect(10, 10, 20, 10); g.drawRect(10, 10, 30, 10); g.drawRect(10, 10, 40, 10); g.drawRect(10, 10, 50, 10); g.drawRect(10, 10, 60, 10); g.drawRect(10, 10, 70, 10); g.drawRect(10, 10, 80, 10); g.drawRect(10, 10, 90, 10); g.drawRect(10, 10, 100, 10); } } } }

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >