Posts by Jonathan CR • 673 points
58 posts
-
-1
votes1
answer65
viewsA: What is it and why should I provide a "dependency array" for React’s Hooks?
Let me give you a basic example: const MeuComponente = () => { const [counter, setCounter] = useState(0); const incrementCounter = useCallback(()=>{ setCounter(counter + 1); },[]) return (…
-
-2
votes2
answers47
viewsA: Is it possible to discriminate unstructured values of an object with union type in Typescript?
Try this: function testDestructuring({ cats, dogs }: CatsOrDogs) { cats?.push('') dogs?.push(''); } The guy inference works, you can see that by hovering your mouse over cats or dogs within the…
-
0
votes3
answers196
viewsA: What causes my component to be rendered again in React?
Short answer: Changes of Constants Long answer: useState returns an array with its first position being the constant and the second position being a function to set new values to that constant.…
-
2
votes1
answer130
viewsA: What is the difference of syscall and call in Assembly?
Near Relative Call call rel16/rel32 This is the call we use has no secret. It basically gets a negative or positive number indicating the number of bytes that should be diverted Near Absolute Call…
assemblyanswered Jonathan CR 673 -
0
votes1
answer26
viewsA: (Function) Check filled fields return previous action
You can simplify these selects... Also, to simplify html so that we can only handle width instead of display... So you can only have a progressibar. <div style="margin-bottom: 1.5em;"> <div…
-
0
votes2
answers34
viewsA: How to make buttons have the color defined in css when selecting Row in a datatable
If it was a fontawesome icon it would just change the color attribute: table.dataTable tbody tr.selected i{ color: darkgreen; } but have to see how this icone, if it is set as background then you’ll…
-
-1
votes2
answers271
viewsA: getElementById in React/JSX
In the newer React there is no need to implement classes, and it became somewhat easier to use the hook useState! Example-> import React, { useState } from 'react'; const Dashboard = React.FC…
-
2
votes1
answer37
viewsA: How to adjust an image to the exact length of the screen?
There’s another detail you forgot, html and body have padding and margin, reset them before you start. body,html{ padding: 0; margin: 0; } You can also use viewport properties such as vw and vh,…
-
1
votes1
answer27
viewsA: Redirect system
Ancient answer-> Notei que no inicio chamou a classe do db, e provavelmente lá é feito o request para ver se o usuário é admin ou não, MAS... como ele vai fazer o request se ele ainda nem sabe…
phpanswered Jonathan CR 673 -
0
votes2
answers13159
viewsA: Error: Access to Xmlhttprequest at 'file://...' from origin 'null' has been blocked by CORS policy
I know that the answer is already accepted, but there is an addendum for those who already have the shaman installed. Start apache and move the files to htdocs. now just access this index via…
-
2
votes4
answers2171
viewsA: CSS, Bootstrap4 Cards Side by Side
Hello, good has several ways to address this theme, being flexbox, or grid.... Follow a practical example of using flexbox <!doctype html> <html lang="pt-br"> <head>…
-
1
votes1
answer33
viewsA: JAVA functionality compared to Delphi to find a value in a specific list
List has several functions, it would be nice to take a quick look at them. I don’t know what purpose you’re looking for, but here’s an example. List<Produto> produtos = new…
-
4
votes1
answer109
viewsA: Update Jeditorpane as a function’s data return - JAVA
Neto I’m updating again the answer because it really gets hard to understand where your problem is. resposta antiga the jop (JOptionPane) it’s not a good case you want a screen to appear in the…
-
2
votes2
answers781
viewsA: How to make an object inside a JSON object in Java?
I know that the question itself has already been answered, but something interesting is not trying to reinvent the wheel, that is, using methods, libs and the like to perform the operation you want…
-
0
votes1
answer70
viewsA: Real Time File Search
of a researcher on how the JFileChooser Its implementation is quite simple ex: JFileChooser fl = new JFileChooser(); fl.setDialogTitle("Buscar arquivo"); //titulo do jDialog…
-
0
votes1
answer69
viewsA: Should I use Swingutilities.invokeLater if I don’t directly extend Jframe?
invokeLater Causes runnable to have its method of execution called in the dispatch chain of the Eventqueue system. This will happen after all pending events are processed. Other explanations: here…
-
0
votes2
answers267
viewsA: Get Directory After JAVA Compiled
I’d like to thank Rafael Guasselli for the help, I would like it to be corrected the answer so I can approve and make it clear to future people who were having the same problem. Follows the answer:…
-
0
votes1
answer68
viewsA: How to close one Jinternalframe when opening another?
Leave for instance them within the action of the button, who knows this help. Remembering that because it is a Jinternalframe can use the .show Ex: private void…
-
0
votes1
answer454
viewsA: Netbeans does not generate lib folder
I found out It’s a Netbeans 9.0-11.0 bug. https://issues.apache.org/jira/browse/NETBEANS-1097 There’s an alternative solution there. Basically, in your file build-impl.xml (that will be inside…
-
0
votes1
answer454
viewsQ: Netbeans does not generate lib folder
Hello, well I’m having a problem compiling a project with Netbeans 11 and jdk 13 for some strange reason when compiling the folder dist will only the jar and the folder lib is not compiled together.…
-
0
votes2
answers267
viewsQ: Get Directory After JAVA Compiled
Beforehand I would like to say that I have already searched in several links indicated here in stackoverflow and other sites as well and I still could not get concrete help (it may be my mistake…
-
0
votes1
answer40
viewsA: View Datatable only if there is registration
You could for example set the "Visible" button right after "fill" the Tables. If the rowCount of 0 then set the Visible button to false. Or if you want just change the name of the button to "No…
-
0
votes1
answer113
viewsA: Javafx application with icone on the Tray system
Here is an example of a class to display tryIcon: import java.awt.AWTException; import java.awt.Image; import java.awt.MenuItem; import java.awt.PopupMenu; import java.awt.SystemTray; import…
-
0
votes1
answer76
viewsA: Call Jdialog without closing/hide Jwindow
Test with these two classes... Jframe -->Telacarregamentoconfjf /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools |…
-
1
votes1
answer27
viewsA: Mutable jcombobox
Good for the error this line would be important to analyze: at javax.swing.JComboBox.setSelectedItem(Unknown Source) says that the selected value is null, try to take that line…
-
1
votes2
answers960
viewsA: Class X Diagram Entity-Relationship Diagram
Dude, your idea is right, the DB will start from Romanticism and then go to Orders, the Orders just have to have this FK to be able to locate and tell who he is "son", but not that his class has to…
-
1
votes5
answers578
viewsA: How to validate when Resultset does not find any value?
Well, in my projects, in case I really need to know if this resultset is empty or not, I do the following: rs.first(); //tenta mover o ponteiro ate a primeira linha caso exista if (!rs.first()){…
-
1
votes1
answer72
viewsA: Move File to JAVA Recycle Bin
As suggested by @Ezar the use of ToTrash() has worked. To see the java version just go to cmd and check that it is java 9 or later java -version The Netbeans IDE used was 11.…
-
1
votes1
answer72
viewsQ: Move File to JAVA Recycle Bin
Hello, there is some way I can move a File to the recycle bin instead of deleting it permanently? File f = new File("um caminho com um arquivo top aki); f.delete(); //retorna um true caso consiga…
-
0
votes1
answer64
viewsA: Jprogressbar loading in real time
A curiosity, it would not be easier to set the value of jprogress with the i? the for could be so: for (int i = fileSize; i >=0; i--) { v_Progresso.setValue(i);…
-
0
votes1
answer287
viewsA: How can I change the position of my Jbutton in Swing?
try to create things in reverse, for example from the inside out. set first the button and its properties (such as the location, setLocation(x,y)) and after all its set properties then include in…
-
0
votes1
answer80
viewsA: Joptionpane calling the screen Main
To display a jop you don’t need to instantiate it, just write JOptionPane.showMessageDialog(null, "Digite o código abaixo e clique em 'Solicitar Certidão' aguarde retorno da consulta, pressione OK…
-
1
votes1
answer196
viewsA: How to export database data, generate a csv and download?
A practical way would be to SELECT * FROM vendas INTO OUTFILE 'C:/vendas.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' the FIELDS TERMINATED BY ',' determines the separation…
-
0
votes1
answer41
viewsA: Line break in Defaultstyleddocument
Solved. The problem was in capturing the jTextPane1.getText().length(), the correct would be doc.getLength(), apparently the line break functioned once, but in a loop the doc tried to insert in a…
javaanswered Jonathan CR 673 -
0
votes1
answer41
viewsQ: Line break in Defaultstyleddocument
I’d like to know why the class DefaultStyledDocument error when inserting a line break, either by \n or by System.lineSeparator(). Minimal example: StyleContext sc = new StyleContext(); final…
javaasked Jonathan CR 673 -
0
votes1
answer29
viewsA: instance continues running even after being closed by a thread
tries to create this thread outside that scope it in the class variable declaration, and finally to finish it try the Join method().
-
0
votes1
answer27
viewsA: My Jtable does not update when I add a Row [Solved]
Each time you enter these conditional links of your DAO class, it creates a new Mainform instance and sends the data so it’s not right. Try to create a class that has all these attributes that you…
-
0
votes2
answers27
viewsA: I have a variable set by parameter. How do I use it on buttons (Action Performed)?
Remember that a Jframe is nothing more than a class. This class can have attributes declared at its beginning even before its constructor.. So an easy way to keep this "id" passed to this Jframe…
-
0
votes2
answers67
viewsA: How to programmatically rescue a newly inserted auto increment ID in JDBC?
has another mode also which is to get by last_insert_id().. it does not need to be returned in a resultset and can be passed as parameter to another sql.. Exp: sql = "INSERT INTO valorcliente…
-
0
votes1
answer253
viewsA: Mysql Workbench error setting foreign keys
try to create the keys separately: Alter table usu_ins add constraint fk_id_ins foreign key (id_ins) references insects(entry_cod); Alter table usu_ins add constraint fk_id_cad foreign key (id_cad)…
-
1
votes1
answer24
viewsA: Use class data in multiple Jframes
Well come on, a Jframe is nothing more than a class. Knowing this we also know that instantiated objects within a scope are visible only in this scope.. ie: public class Screen3 extends…
javaanswered Jonathan CR 673 -
0
votes1
answer39
viewsA: java database connection
well Oce already has its panel, now just know what Oce wants to return to its panel.. for example, the common use is the DAOS, they return something related to their own class. for example>>…
-
0
votes1
answer45
viewsA: How to return the index of a java ARRAY
public void mouseClicked(MouseEvent e) { /*escrever o indice "i" aqui não funcionaria? uma ideia seria definir o nome das jpanes e escrevelas nesse evento de click. */ …
-
0
votes1
answer35
viewsA: Problem in a connection class
Here is an example of my mysql connection class: remember to import the mysql library to your project. import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement;…
javaanswered Jonathan CR 673 -
0
votes1
answer45
viewsA: Problem with a method
try this: public Usuario validarSenha(Usuario u){ String sql = "SELECT id_usuario, login FROM usuario where login = ? and senha = ?"; try { PreparedStatement stmt = con.prepareStatement(sql);…
javaanswered Jonathan CR 673 -
0
votes1
answer87
viewsA: Main method in Jframe?
The main method is required for your main jFrame, or its class responsible for instantiating a jFrame.. it is good to have a main() in jFrames, since when trying to compile only that jFrame itself…
-
0
votes1
answer23
viewsA: Popular combobox with a list of a query
a hint would be to return a list instead of Boolean: public List<String> setores findAllSetores() { List<String> setores = new ArrayList<>(); /*operacoes*/ return setores; } then…
-
1
votes3
answers11171
viewsA: How to return the ID of a record right after it is inserted?
The generated key in auto_increment does not need to be returned in a Resultset, Following example: sql = "INSERT INTO tabela1 (ID_CLIENTE,total) VALUES (?,?)"; try { stmt =…
-
0
votes2
answers126
viewsA: Disfigured Netbeans
Netbeans for windows>> Install plugin by going to the "tools>>plugins" tab search for "easyUML" and install it.. after installed create a NEW PROJECT >> UML>> UML Diagrams…
-
0
votes1
answer21
viewsA: Add first item to Jcombobox
Apparently you have somehow set jCombo to accept only "State".... then your String cannot be "casted" (nen know if that word exists, but now it has existed) to "State".. When I manipulate values…