Posts by Lucas Caresia • 2,663 points
185 posts
-
3
votes1
answer192
viewsQ: How to use setNextFocusableComponent in a Jtextarea
I used setNextFocusableComponent in a JTextArea, but it doesn’t work because the TAB works as a "space" inside the JTextArea, how to solve this ??
-
-2
votes2
answers131
viewsQ: When generating an image, I just want to visualize it and not save it
When using this code I save the image, but instead of saving I just want to visualize it. String key = "Lucão MC"; BufferedImage bufferedImage = ImageIO.read(new File("recibo.png")); Graphics…
-
1
votes1
answer566
viewsA: How to write about an image
I was able to solve just by correcting ImageIO.write(bufferedImage, "png", new File("recibo.jpg")); To ImageIO.write(bufferedImage, "png", new File("recibo.png"));…
-
0
votes1
answer566
viewsQ: How to write about an image
I found this code on the Internet and made some changes, but I’m not sure what’s going wrong. Code: public class main { public static void main(String[] args) throws IOException { String key =…
-
3
votes2
answers352
viewsQ: Code help (appears to be hexadecimal)
Hello, in my course had a joke, who could decipher the code would win a prize, I tried in hexadecimal, but I did not get anything. 51 44 52 20 59 44 20 57 44 52 20 4a 48 51 57 4c 4f 50 48 51 57 48…
-
0
votes1
answer37
viewsQ: Jlabel of visual bug when use setBackground()
When I use JLabel.setBackground(Color); it simply gives a visual bug. Layout: quarto1 = new JPanel(); quarto1.setBounds(10, 11, 158, 82); frame.getContentPane().add(quarto1);…
javaasked Lucas Caresia 2,663 -
5
votes2
answers5579
viewsQ: How to take only the number after the comma
When I do the 162/11 calculation, the result obtained is 14,72727272727273. But when I use the code System.out.printf("%.1f", teste);, the number is displayed 14,8. I’d like a way to keep just the 8…
javaasked Lucas Caresia 2,663 -
0
votes1
answer317
viewsQ: Error while compiling Android
When compiling, the following error occurs: :app:transformClassesWithDexForDebug FAILED Error:1 error; aborting Error:Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code.…
-
2
votes1
answer203
viewsQ: Error while removing Object from Arraylist
When I try to remove a int of arrayList he simply of error. Code: ArrayList<Integer> colors = new ArrayList<>(); colors.add(Color.rgb(119, 103, 141)); colors.add(Color.rgb(33, 10, 208));…
-
1
votes1
answer88
viewsQ: Mediaplayer.create() stops working after a few sounds
Hello, I put a different sound to touch each button pressed, but after 4 Tarts it simply stops. Code: numero = random.nextInt(numeros.length); MediaPlayer soundID = MediaPlayer.create(this,…
-
0
votes1
answer1056
viewsQ: How do you resize a Jpanel inside a Jscrollpane automatically?
After adding a greater amount of buttons than the JPanel support, I would like to update(increase the JPanel) automatically, how can I do this? private JPanel contentPane; private static int tamanho…
-
2
votes1
answer1692
viewsQ: How to check if a table exists in Mysql
I’ve found several ways on the Internet, but none the way I wanted. I would like a java method for which it checks whether a table exists in the database if it exists TRUE or return FALSE. Grateful…
-
0
votes2
answers37
viewsQ: Error inserting data into table
Opening Connection: private static final String USUARIO = "root"; private static final String SENHA = "123456"; private static final String URL = "jdbc:mysql://127.0.0.1:3306/escolabd"; private…
-
3
votes1
answer144
viewsQ: How to save String[] in Mysql
Hello, I’d like to save one String[] in Mysql, but I don’t know the type of datatype that saves String[], and what method I use to store this information.…
-
1
votes1
answer354
viewsQ: Error connecting to Mysql
I took an example of the internet to connect with Mysql private static final String USUARIO = "root"; private static final String SENHA = "123456"; private static final String URL =…
-
0
votes1
answer1748
viewsQ: How to add scrollbar in Jpanel?
I would like to add a scroll bar to a Jpanel that uses Absolute Layout. package Default; import javax.swing.JFrame; import javax.swing.border.EmptyBorder; import java.awt.Dimension; import…
-
0
votes0
answers51
viewsQ: How to generate multiple buttons with the same variable and catch them separately
Hello, I’ll put the important part of the code here and then I’ll explain what I want to do. Main: public static JButton sala; public static int contagemTurmas = 0; botaoSalvar.addActionListener(new…
-
1
votes0
answers75
viewsQ: Error if project name is not "secsu"
Hello, today I created a project to test with the name "secsu" and it works perfectly, but when I try to change the name(Refactor > Rename) he simply of error. Code: package secsu; import…
-
0
votes1
answer31
viewsQ: Error when compiling LWJGL
When trying to compile a code LWJGL gave the following error:…
-
0
votes1
answer33
viewsQ: Problems importing with LWJGL
Hi, I followed in the footsteps of that video, and I took the sample code from website. Trying to matter says method is undefined:…
-
1
votes0
answers1246
viewsQ: Error while compiling Allegro
I installed and created the Allegro project following this tutorial. I have that code: #include <stdio.h> #include <stdlib.h> #include <allegro5/allegro.h> #include…
-
0
votes1
answer82
viewsQ: How to make a list of available "wifis"
I would like to know how to take all available wifis and put them on a list, searched on the internet, but did not understand right, I would like a well summarized code, thank you. public class…
androidasked Lucas Caresia 2,663 -
1
votes0
answers31
viewsQ: How to capture keys with minimized program
I’m doing a Chat and would like when the user typed a letter (which he would configure) reopen the Chat that was minimized. How would I capture a key pressed even with the program minimized ??…
javaasked Lucas Caresia 2,663 -
1
votes1
answer496
viewsQ: How to use "drawRect" to draw on a component?
I am learning Graphics, but I can’t make a square: public static void main(String[] args) { JFrame tela = new JFrame("Snake"); tela.setSize(500, 500); tela.setVisible(true); Graphics g =…
-
4
votes2
answers123
viewsQ: Some errors on Android
I’m trying to start programming on Android. I created the project and came this code: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);…
-
6
votes2
answers619
viewsQ: How to capture the pressing of a key with the program running in the background
The code I have so far is this: public static void main(String[] args) { SystemTray tray = SystemTray.getSystemTray(); Image image = new BufferedImage(10, 10, 10); String tooltip = "Oi amiguinho";…
javaasked Lucas Caresia 2,663 -
3
votes1
answer124
viewsQ: When concateno String add a ENTER
When I concateno(+) strings adds one alone enter right after the concatenation. private static Dimension TOOLKIT = Toolkit.getDefaultToolkit().getScreenSize(); private static GraphicsEnvironment GE…
-
1
votes1
answer124
viewsQ: Socket Doesn’t Send Message to Right Customers
When typed /msg nome mensagem should send this message to nome, but he sends it to whoever typed it Java manager. private Socket cliente; public static String nomeCliente; private static…
-
2
votes1
answer1026
viewsQ: Centering text on a Jtextarea or Jtextpane
In this image the text is not centered, it is far above the JTextArea: And I would also like the text to begin in the middle of JTextArea and was adjusting as I was writing. What method can I use to…
-
2
votes1
answer713
viewsQ: How to set a new (external) source for a Jtextpane
I have a JTextPane and I want to define a new source (found on the internet) for it. I saw several tutorials, but none of them could define the source, I would like to make it as simple as possible.…
javaasked Lucas Caresia 2,663 -
21
votes1
answer1341
viewsQ: How to remove the edges of a Jframe?
I’d like to remove the edges of a JFrame. I used setUndecorated(true), however it removes completely and I would like to leave only the title bar of the JFrame.…
-
1
votes0
answers196
viewsQ: How to traffic real-time data with JAVA?
What is necessary to develop a Chat system, in which two people receive messages in real-time, and how to establish a connection between users' computers? The front-end is already developed, but it…
-
3
votes3
answers99
viewsQ: Method to save multiple "Players" to a list
I want to make a system of party, the only command will be /party PLAYER (if the player is already in the party, it will be removed and if it is not, it will be added). But I couldn’t find a way to…
javaasked Lucas Caresia 2,663 -
2
votes1
answer733
viewsQ: How to "delete" an image from the screen
In this code I would like to delete the image I put before and not one on top of the other. Graphics g = getGraphics(); Graphics bbg = backBuffer.getGraphics(); bbg.drawImage(fundo.getImage(), 0, 0,…
-
2
votes1
answer2043
viewsQ: How to set the location of Jbutton according to the size of a Panel
I’d like to define the location of color1 according to the size of a Jpanel, the same way I did with the fundo public static void janelaPrincipal() { //FRAME JFrame janela = new JFrame();…
-
1
votes1
answer1226
viewsQ: setPreferredSize and setSize do not work
I used the setPreferredSize and the setSize on the button color1 but no effect on the application, it continues using the entire application. public static void janelaPrincipal() { //FRAME JFrame…
-
2
votes2
answers150
viewsQ: What is Forcebrute’s logic of trial and error?
How is it done to make the billions of possible combinations without wasting time? I made a system to generate random letters (he can make all the combinations), but he spends a lot of time checking…
javaasked Lucas Caresia 2,663 -
3
votes1
answer122
viewsQ: Error using Random in JAVA
When I run this code: public class main { static boolean terminar = false; public static void main(String[] args) { long init = System.currentTimeMillis(); BruteForce(true, true, "a123", 10, 10000);…
-
6
votes1
answer226
viewsQ: Why a loop FOR faster than 10 FOR together
I made a for alone count up to 1000000 (sending 1 message each loop) and it took 14 seconds. public class main { public static void main(String[] args) throws InterruptedException { long init =…
-
1
votes2
answers40
viewsQ: The functions do not end
After the execution of the 4 functions it should print the time it took to execute public class main { public static void main(String[] args) { long init = System.currentTimeMillis(); ataque1();…
-
0
votes1
answer261
viewsQ: How to run multiple FOR at the same time
In the code below I have 4 for and they run in sequence, but I need them to run them all at the same time. public class main { public static void main(String[] args) { long init =…
-
1
votes1
answer1575
viewsQ: How to run java at the Eclipse prompt
I made a code in java and in it I use " r" that only works at the prompt and I would like to know how to run this code at the prompt by the eclipse itself.
-
0
votes2
answers186
viewsQ: How to modify an existing System.out.println
If I run this code public class main { public static void main(String[] args) { teste(20); } public static void teste(int maximo) { for(int i = 0; i < maximo; i++) { System.out.println(i + " de "…
javaasked Lucas Caresia 2,663 -
2
votes1
answer137
viewsQ: Allegro Debug -Abort() Has Been Called
I tried to make an animation and Visual Studio gives the error Debug -Abort() Has Been Called. Code: #include <allegro5\allegro.h> #include <allegro5\allegro_native_dialog.h> #include…
-
1
votes1
answer51
viewsQ: Allegro does not perform anything graphic
It simply does not appear anything graphic, the functional (close the window) works perfectly, but the graphic (background color and "ship") do not work. #include <allegro5\allegro.h> #include…
-
1
votes1
answer946
viewsQ: Dlls error when compiling
Studio: #include <allegro5\allegro.h> int main(void) { ALLEGRO_DISPLAY *display = NULL; if(!al_init()) { return -1; display = al_create_display(800, 600); } if(!display) { return -1; }…
-
1
votes0
answers581
viewsQ: Auto-Complete from IDE Code::Blocks does not display the methods from the Allegro library
I’m using Allegro in Code:Blocks, but when it comes to something from Allegro Code::Blocks can’t use Autocomplete, what should I do to fix it?
-
0
votes0
answers473
viewsQ: Makefile.win error while compiling project
The archive Makefile.win makes a mistake when trying to compile my project. A warning appears asking to reload the file, after pressing YES and trying to re-compile it appears again the same warning…
-
0
votes0
answers130
viewsQ: Error while compiling in DEV-C++(SDL)
I did all the procedure to use SDL2, but when I compile the following error happens [Error]SDL/SDL.h: No such file or directory This is the content of the line where the error occurs…
-
1
votes0
answers1271
viewsQ: What languages to use to create a Tibia/Spout(2D) style game
Hi, I’ve always wanted to do a "little game" in 2D in the kind of Tibia or Spout (but for the PC), nothing so complex, just the basic (map, make the character move, motion animation, etc) and I…
gamesasked Lucas Caresia 2,663