|
How to make a scrolling background for a JPanel in java? I tried searching google but couldn't find a helpful one.
|
|
|
|
|
Do you mean manual scrolling, or something that scrolls by itself? And how would that affect any other controls that are in the panel?
|
|
|
|
|
I have a jpanel with an image as a background . how can i make that scroll like in a game ?
|
|
|
|
|
|
sir i don't want scroll panes . i want my jpanel background image to scroll horizontaly automatticaly.i am making a game.
|
|
|
|
|
|
But I have seen many people making that using pure java. Sir please if it is not possiblie Please help me for this:-
I am using this code to make an image the background of a jpanel -
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(bgImage, 0, 0, null);
}
Sir how can make the background a gif using this code. Sir please help me. I beg.
|
|
|
|
|
|
Sir you are the only one who replied to my questions. I am very very thankfull for you.
|
|
|
|
|
Hi, I'm a student of Computer Science I have a little task which is I want to read the certificate from USB Token(Entersafe PKI Manager - Epass2003 Auto) and after that, I print it on the Eclipse Console using Java Can Anyone Help me please with this solution.
|
|
|
|
|
I am an absolute beginner in java and l want to practice java code in eclipse code editors. I want to know that do l have to set up the environmental variables first to run programs in eclipse? And also is there will be any harm or changes to my system after setting variables? Please help me..
|
|
|
|
|
|
Recently, l have downloaded jdk in my Windows 10. Now, l didn't rememberd which version of jdk l have installed in my system. I want to know that which version of jdk is installed in my Windows. Please help me.
|
|
|
|
|
java -version
Type that command at the console. And try making use of the documentation.
|
|
|
|
|
Thank you so much for helping me sir but l didn't got your point that what you're trying to say.
|
|
|
|
|
Open a cmd window and type "javac -version". The result will tell you which version of the JDK you have installed.
|
|
|
|
|
|
Might want to also use the following commands. Just as with the other in a command window.
javac -version
where java
where javac
First will show the compiler version. Which should be the same as the java version.
Other two will show you where it is finding those commands so you can verify that it is what you expected.
|
|
|
|
|
Good afternoon! I'm trying to create a custom generic Bean Validator for the email of an author and the name of a category to verify that they are unique and I wish I could use a custom JPQL, the name of the persistence unit in persistence.xml and other variables. However, I don't know how to pass variables inside isValid, I only know how to hardcode them.
public class UniqueFieldValidator<T> implements ConstraintValidator<UniqueField,T> {
@Override
public boolean isValid(T value, ConstraintValidatorContext context)
{
EntityManagerFactory emf = Persistence.createEntityManagerFactory("project");
EntityManager em = emf.createEntityManager();
String jpql = "select a from Author a where a.email = :pEmail";
TypedQuery<Author> query = em.createQuery(jpql, Author.class);
query.setParameter("pEmail", value);
Optional<Author> optAuthor = Optional.of(query.getSingleResult());
if(optAuthor.isPresent())
{
return false;
}
return true;
}
}
modified 3-Jul-21 13:26pm.
|
|
|
|
|
Default Is Valid Implementation As Below public boolean isValid(Object value, ConstraintValidatorContext ctx)
|
|
|
|
|
Hi I am developing a library management system in net-beans. When I run it on my system it works fine however, if try to run it on another system it gives me an error of javax.persistence.Persistence.createEntityManagerFactory("path_to_database_on_my_system"). But this path to database must be changed in this function. How would I do this? Need Help.
|
|
|
|
|
Been messing around for hours and eventually decided to seek the assistance of the internet.
I am trying to make a program where I/the user can add elements into an array (Name, age gender). Once elements have been added to the array, I want to then be able to search a String (name) to find the desired name I am after in the array. The context of the program is adding Climbers to a Climber Database (just an array) of who has climbed what mountain (haven't attempted adding the mountain stuff yet).
In what I've written so far, I keep getting the return null, saying that the searched String cannot be found. I have a feeling that I am failing to pass the parameters of the added element in the array.
For example, I add a 'climber' with the name John, 19, Male in the Climber Class. I then go to the ClubStats class to getClimber and search "John", the only one in the array and I receive a null..
FYI I am using BlueJ here so at a serious basic level.
public class Climber
{
private String name;
private int age;
private String gender;
public Climber(String newName, int newAge, String newGender)
{
name = newName;
age = newAge;
gender = newGender;
}
|
|
|
|
|
I understand that a NPE can come from a variable or method returning null. But what I'm trying to do is get a bank account balance. To do this I first have to correctly enter the account id and nip, which I can do without problems. Then I have 4 options to pick from (right now I only have one implemented properly) so I pick Consulta (consult) and what I should be getting is the account balance but I get a NPE error. Can someone help me figure this out? The classes involve during this process should be SolicitudSaldo (consult balance), ATM, Cuenta (Account), BaseDatosBanco (Bank data base) and Transaccion (Transaction). I think the problem might have to do with how I declare ATM in my Jframe INTERFAZ_TRANSACCIONES.
I'll paste a link to my code since It's quite a lot and I don't want to make this post any longer. My project is in the master branch.
Heres a link to my project in gitHub
GitHub - Emmanck613/ATM_02[^]
|
|
|
|
|
No, we can't - as you say it's "quite a lot" of code - and it needs your data to duplicate the problem.
So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. How you use it depends on your compiler system, but a quick Google for the name of your IDE and "debugger" should give you the info you need.
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.
Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Fortunately I seem to have found the problem, as I suspected, it had to do with how I declared ATM in my jframe.
|
|
|
|