GestureDetector and InputListener in libgdx

I'm new to libgdx and what I'm trying to achieve here is that I want my GestureDetector to work at the same time with InputListener. I have two buttons on the left and I need them to keep reacting even if I start swiping at the same time(multitouch). I used InputMultiplexer but it doesn't work that way I need. I checked all the return values of InputListener and GestureDetector and everything that I need returns true, also GestureInputListener is a class that implements GestureDetector.GestureListener. I only used fling in it. Both GestureInputListener and InputListener wor...

Getting Drawable

I am using glide and once the image is retrieved it is put into a view, the view is extended and i use the below code in the constructor. The code returns null. Is there a way to wait til it returns the drawable? It works in the listeners and that's why i am asking if there's a way to wait so it can be in the constructors.Code:Glide:Glide .with(activity).asBitmap() .load(imageURL) .into(new SimpleTarget<Bitmap>(currentMap.getWidth(), currentMap.getHeight()) { @Override public void onResourceReady(@NonNull Bitmap resource, @...

Get shown component in scrollpane

I have a scrollpane where is a Jpanel inside and I fill this jpanel with many Buttons. Is there any possibility to get the current shown components?Because I want to know which are the buttons that are currently shown. (I know I can access the children of a jpanel via jpanel.getComponents() but that's are all components in this pane I want only the one that are currently on screen).BRLeon I assume that this container is already visible on the screen, then I suggest 1) to extract JViewPort from JScrollPane, 2) addChangeListener to JViewPort3) each visible JComponent(s) re...

Properly scaling x-axis in accordance with pixels (Java)

I am working on plotting a sin(x) graph for a school project. Currently I have everything working the way I want it to besides one thing: the scaling of the x axis. Here is the code I am currently using: int xStart = xShift; int xEnd = xShift; int yStart = getHeight() / 2; int yEnd = getHeight() / 2; int scale = getHeight() / 2; double constraint = 0.80; for (double i = Math.PI / 32; i <= Math.PI * 2; i+= Math.PI / 32){ xEnd += (getWidth() - (2 * xShift) / 64); yEnd = (scale - ((int) Math.round(Math.sin(i) * scale * constraint))) ; ...

Clustering with JBoss EWS 2.0

In our production environment, we're using JBoss Enterprise Web Server 2.0, which basically is a bundling of Apache HTTP Server and a slightly modified Tomcat 7. We have two nodes, on different servers, and we're trying to set up clustering with session failover (replication) between the nodes. My initial thought was to simply follow the Tomcat 7 Clustering How-To. But following the mentioned guide (using the config in the example) and starting the server gives this error:java.lang.ClassNotFounException: org.apache.catalina.ha.tcp.SimpleTcpClusterAlso in the log:INFO: Clust...

Java execute Linux commands that require su?

What is the best way to run Linux commands that require "su" with Java? I want it to be very reliable, as for security goes I don't care much about it the system is not a production server. No one ever connects to the machine but myself. I thought about logging in as root so I don't have to deal with the su command and its disabled by default. I'm using Debian 6. The only thing is that one of my requirements is that the program should start after the normal user logs in without any farther user input. I would set auto login for the normal user and when the computer is turne...

Need some assistance understanding tutorial code: Java - Class Constructors / Initializers

I've been following some basic Java tutorials on Pluralsight, I've hit a point where I don't quite understand what the tutor is trying to explain, he seems to have a tendency to quickly go over some exercises rather quickly and it's a little difficult to follow.I have 2 classes, a "Main" and a "MathExecution". I fully understand what is happening in MathExecution, however I don't quite understand some aspects of Main, which I will go over. I will paste both classes below:Main.java:public class Main { public static void main(String[] args) {// double[] value1 = {10...

Java highscore list

So i have a problem with my final projekt in school. I'm creating a game with a highscore list but i need to have ten people to show up, and i curently only have 5 people and i do not have a single clue how to fix it. import java.util.*; import java.io.*; public class HighscoreManager { // Sparar alla poäng i filen "scores.dat", filen skapas här private static final String HIGHSCORE_FILE = "scores.dat"; // En arraylista med typen score ArrayList<Score> scores; // Startar en in och en utström för att skicka och ladda in informa...

How to get a value from an array to be used in another class?

If there is an array such as://....int[] anArray;anArray = new int[3];anArray[0] = new otherClassWConst( x, y , z);anArray[1] = new otherClassWConst( x, y , z);anArray[2] = new otherClassWConst( x, y , z);//....With the values of x and y and z all being of different value to the other x, y, and z's from the other objects in the array. (Does that make sense? Like the value of x in anArray[0] is not the same as the value found in anArray[2]). Note: there is a constructor from another class that requires those parameters, I'm not sure if thats importantHow do I, in a different...

Joda-Time datetime daylight saving time for Europe/Berlin

How can I parse a date string with Joda-Time datetime which uses the correct timezone WITH daylight saving time?As an example in scala I try to parse the string "2014-04-07 01:00:00.000" (without timezone information). This date is coming from MySQL and is supposed to be in tz Europe/Berlin +01:00. What I like to have is a joda date time according to 2014-04-07 00:00:00+01:00 which is the timezone Europe/Berlin currently not on DST (GMT +1).val fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS").withZone(DateTimeZone.forID("Europe/Berlin"))val dt = fmt.parseDateTime(...

Java - Add element to empty set (immutable)

I've been working on trying to implement an immutable set from scratch, so I'm not using HashSet or java.util.SetI have this method in my Empty class to add an element to an empty set:public Set<T> add(T x) { return new Element<T>(x, new Empty<T>());}And in another class called Element, I have the following constructor: public Element(T element, Empty<T> empty) { assert(element != null); assert(empty != null); this.element = element; this.set = empty; }EDIT: here is my other Element constructor used for adding an element to a s...

Good Web Server/Servlet Container for Clojure Web Apps?

I am looking for a good production web server/servlet container for my compojure web appliction. What are the pros and cons of using Jetty or Tomcat or other server for a Clojure web app using compojure? Is there any good documentation for using a web server with Clojure for production, or tools?I would prefer a web server that is flexible, easy to configure and has good documentation on how to configure and use it. I think there is not yet a pure Clojure Webserver, but I heard that people at Apache were working on something like that. On the meanwhile I have some links ...

Getting A File's Mime Type In Java

I was just wondering how most people fetch a mime type from a file in Java? So far I've tried two utils: JMimeMagic & Mime-Util. The first gave me memory exceptions, the second doesn't close its streams off properly. I was just wondering if anyone else had a method/library that they used and worked correctly? In Java 7 you can now just use Files.probeContentType(path). [XXX]Unfortunately,mimeType = file.toURL().openConnection().getContentType();does not work, since this use of URL leaves a file locked, so that, for example, it is undeletable.However, you have t...

Invoking Clojure from Java in IntelliJ Idea?

I installed La Clojure Plugin for IntelliJ Idea IDE so I'm either able to use Clojure REPL, or create a Clojure app, but how to run a Clojure function from a Java program? For some unknown reason, I can't import clojure.lang.RT; etc. Can you give me a step-by-step guide so it will be possible to invoke Clojure code from Java? You need to have the clojure jar in your dependencies (they are shown in Project Tab -> External Libraries). [XXX]

Why isBinarySearchTree() function is not correct

I am checking if a tree is a binary search tree. I see what the known solution is. Prior to me looking it up, I came up with the following attempt based off of post order traversal. I have traced it by hand, and seems to make sense. But, it is incorrect. Can anyone help me understand why?class Node { int data; Node left; Node right; }boolean checkBST(Node root) { // Empty tree if (root == null) { return true; } // Sub trees are BST boolean valid = checkBST(root.left) && checkBST(root.right); // Greater than left if (root.lef...

Looping through Object of Objects in java

I have an object which in turn contains other objects. Now I have to iterate through this main object and then pick each object and then iterate through them to find out whether any empty fields are present in them. If the object itself is empty, I have to cut it out of main object. Any thoughts on this please.public class Transactions {private Integer totalTransactionCount = null;private List<Transaction> transactionsList = new ArrayList<Transaction>();}public class Transaction {private String amount = null;private Foreign foreign = null;} public class Foreign ...

Page 1 of 2360  |  Show More Pages:  Top Prev Next Last