Posts by Victor Stafusa • 63,338 points
1,321 posts
-
1
votes1
answer512
viewsA: Java - random number buttons
I think what you want is something more or less like this. I can’t be sure because you didn’t give the full code, so it’s hard to help you! import java.util.Arrays; import java.util.Collections;…
javaanswered Victor Stafusa 63,338 -
5
votes2
answers4816
viewsA: Java, random numbers (no repetition)
Try this: import java.util.Arrays; import java.util.Collections; import java.util.List; public class Aleatorio8 { public static void main(String[] args) { List<Integer> lista =…
javaanswered Victor Stafusa 63,338 -
3
votes1
answer130
viewsA: File . java not found
You are running the command javac from the wrong folder. First navigate to the correct folder, which is the folder where your file .java is. And then turn the javac. To navigate between folders on…
javaanswered Victor Stafusa 63,338 -
4
votes2
answers110
viewsA: Use a function several times
Your main problem is the variable cont which is only one, and not one per clock. I just entered a variable myCont per watch and use it instead of the cont that worked. Here is the jsfiddle:…
-
4
votes2
answers123
viewsA: How to separate libraries in an app suite?
For each strongly related group of entities, create a package. For example, there will be a package with the property entities. There will be another package with HR entities. There is, by itself,…
-
2
votes1
answer471
viewsA: Is it possible to run class unit test with inheritance?
Inherit from ArrayList<String> is bad. Incidentally inheriting from any class of Collection, unless you know very well what you’re doing is bad. The reason is that the Collections is out of…
-
14
votes2
answers45293
viewsA: What is a deploy?
Deploy means implanting. For example, after you have generated your program and want to put it on the air on your application server, what you are doing is deploying it on the server. Implanting…
-
4
votes1
answer188
viewsA: How to Distribute RIA with JNLP and Java 8
This is not a complete answer, but I will use as an example the JAR of Tide with which I had this problem a few days ago. It is a JNLP executable JAR which is also self-signed and was locked in Java…
-
13
votes1
answer236
viewsA: Divide circle SVG into 12 parts
I got it. Here’s the fiddle: https://jsfiddle.net/m5ojvsbe/ And here’s the source code. It can be executed right here with the blue button Execute that’s down there: // Raio do círculo. var r = 50;…
-
0
votes1
answer774
viewsA: JPA/Hibernate problem with competition and persistence in the JRE
Let’s start with these two items: Instances of divergent objects in instances of EntityManager different. Competing operations with EntityManager different generating persistence error. NEVER use…
-
11
votes2
answers2638
viewsA: Search words cannot find the word
Use the type boolean! He is your friend and serves to help! Do not use int with 0 and 1 to represent true/false values or yes/no. Learn how to code. Just see how you’ve positioned the blocks else,…
javaanswered Victor Stafusa 63,338 -
2
votes1
answer1313
viewsA: Recover the value of a Jtextfield via an Actionlistener
You can pass the required field in the builder: import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import…
-
1
votes1
answer1525
viewsA: Update (refresh) a Jdialog (swing) dynamically
The best I could do was this. I don’t know what he was supposed to do exactly when he reloaded the screen, so I put a System.out.println to demonstrate that the method was called. Whenever I select…
-
7
votes2
answers531
viewsA: Translation of the word flush
I think a reasonable translation would be unload. Thus, "flush standard output" would be translated to "download the standard output". You can argue (and I would agree) that the term download sounds…
-
5
votes1
answer580
viewsA: High memory consumption Java Swing application
Your main problem seems to be in ConexaoJPA: public class ConexaoJPA { public static EntityManager getEntityManager(){ EntityManagerFactory emf = Persistence.createEntityManagerFactory("SisPU");…
-
5
votes1
answer677
viewsA: Algorithm to generate a character diamond
I won’t give you the code, but I’ll give you an idea about the algorithm. First, you will need to convert from letter to number, which I will call n, so that A is 0, B is 1, etc. I put A as 0 and…
-
1
votes1
answer633
viewsA: Maturity of dates
Your code has a lot of problems: You did not provide the class PersonC of the parameter jtc (I’m supposed to be a subclass of Person), but since you don’t seem to be using this parameter for…
-
6
votes1
answer356
viewsA: Minimizar + Sytemtray
The answer is already in your code. To make it easier, we will rearrange it: public void moveToTray() { if (!SystemTray.isSupported()) return; final SystemTray systemTray =…
-
0
votes3
answers1949
viewsA: Implement and perform joint operations on chain lists
You can add a method to find out if an element exists in ListaDinamica: public boolean existe(int elemento) { for (Lista a = primeiro; a != null; a = a.getProx()) { if (a.getValor() == elemento)…
javaanswered Victor Stafusa 63,338 -
0
votes3
answers1949
viewsA: Implement and perform joint operations on chain lists
I think that would be it, that simply modifies a ListaDinamica concatenating in her another ListaDinamica: public void uniao(ListaDinamica outraLista) { ultimo.setProx(outraLista.primeiro); ultimo =…
javaanswered Victor Stafusa 63,338 -
5
votes1
answer136
viewsA: Arrayindexoutofboundsexception in Java 8 Parameter Reflection
It’s a Java bug: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=5087240 To circumvent this bug, it is necessary to check whether the Constructor.getGenericParameterTypes() and the…
-
9
votes1
answer136
viewsQ: Arrayindexoutofboundsexception in Java 8 Parameter Reflection
I was making a code with Reflection in Java 8 when I came across a strange behavior - A ArrayIndexOutOfBoundsException unexpected. Based on this, I decided to create a minimal, complete and…
-
0
votes1
answer1141
viewsA: Error to install VB.NET application on Windows Server
I think your problem should be that on your server, Crystal Reports does not have all the read and write permissions of files that he needs in his workbook or is not configured to run as a service.…
-
1
votes1
answer88
viewsA: Incremental key
Your SQL should be like this: INSERT INTO usuario (nome, idade) VALUES (?, ?) The reason is that the auto_increment is only applied if you do not specify the id, but in this case you were specifying…
-
2
votes2
answers1826
viewsA: Is it possible to hide the link bar displayed in the bottom corner of browsers?
This link bar exists as a security feature and has been invented to mitigate problems arising from phishing. If it could be hidden or disabled, then all websites that promote phishing would…
-
6
votes4
answers199
viewsA: Problem accessing array element
Your biggest problem is here: for ( j = 0 ; j < n ; j++) That means you’ll only walk through the first ones n string characters, not each word. I think the best way to do that is to have an…
-
5
votes6
answers8412
viewsA: Function that enumerates letters of the alphabet
Here is a way that knows how to treat accents and works with the Latin, Cyrillic and Greek alphabets: var latinoMaiusculo = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var latinoMinusculo =…
-
1
votes1
answer137
viewsA: Input with V or F only
I did it. First I started to leave of this other Stack Overflow in English. After that, I tried the code and came to this: var valorSalvo = 'F'; $('#textbox').on('input propertychange paste',…
-
1
votes2
answers469
viewsA: Replace all after first white space
Another way to do it, without using regular expressions, is the following: var antes = 'stirred up'; var depois = antes.split(' ')[0]; alert("Antes: " + antes + "; Depois: " + depois); This then…
javascriptanswered Victor Stafusa 63,338 -
2
votes1
answer132
viewsA: Replace occurrences arbitrarily in Javascript
I did the job replaceString which follows on the basis of the second code which is demonstrated in this section of this link. To prove it works includes unit testing with Qunit, then just click on…
-
2
votes1
answer1040
viewsA: Jfreechart - Java Swing charts do not appear on the screen
I tested here with this code and it worked: import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Toolkit; import javax.swing.JButton; import…
-
1
votes1
answer804
viewsA: 'Load More' button duplicates or does not work AJAX/JSON
Assuming that the ids that are in the JSON that comes from PHP are in ascending order (which makes more sense), I think you need to track which was the last id needs. It is also good to find a way…
-
3
votes3
answers683
viewsA: list index out of range when trying to resolve the issue of google Developer day 2010
Look, I don’t know python, but I think in this part: for ca in range(len(validos)): a = 0 e = list(validos[ca]) #o IDLE acusa o erro aqui(list index out of range) for cb in range(len(e)): a +=…
-
2
votes2
answers1633
viewsA: Splashcreen plugin (Cordova) and icons do not work on Crosswalk
According to the wikipedia: J2SE 8 = 52 J2SE 7 = 51 J2SE 6.0 = 50 J2SE 5.0 = 49 JDK 1.4 = 48 JDK 1.3 = 47 JDK 1.2 = 46 JDK 1.1 = 45 In your mistakes appears this: warning:…
-
2
votes2
answers386
viewsA: Error while trying to run a class
It may be that import is missing at the beginning of the file: import javax.swing.JOptionPane;
-
3
votes1
answer1530
viewsA: "Transparent" text in java
I got it. The trick is you create a JTextField with two other components inside: One JLabel with the suggestion text and an image with the icon. And then you use the DocumentListener to capture text…
-
3
votes2
answers598
viewsA: Why am I not getting into the if Else of this code
Your problem is encoding of accents and the following test confirms it. Just put some System.out.println in their elses: } else { System.out.println("Voce digitou " + veiculoStr); break; } } else {…
-
31
votes2
answers1684
viewsA: What are Unit Tests for and what are the advantages?
Imagine the following scenario: You have that huge program with a couple of hundred modules. And then you have to move something in the middle. Maybe it’s taking a class or a function and dividing…
-
3
votes1
answer237
viewsA: Is there a Java function equivalent to drawPixel?
Yes, of course. You can use the methods setRGB(x, y, cor) and getRGB(x, y) class BufferedImage. You can get a BufferedImage when using one of its builders, or upload an external image. For example:…
-
2
votes1
answer366
viewsA: File . class is not generated
Your question is unclear but I’ll try to answer anyway. First create a file HelloWorld.java: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } }…
javaanswered Victor Stafusa 63,338 -
1
votes2
answers424
viewsA: How do I display a jPanel when I place my mouse over a certain region?
Does this help you? Explanation in the code comments. import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import…
-
17
votes1
answer593
viewsA: Anti-aliasing algorithm in Java
Strategies for the anti-aliasing The algorithm of anti-aliasing in general it is not very complex, but it becomes complex when you go into the sordid details and optimizations. For comparison…
-
7
votes1
answer1536
viewsA: Operation with Delphi hours
Well, in all three cases you used a variable horaInicial and then horaIncial. I will assume that the i missing is a silly typing error only and not a different variable. Behold on this page these…
-
4
votes1
answer1372
viewsA: Update column and table settings with Hibernate
Within the persistence.xml (or hibernate.cfg.xml or some other equivalent mechanism) you can define the following property: <property name="hibernate.hbm2ddl.auto" value="update" /> The…
-
1
votes3
answers126
viewsA: Is it safe to keep the context of an app in a Singleton?
Your class is more or less. But the first big problem I see is the builder being public. With this, just someone summon you and your Singleton will no longer be a Singleton. There is another big…
-
9
votes4
answers784
viewsA: Break an integer into small parts in Java
Response based on the mgibsonbr, but without having to invert the list: int a = 123; List<Integer> numerosGerados = new ArrayList<>(); int x = a > 0 ? a : -a; do {…
javaanswered Victor Stafusa 63,338 -
1
votes1
answer56
viewsA: Click the button without using GUI
What’s so hard about that? import java.awt.Dimension; import java.awt.EventQueue; import javax.swing.JButton; import javax.swing.JFrame; /** * @author Victor */ public class TelaSair { public static…
javaanswered Victor Stafusa 63,338 -
1
votes1
answer790
viewsA: How to open a GUI built in Eclipse by Netbeans?
In Netbeans for it to be recognized as a form and function properly there are several requirements. I’ll start with the simplest (but least important). First, the constructor should have the…
-
1
votes1
answer1803
viewsA: Calculate clicks per second
First you should capture click-through events and set a timestamp for each. In the case of events that are inherited from java.awt.event.InputEvent, this timestamp will be present in the method…
javaanswered Victor Stafusa 63,338 -
11
votes2
answers2813
viewsA: Google Adsense automatic click
I disagree and much of what you are doing and I would not like to help you. However, I can give suggestions to those who want to automate clicks (including you): You can use the Selenium, which is a…