Search Results

Search found 33640 results on 1346 pages for 'java generics'.

Page 71/1346 | < Previous Page | 67 68 69 70 71 72 73 74 75 76 77 78  | Next Page >

  • How would I use JBox2d in Java?

    - by BluFire
    So I did some research and a found Box2d. I then proceeded to download it and the testbed. Now that i have it, I don't know how to properly use it. I'm looking for a clear simple answer on how to use the engine. The things I did was that I put it into a lib folder and referenced the JBox2D jar file. After that i got stuck. How can i use this to program games for android? I'm very confused since Box2d was intended for C++.

    Read the article

  • Java ResourceLoader.getResourceAsStream local resource

    - by Dajgoro Labinac
    Before using lwjgl, i used the Graphic method, and there i displayed imageicons, and i had the picture file located in the resources. I used: ImageIcon tcard = new ImageIcon(this.getClass().getResource("RCA.png")); to load the image. Now when i load textures in lwjgl, i have to use absolute paths to locate the file: tcard = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("C:/RCA.png")); I tried googling, but i didn't find anything helpful... How can i load the image from the local resources like in the first example?

    Read the article

  • libgdx - collision detection with tiled map java

    - by user2875021
    currently, I am working on a 2d rpg game which is similar to final fantasy 1-4. I can load up a tiled map and the sprite can walk freely on the map. However, I will like to create a wall for it to stop walking through it. I created three tiled layer Background, Collision, Overhead and one Collision object layer with rectangles only. "How do I handle collisions with the object layer in the tiled map?" "Do I have to create every single rectangle that is in the object layer with Rectangle rectangle = new Rectangle() and rectangle.set(x, y, width, height)in the code?" Thank you very much in advance. Any help is greatly appreciated!

    Read the article

  • Vectors with Circles Physics -java

    - by Joe Hearty
    This is a problem I've been having, When making a set number of filled circles at random locations on a JPanel and applying a gravity (a negative change in the y), each of the circles collide. I want them to have collision detection and push in the opposite direction using vectors but i don't know how to apply that to my scenario could someone help? public void drawballs(Graphics g){ g.setColor (Color.white); //displays circles for(int i = 0; i<xlocationofcircles.length-1; i++){ g.fillOval( (int) xlocationofcircles[i], (int) (ylocationofcircles[i]) ,16 ,16 ); ylocationofcircles[i]+=.2; //gravity if(ylocationofcircles[i] > 550) //stops gravity at bottom of screen ylocationofcircles[i]-=.2; //Check distance between circles(i think..) float distance =(xlocationofcircles[i+1]-xlocationofcircles[i]) + (ylocationofcircles[i+1]-xlocationofcircles[i]) ; if( Math.sqrt(distance) <16)

    Read the article

  • ArrayList in Java [on hold]

    - by JNL
    I was implementing a program to remove the duplicates from the 2 character array. I implemented these 2 solutions, Solution 1 worked fine, but Solution 2 given me UnSupportedoperationException. I am wonderring why i sthat so? The two solutions are given below; public void getDiffernce(Character[] inp1, Character[] inp2){ // Solution 1: // ********************************************************************************** List<Character> list1 = new ArrayList<Character>(Arrays.asList(inp1)); List<Character> list2 = new ArrayList<Character>(Arrays.asList(inp2)); list1.removeAll(list2); System.out.println(list1); System.out.println("*********************************************************************************"); // Solution 2: Character a[] = {'f', 'x', 'l', 'b', 'y'}; Character b[] = {'x', 'b','d'}; List<Character> al1 = new ArrayList<Character>(); List<Character> al2 = new ArrayList<Character>(); al1 = (Arrays.asList(a)); System.out.println(al1); al2 = (Arrays.asList(b)); System.out.println(al2); al1.removeAll(al2); // retainAll(al2); System.out.println(al1); }

    Read the article

  • java application architecture

    - by LostMohican
    We have to write an administration panel for many customers. But we want to have just one administration panel, and use it in various projects. This admin panel will have basic components such as access control logic, maker-checker system in changes, user logging and etc. It will also have reporting for the customer, logs of transaction of the customer (which can vary according to the industry such as mobile banking, banking, ticket sales). These components may have to be modified according to the business. So we are thinking about the architecture here, Is it OK to use jars of every basic components, and bring them together on a glue application? Or should we build each component as WARs and make interfaces between them? If there are any more ideas, it will be appreciated.

    Read the article

  • Java - Finding distance between player and tile in array

    - by Corey
    What is the best way performance wise to do this? When I click a tile I want it to get the distance and if I am close enough I can interact with the tile. One way would be to find the tile by doing mouse / tile width when I click correct? But then how would I get that tiles position? I know how to find the distance I just don't know how to get a certain tiles position from the array when I click it

    Read the article

  • Basic Java drawing program: issue with squares

    - by Caminek
    I'm trying to create a simple drawing program that creates a square where the user clicks and drags. The square displays correctly as long as either x or y remain positive with respect to the original click position. If both x and y are negative with respect to the original click position, the square grows/shrinks, but also wanders about the screen. Is there a way to swap the origin point from top-left to bottom-right or to keep the square from wandering?

    Read the article

  • Map rendering Libgdx Java

    - by user3165683
    Ok, so I am trying to create a 2D non-movable random tiled map. This is what I have so far: private void generateTile(){ System.out.print("tiletry1"); while(loadedTiles != 8100){ System.out.print("tiletry"); Texture currentTile = null; int tileX = 0; int tileY = 0; if (tileX == 120); tileY = 16; tileX = 0; game.batch.begin(); switch(MathUtils.random(2)){ case 0: //game.batch.draw(tile1, tileX, tileY); System.out.print("tile1"); currentTile = tile1; break; case 1: //game.batch.draw(tile2, tileX, tileY); System.out.print("tile2"); currentTile = tile2; break; case 2: //game.batch.draw(tile3, tileX, tileY); System.out.print("tile3"); currentTile = tile3; break; } tileX+=16; loadedTiles ++; game.batch.draw(currentTile, tileX, tileY); game.batch.end(); } } However, I can't see any of the tiles and the screen just looks green. This method is above my render method which I have: camera.update(); batch.setProjectionMatrix(camera.combined); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); game.batch.begin(); //other render stuff Why am I not able to see the tiles?

    Read the article

  • Please Critique Code (Java, Java2D, javax.swing.Timer)

    - by Trizicus
    Learn by practice right? Please critique and suggest anything! Thanks :) import java.awt.EventQueue; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import javax.swing.JFrame; public class MainWindow { public static void main(String[] args) { new MainWindow(); } JFrame frame; GraphicsPanel gp = new GraphicsPanel(); MainWindow() { EventQueue.invokeLater(new Runnable() { public void run() { frame = new JFrame("Graphics Practice"); frame.setSize(680, 420); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gp.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) {} public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} }); gp.addMouseMotionListener(new MouseMotionListener() { public void mouseDragged(MouseEvent e) {} public void mouseMoved(MouseEvent e) {} }); frame.add(gp); } }); } } GraphicsPanel: import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JPanel; import javax.swing.Timer; public class GraphicsPanel extends JPanel { Test t; Timer test; GraphicsPanel() { t = new Test(); setLayout(new BorderLayout()); add(t, BorderLayout.CENTER); test = new Timer(17, new Gameloop(this)); test.start(); } class Gameloop implements ActionListener { GraphicsPanel gp; Gameloop(GraphicsPanel gp) { this.gp = gp; } public void actionPerformed(ActionEvent e) { try { t.incX(); gp.repaint(); } catch (Exception ez) { } } } } Test: import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Toolkit; import javax.swing.JComponent; public class Test extends JComponent { Toolkit tk; Image img; int x, y; Test() { tk = Toolkit.getDefaultToolkit(); img = tk.getImage(getClass().getResource("images.jpg")); this.setPreferredSize(new Dimension(15, 15)); } @Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g.create(); g2d.setColor(Color.red); g2d.drawString("x: " + x, 350, 50); g2d.drawImage(img, x, 80, null); g2d.dispose(); } public void incX() { x++; } }

    Read the article

  • Help me with this java program

    - by aser
    The question : Input file: customer’s account number, account balance at beginning of month, transaction type (withdrawal, deposit, interest), transaction amount Output: account number, beginning balance, ending balance, total interest paid, total amount deposited, number of deposits, total amount withdrawn, number of withdrawals package sentinel; import java.io.*; import java.util.*; public class Ex7 { /** * @param args the command line arguments */ public static void main(String[] args) throws FileNotFoundException { int AccountNum; double BeginningBalance; double TransactionAmount; int TransactionType; double AmountDeposited=0; int NumberOfDeposits=0; double InterestPaid=0.0; double AmountWithdrawn=0.0; int NumberOfWithdrawals=0; boolean found= false; Scanner inFile = new Scanner(new FileReader("Account.in")); PrintWriter outFile = new PrintWriter("Account.out"); AccountNum = inFile.nextInt(); BeginningBalance= inFile.nextDouble(); while (inFile.hasNext()) { TransactionAmount=inFile.nextDouble(); TransactionType=inFile.nextInt(); outFile.printf("Account Number: %d%n", AccountNum); outFile.printf("Beginning Balance: $%.2f %n",BeginningBalance); outFile.printf("Ending Balance: $%.2f %n",BeginningBalance); outFile.println(); switch (TransactionType) { case '1': // case 1 if we have a Deposite BeginningBalance = BeginningBalance + TransactionAmount; AmountDeposited = AmountDeposited + TransactionAmount; NumberOfDeposits++; outFile.printf("Amount Deposited: $%.2f %n",AmountDeposited); outFile.printf("Number of Deposits: %d%n",NumberOfDeposits); outFile.println(); break; case '2':// case 2 if we have an Interest BeginningBalance = BeginningBalance + TransactionAmount; InterestPaid = InterestPaid + TransactionAmount; outFile.printf("Interest Paid: $%.2f %n",InterestPaid); outFile.println(); break; case '3':// case 3 if we have a Withdraw BeginningBalance = BeginningBalance - TransactionAmount; AmountWithdrawn = AmountWithdrawn + TransactionAmount; NumberOfWithdrawals++; outFile.printf("Amount Withdrawn: $%.2f %n",AmountWithdrawn); outFile.printf("Number of Withdrawals: %d%n",NumberOfWithdrawals); outFile.println(); break; default: System.out.println("Invalid transaction Tybe: " + TransactionType + TransactionAmount); } } inFile.close(); outFile.close(); } } But is gives me this : Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:840) at java.util.Scanner.next(Scanner.java:1461) at java.util.Scanner.nextInt(Scanner.java:2091) at java.util.Scanner.nextInt(Scanner.java:2050) at sentinel.Ex7.main(Ex7.java:36) Java Result: 1

    Read the article

  • Java file manager won't load in Firefox

    - by Arthur
    I am using Webmin and I can't get the file manager to load in Firefox. It is a simple, Java based file manager. When I try to load it I get the following error: This module requires java to function, but your browser does not support java Internet Explorer works fine and I have yet to try on Chrome. Java is installed and I have the same problem on Windows and Linux. Java seems to work fine with everything else, with the exception of webcams. Any advice on the issue would be appreciated. Edit: I just checked and it doesn't work in Chrome either.

    Read the article

  • Disable Java Plugin in Google Chrome?

    - by Jeff Atwood
    This is the second time I've had a drive-by executable installed on my machine using the following: Google Chrome 6 (latest) Windows 7, UAC on This happened while I was browsing for images to add to a gaming.se post; one of the sites I visited (to get an image of a transfer cable) must have had drive-by browser exploit code running. UAC alerted me that a weird temporary executable wanted to run, and I declined, but I still got the fake antivirus executable running on my machine. Sigh.. I do have Java installed because I upload stuff monthly to clearbits.net and their uploader is a Java plugin. So my best guess is, websites are doing drive-by installs using the massive numbers of zero-day vulnerabilities in the Java browser plugins. For now, I have uninstalled Java, which works. But I wondered if I could disable the Java plugin in Google Chrome instead. So, how do you disable these vulnerable plugins in Google Chrome? I can't find the UI.

    Read the article

  • Installing Java on a Virtual Private Server

    - by Martin Rowe
    I have recently managed to get my employer to pay for a vps. I teach and asked the vps provider to enable Perl, Python, Ruby, Tomcat and Java. They've done the first four (really quickly) but have got back to me asking which parts of Java I need. I think the Java Virtual Machine is a given but what other S/W do I need to get installed? I think by getting the vps I now have the chance to teach Enterprise Java and want to get into Java Message Server and Enterprise patterns. Can I get Glassfish installed or is that a silly question? What about servlets and beans? Thanks in anticipation Martin Rowe

    Read the article

  • how to solve out of memory error in java in amazon ec2 server

    - by sathishkumar
    can anyone explain about this error message? we are using IBM jre to run java application Its occupying more space on the server. JVMDUMP006I Processing dump event "systhrow", detail "java/lang/OutOfMemoryError" - please wait. JVMDUMP006I Processing dump event "systhrow", detail "java/lang/OutOfMemoryError" - please wait. JVMDUMP032I JVM requested Heap dump using '/home/sathish/jetty6/heapdump.20110417.114115.18926.0001.phd' in response to an event JVMDUMP010I Heap dump written to /home/sathish/jetty6/heapdump.20110417.114115.18926.0001.phd JVMDUMP032I JVM requested Heap dump using '/home/sathish/jetty6/heapdump.20110417.114115.18926.0002.phd' in response to an event JVMDUMP010I Heap dump written to /home/sathish/jetty6/heapdump.20110417.114115.18926.0002.phd JVMDUMP032I JVM requested Heap dump using '/home/sathish/jetty6/heapdump.20110417.114115.18926.0003.phd' in response to an event JVMDUMP010I Heap dump written to /home/sathish/jetty6/heapdump.20110417.114115.18926.0003.phd JVMDUMP032I JVM requested Java dump using '/home/sathish/jetty6/javacore.20110417.114115.18926.0004.txt' in response to an event JVMDUMP010I Java dump written to /home/sathish/jetty6/javacore.20110417.114115.18926.0004.txt

    Read the article

  • .desktop shortcuts aren't working for java applications in LXDE

    - by chaz
    I just installed minecraft on my LXDE desktop/Lubuntu machine and I'm trying to create a .desktop file on the desktop that executes java -jar ~/minecraftlauncher.jar. The command works in bash scripts and the terminal but refuses to work when I click on my .DESKTOP shortcut which is suppose to execute the same command. I've experimented with other jars and they can't seem to start too. Here is my xsession log: ** (pcmanfm:1572): DEBUG: launch command: <java -jar ~/Downloads/minecraft_server.jar> ** (pcmanfm:1572): DEBUG: sn_id = pcmanfm-1572-administrator-Dimension-3000-java-14_TIME14031891 Unable to access jarfile ~/Downloads/minecraft_server.jar ** (pcmanfm:1572): DEBUG: launch command: <java -jar ~/minecraftlauncher.jar> ** (pcmanfm:1572): DEBUG: sn_id = pcmanfm-1572-administrator-Dimension-3000-java-15_TIME14070158 Unable to access jarfile ~/minecraftlauncher.jar UPDATE: Whoops, it seems to work when I give an absolute path. I guess the home path is something else. UPDATE: I guess X doesn't resolve the home specifier. I ran a .desktop file that executed a script that outputs the current directory, and it seems to be correct.

    Read the article

  • Tuning OpenVZ Containers to work better with Java?

    - by Daniel
    I have a 8 GB RAM Server (Dedicated) and currently have KVM Virtual Machines running on there (successfully) however i'm considering moving to OpenVZ as KVM seems a bit overkill with a lot of overhead for what i use it for. In the past i have used OpenVZ Containers, hosted by myself and from other providers and Java doesn't seem to work well with them.. One example is that if i give a container 2 GB RAM ( No burst) (with or without vswap doesn't matter) a java instance can only be tuned to use at very most 1500 MB of that RAM (-Xmx, -Xms). Ideally, i wish to be able to create "Mini" containers with about 256MB, 512MB, 768 RAM and run some java instances in them. My question is: I'm trying to find an ideal way to tune a OpenVZ container configuration to work better with Java memory. Please, don't suggest anything related to Java settings, i'm looking for OpenVZ specific answers.. Though i welcome any suggestion if you feel it may help me. Much Appreciated, Daniel

    Read the article

  • Need old version Firefox Java plugin

    - by Bryan
    I need to use Java 1.6.0_20 for the software I'm running. I went to the Oracle website and downloaded jre1.6.0_20 and installed it on my computer, but can't seem to get Firefox to load Java. If I download directly from http://www.java.com/en/download/manual.jsp, the plugin works fine but is the wrong version, and I can't find on www.java.com anywhere to download any of the previous versions. According to the help (can't post link because of spam prevention), I need to go into the Java Control Panel and enable it for Mozilla. I've done this multiple times, but every time I go in to the control panel and check the box, click Apply and Save, as soon as I go back in the box is unchecked. Does anyone know either why the box is unchecked, or where I can download the old JRE that also is configured for Firefox?

    Read the article

  • Having an issue with Java/ minecraft (Windows 7 64bit)

    - by MetroGnome
    I have had issues with java on my computer for a while. First of all, java has never worked on Google Chrome or Firefox, Only IE. Whenever I need to use Java, I use IE. Now, I just tried to play minecraft the other week and I receive the error "fatal error (1)" and get a black screen (this is on the online free version). Now, I searched for java and found that I have Java 32 bit. I cannot uninstall it on Revo uninstaller or Windows uninstaller. What should I do?

    Read the article

  • Java Error Code 2753 Regutils.dll

    - by Adam
    Hello, I'm trying to install Java's JRE, however I'm running into problems. Recently the JRE was uninstalled on this computer, and when I try to reinstall I get this error 2753. I've looked online and the best page I've found to try and help is this one: http://forums.majorgeeks.com/showthread.php?t=182720 Which says to uninstall Java using Revo or Windows Cleanup. However nether program says I have Java installed. From what I've read this is a uninstall problem when Java is not really uninstalled. How do I make sure Java is completely uninstalled? Do you have any other suggestions for me to try?

    Read the article

  • C# 4.0: Covariance And Contravariance In Generics

    - by Paulo Morgado
    C# 4.0 (and .NET 4.0) introduced covariance and contravariance to generic interfaces and delegates. But what is this variance thing? According to Wikipedia, in multilinear algebra and tensor analysis, covariance and contravariance describe how the quantitative description of certain geometrical or physical entities changes when passing from one coordinate system to another.(*) But what does this have to do with C# or .NET? In type theory, a the type T is greater (>) than type S if S is a subtype (derives from) T, which means that there is a quantitative description for types in a type hierarchy. So, how does covariance and contravariance apply to C# (and .NET) generic types? In C# (and .NET), variance applies to generic type parameters and not to the resulting generic type. A generic type parameter is: covariant if the ordering of the generic types follows the ordering of the generic type parameters: Generic<T> = Generic<S> for T = S. contravariant if the ordering of the generic types is reversed from the ordering of the generic type parameters: Generic<T> = Generic<S> for T = S. invariant if neither of the above apply. If this definition is applied to arrays, we can see that arrays have always been covariant because this is valid code: object[] objectArray = new string[] { "string 1", "string 2" }; objectArray[0] = "string 3"; objectArray[1] = new object(); However, when we try to run this code, the second assignment will throw an ArrayTypeMismatchException. Although the compiler was fooled into thinking this was valid code because an object is being assigned to an element of an array of object, at run time, there is always a type check to guarantee that the runtime type of the definition of the elements of the array is greater or equal to the instance being assigned to the element. In the above example, because the runtime type of the array is array of string, the first assignment of array elements is valid because string = string and the second is invalid because string = object. This leads to the conclusion that, although arrays have always been covariant, they are not safely covariant – code that compiles is not guaranteed to run without errors. In C#, the way to define that a generic type parameter as covariant is using the out generic modifier: public interface IEnumerable<out T> { IEnumerator<T> GetEnumerator(); } public interface IEnumerator<out T> { T Current { get; } bool MoveNext(); } Notice the convenient use the pre-existing out keyword. Besides the benefit of not having to remember a new hypothetic covariant keyword, out is easier to remember because it defines that the generic type parameter can only appear in output positions — read-only properties and method return values. In a similar way, the way to define a type parameter as contravariant is using the in generic modifier: public interface IComparer<in T> { int Compare(T x, T y); } Once again, the use of the pre-existing in keyword makes it easier to remember that the generic type parameter can only be used in input positions — write-only properties and method non ref and non out parameters. Because covariance and contravariance apply only to the generic type parameters, a generic type definition can have both covariant and contravariant generic type parameters in its definition: public delegate TResult Func<in T, out TResult>(T arg); A generic type parameter that is not marked covariant (out) or contravariant (in) is invariant. All the types in the .NET Framework where variance could be applied to its generic type parameters have been modified to take advantage of this new feature. In summary, the rules for variance in C# (and .NET) are: Variance in type parameters are restricted to generic interface and generic delegate types. A generic interface or generic delegate type can have both covariant and contravariant type parameters. Variance applies only to reference types; if you specify a value type for a variant type parameter, that type parameter is invariant for the resulting constructed type. Variance does not apply to delegate combination. That is, given two delegates of types Action<Derived> and Action<Base>, you cannot combine the second delegate with the first although the result would be type safe. Variance allows the second delegate to be assigned to a variable of type Action<Derived>, but delegates can combine only if their types match exactly. If you want to learn more about variance in C# (and .NET), you can always read: Covariance and Contravariance in Generics — MSDN Library Exact rules for variance validity — Eric Lippert Events get a little overhaul in C# 4, Afterward: Effective Events — Chris Burrows Note: Because variance is a feature of .NET 4.0 and not only of C# 4.0, all this also applies to Visual Basic 10.

    Read the article

  • Java EE talks at JAX Conf

    - by arungupta
    JAX Conf is starting in San Jose today and there are several talks on Java EE there. Java EE Wednesday and Thursday Java Persistence API 2.0 with Eclipse Link RESTful Services with Java EE Cast Study: Functional programming in Scala with CDI GlassFish 3.1: Deploying your Java EE 6 Applications The future of Java Enterprise Testing Forge new ground in Rapid Enterprise Development The Java EE 7 Platform: Developing for the Cloud (Keynote) Exploring Java EE 6 for the Enterprise Developer JBoss Day JSF Summit CDI Tutorial And many more ... Check out the complete schedule and see ya there!

    Read the article

  • Java EE talks at JAX Conf

    - by arungupta
    JAX Conf is starting in San Jose today and there are several talks on Java EE there. Java EE Wednesday and Thursday Java Persistence API 2.0 with Eclipse Link RESTful Services with Java EE Cast Study: Functional programming in Scala with CDI GlassFish 3.1: Deploying your Java EE 6 Applications The future of Java Enterprise Testing Forge new ground in Rapid Enterprise Development The Java EE 7 Platform: Developing for the Cloud (Keynote) Exploring Java EE 6 for the Enterprise Developer JBoss Day JSF Summit CDI Tutorial And many more ... Check out the complete schedule and see ya there!

    Read the article

  • Creating a Type object corresponding to a generic type

    - by Alexey Romanov
    In Java, how can I construct a Type object for Map<String, String>? System.out.println(Map<String, String>.class); doesn't compile. One workaround I can think of is private Map<String, String> dummy() { throw new Error(); } Type mapStringString = Class.forName("ThisClass").getMethod("dummy", null).getGenericReturnType(); Is this the correct way?

    Read the article

  • Comparing the values of two generic Numbers

    - by PartlyCloudy
    I want to compare to variables, both of type T extends Number. Now I want to know which of the two variables is greater than the other or equal. Unfortunately I don't know the exact type yet, I only know that it will be a subtype of java.lang.Number. How can I do that? Thanks!

    Read the article

< Previous Page | 67 68 69 70 71 72 73 74 75 76 77 78  | Next Page >