Skip to content

Tag: java

Guice injector in JUnit tests [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago. Improve this question Using Guice, is it a good practice to get a new injector in each JUni…

JTable -> TableModeListener

I have this JTable having a DefaultTableModel as its model. On the table I have several swing component, JComboBox and JCheckBox, set on a particular column via DefaultCellEditor and DefaultCellRenderer. The TableModelListener was added to the table to capture changes on editable columns. The rest of the colu…

How to make Java Swing components fill available space?

I cannot seem to get my Java Swing components to work together correctly. What I want to do, is have a JPanel fill ALL the space available inside a JTabbedPane. At the moment, my setup is as follows: This creates a windows that is my desired size (dynamically proportional to the screen size, not included in a…

How can I initialize an ArrayList with all zeroes in Java?

It looks like arraylist is not doing its job for presizing: Afterwards when I try to access it: Instead of returning 0 it throws IndexOutOfBoundsException: Index 5 out of bounds for length 0. Is there a way to initialize all elements to 0 of an exact size like what C++ does? Answer The integer passed to the c…

How does Archiva compare to Nexus?

There are a few similar questions already, but most are either focused on Nexus vs. Artifactory, or are a few years old. I wanted to get a sense of where the two project stand these days. My impression is that Nexus is the best regarded repository manager, but I do tend to (slightly) prefer purely Free projec…

Dynamically loading a class in Java

I looked up the syntax and searched the api but am still confused about the process. I also searched Stackoverflow. What is the proper way to load a class and create an object out of it dynamically? In otherwords I want the user to specify what type of object they want to create, and then create that type of …