Posts by Renan Gomes • 19,011 points
435 posts
-
4
votes1
answer537
viewsA: How to open a password protected Word document?
I believe using only the open is not possible because you need to check the password and the method just launches the associated application to open the file type. However there is the POI which is…
-
1
votes5
answers10050
viewsA: Run script js when trying to close the window
I don’t know what version you’re using of jQuery, but the function unload() is deprecated since the version 1.8. You can use the function on() and wait for the event unload.…
-
2
votes2
answers321
viewsA: Problem with hasNext() Java
As an alternative to the way you are doing, you can use the method Files#readAllLines() that already reads all the lines in the file and returns an object List<String>. This will dispense with…
-
1
votes3
answers523
viewsA: Error in Hibernate
Apparently you are using version 3.2.4. To use the method AnnotationConfiguration#addAnnotatedClass() you need to import the jar file from hibernate-core version 3.6.0 or later.…
-
3
votes2
answers1452
viewsA: How to create an animated Progressbar to inform the strength of the password?
I would leave to use Javascript when it was really necessary. Animations and changing the appearance of an element can be done only with CSS. It is possible to use selectors by attribute to apply…
jqueryanswered Renan Gomes 19,011 -
1
votes2
answers243
viewsA: How can I associate 3 authors to just one book?
I don’t know if you’re familiar with Collections and Generics, but there is a way to solve the problem. Instead of your class Livro have a type attribute Autor, you may have a List<Autor>…
-
2
votes1
answer677
viewsA: Add bookmark system
You can use the Web Storage API since the only requirement is to keep this information when reloading the page, through the functions window#localStorage() and window#sessionStorage() it is possible…
-
5
votes1
answer836
viewsA: Site does not get responsive
You accurate define the metatag with the viewport in the document header: <head> <!-- ... --> <meta name='viewport' content='width=device-width, initial-scale=1'/> </head>…
-
2
votes2
answers17232
viewsA: Swap class with javascript or jquery
I’m only going to add one, Sergio’s answer has already killed the question with great solutions. I believe that in this case there is no need to exchange classes, .menu-disable may not even exist.…
-
2
votes2
answers162
viewsA: How to count state changes in fields with a certain class within a function?
You can use data-Attributes to "store" the element state. For example, having an element (input, select, textarea) with the attribute data-foi-modificado: <input type='text' data-foi-modificado…
-
8
votes1
answer11265
viewsA: How to create a dynamic progress bar considering all fields of a form?
Progress The tag <progress> was introduced in HTML5 precisely to display the progress of a task, i.e., it is not necessary to manipulate the property width of an element. Let’s face it, update…
-
5
votes3
answers1573
viewsA: Avoiding line breaks in text areas
As you are using Bootstrap, the example below uses jQuery. var ENTER_KEY = 13; $('textarea').on('keypress', function(event) { var char = event.which || event.keyCode; if (char == ENTER_KEY) {…
-
1
votes2
answers1588
viewsA: How to submit a form by pressing "enter"?
You don’t need to capture if the ENTER was typed in the input, because when the enter key is pressed inside an input element in a form, by default the form will be sent. What you need to do is…
jqueryanswered Renan Gomes 19,011 -
6
votes2
answers1819
viewsA: How to make a gif run only once?
Open the image in a graphical editor and remove the infinite loop option. Now, with Javascript you can create a static image in a canvas. And after a while (in this case, duration of .gif) the…
-
2
votes3
answers650
viewsA: Jquery calculate average and insert the result into the average field that is disable
You can use the function filter() to check if there are inputs empty at each change event, and only when the number of inputs is zero the calculation is performed: var temInputVazio =…
jqueryanswered Renan Gomes 19,011 -
1
votes4
answers756
viewsA: Remove a specific space in a string
As you said the format can be varied ( min, mins, miNs, etc...) I will post another way of doing considering the spaces and not the words. You can use the class Scanner for this, the staff only…
-
2
votes2
answers2880
viewsA: How do I popup a new Jframe?
You can create this popup using JDialog. Apparently you already use JFrame and knows that it is possible to add components to it, the JDialog works in the same way. import java.awt.FlowLayout;…
-
2
votes1
answer36
viewsA: Toggle_sidebar event
Use hasClass() to know if the element has the class the class that makes it active, for example: if($('.uib_w_43').hasClass('.uib_bar_visible')){ // Está ativo... } Or you can do without jQuery,…
javascriptanswered Renan Gomes 19,011 -
2
votes2
answers2303
viewsA: How to modify the HTML document via an extension?
There is already an answer on the development for Chrome, so I will try to explain in a simplified way how to do the same in Firefox. Mozilla provides a SDK which includes Apis for the development,…
-
4
votes3
answers1738
viewsQ: Is it possible to test only specific classes?
I have two classes of tests: class A { @Test public void fazAlgo(){ // ... } } class B { @Test public void fazAlgoMesmo(){ // ... } } My tests are taking too long because all classes are being…
-
1
votes2
answers7394
viewsA: How to change color of css header only
This will depend on how your HTML is structured, with the code you posted there is not much to do but assume that this header be the first direct child in body. I believe the easiest way is to…
-
2
votes1
answer1761
viewsQ: How to get the value of the <version> property in pom.xml?
I need to get the value of the current version of the application in various parts of the code. A priori I thought of creating a class containing the version: public class Version { public static…
-
1
votes3
answers5447
viewsA: Remove element Focus using pure Javascript
The function is the same: blur(). Example: var button = document.querySelector('button'); button.addEventListener('click', function() { this.blur(); }); button.addEventListener('blur', function() {…
javascriptanswered Renan Gomes 19,011 -
18
votes2
answers994
viewsQ: Why use a generic return?
I was looking at the signature of the class methods Optional and I don’t understand what that means <T> in front of the return of the method empty(): public static <T> Optional<T>…
-
6
votes2
answers738
viewsA: Why use/not use * box-Sizing?
This article by Sergio Lopes talks about the subject and shows how the specification of box-model is confusing. You use this property to define that, the size of an element must be calculated from…
-
6
votes2
answers175
viewsA: Use links in geometric shapes
Use the Randrade proposal or change its implementation. There is no way to center the link without the position is absolute because its element has no height defined, you have chosen to do the…
-
10
votes6
answers8730
viewsA: How to create geometric shapes using CSS?
Use polygon: svg polygon { fill: #666 } <svg width='200' height='100'> <polygon points='0,100 50,0 150,0 200,100'/> </svg> <svg width='200' height='100'> <polygon…
-
1
votes2
answers2969
viewsA: How to sort and sort strings without using Collection?
Use the method Collections.sort(List<T> list, Comparator<? super T> c). For this you need to create a class that implements the interface Comparable<T>. Whereas you have a list of…
-
1
votes4
answers3932
viewsA: How to align 7 elements on the same line?
Can use flexbox support: section { display: flex; justify-content: space-between } <section> <div>1</div> <div>2</div> <div>3</div> <div>4</div>…
-
3
votes2
answers318
viewsA: How do I leave an element with page height all the time?
There is no need to use Javascript if you do not intend to make use of this value while running your application. As I said, this menu will have the same size every time, so just the property height…
-
7
votes2
answers135
viewsA: While with incomprehensible format
Basically you are reading a text file character by character and concatenating to a string. This method FileInputStream#read() returns -1 when the end of the file is reached, then what you are doing…
-
2
votes2
answers4566
viewsA: Make 'Ubmit' button expect action from an Alert?
Not seeing your code gets a little complicated to answer for sure, but I believe it’s because the standard behavior of Submit is being fired. You can use Event.preventDefault to prevent action…
-
4
votes2
answers273
viewsA: .after() jquery on JS Pure?
Use insertAdjacentHTML(posição, conteúdo) (support): To posição is defined for the element by the following types: "afterbegin": Inside the element, before your first child (childNode). "afterend":…
javascriptanswered Renan Gomes 19,011 -
1
votes2
answers964
viewsA: How to take a string arraylist value, for a File array
If you have a ArrayList of strings, just scroll through it and use the "turn string" to create a new File(String pathname): ArrayList<String> arrayListDeStrings = ... // Populando…
-
1
votes1
answer378
viewsA: Parse HTML with Jsoup - Java
The example they provide there serves to better understand the simplicity of Jsoup to parse an html document, but you accurate treat failures that may occur. A way to initialize attributes doc and…
-
2
votes1
answer1444
viewsA: Add CSS to specific page via JS
var FILE = '/assets/css/meucss.css'; var css = document.createElement('link'); css.setAttribute('rel','stylesheet'); css.setAttribute('type', 'text/css'); css.setAttribute('href', FILE);…
-
2
votes2
answers2465
viewsA: How to fix an input within a responsive div
It is not necessary to "fix", just need to treat so that other elements do not overlap the text. One option is to use flexible layout, but check the support that browsers offer. If you need to…
-
2
votes1
answer1537
viewsA: How to change the standard source of Swing components?
According to that answer in jGuru you can define the source of each resource, only of the components you are interested in - in case the label and the button. UIManager.put("Button.font", /* font of…
-
1
votes3
answers840
viewsA: Countdown, split time by div
I changed only the HTML and removed a snippet in Javascript that checked the existence of the element with id='pageinval7' to write the values in the document: function countdown_load65() { var…
-
0
votes2
answers1661
viewsA: Redeem values from an XML contained in a String
It is possible to take the values with regex, but there is the disadvantage of needing to change it whenever you need to look for another element. I suggest you create one Document, so it becomes…
javaanswered Renan Gomes 19,011 -
2
votes2
answers1616
viewsA: How to customize scrollbar in div?
The problem is that customizing the scroll is not something that’s in the specification, so it’s not a need for browsers to implement this feature. Some include this feature and allows the scroll to…
-
5
votes2
answers1382
viewsA: Dynamically change style through JS
In HTML5 there is a tag <progress> which serves precisely this. The difference is that instead of modifying the width of an element, you will need to change only its value (attribute value).…
javascriptanswered Renan Gomes 19,011 -
2
votes1
answer300
viewsA: How to change the display of a select options on mobile devices?
Use Javascript to get the userAgent and check if the user is accessing the site with a browser mobile. If the value is true, simply remove the class that changes the appearance of the select. You…
-
21
votes1
answer7765
viewsA: Show image under another with css Hover
There are many ways to do it. I would choose to put the image of play in one element ::after not to dirty the html code, because it is only a "visual" information that the element is a media…
-
1
votes3
answers586
viewsA: How to apply CSS to HTML element before and after a text?
You can use the pseudo elements ::after and ::before to style the content before and after an element respectively. Thus you avoid unnecessary markup in HTML and do not need to choose to make use of…
css3answered Renan Gomes 19,011 -
3
votes1
answer165
viewsA: What is wrong with this Chrome extension?
First, there is a tag h1 unopened. Another problem is that your manifest is incorrect. Instead of popup, utilize default_popup: { "name": "RandomHype", "version": "1.0", "manifest_version": 2,…
-
3
votes2
answers548
viewsA: Facebook Page Plugin giving "Failed to load Resource"
Apparently the problem is being assumed that the resource is on the computer, perhaps because you are leaving the URL without protocol. If you look at the error message, the searched resource is…
-
2
votes2
answers52
viewsA: I believe my mistake is in the matrices, or type conversions, but how to solve?
The problem is that you are assigning values to a null object. You need to instantiate a Point before assigning attribute values x and y. import java.awt.Point; public class MapeiaTela { int[][]…
-
2
votes2
answers155
viewsA: How to do this effect with CSS
It’s easier to use SVG than trying to do everything with CSS. polygon { fill: #F7941D } text { fill: #000 } <svg width='600' height='200'> <g> <polygon points='0,20 20,0 580,0 600,20…
cssanswered Renan Gomes 19,011 -
2
votes1
answer475
viewsA: How to show Hashmap value?
It was not clear, but in his example apparently there is always a Pattern, one type and a value. So why not create an object with these attributes? public class Element { private String pattern,…