Is there any class which lets me set brightness to an image, preferably BufferedImage but it doesn't really matter, and then whenever desired remove the brightness. I have tried using RescaleOp, but it doesn't satisfy the latter criterion. When I have brightened the image, I can't seem to get it back to normal.
Java Code:
RescaleOp op;
if(image should be brightened){
float scales[] = {2f, 2f, 2f, 1f}, offsets[] = new float[4];
op = new RescaleOp(scales, offsets, null);
op.filter(getImage(), getImage());
}else{
float scales[] = {1f, 1f, 1f, 1f}, offsets[] = new float[4];
op = new RescaleOp(scales, offsets, null);
op.filter(getImage(), getImage());
} mh_sh_highlight_all('java');
When I try to brighten my BufferedImages with RescaleOp, they are cut in half, and not brightened at all. However, strangely enough, when I tried to run the same program on another computer they were not cut in half, but only one half of the image was brightened. Here are two images displaying the issue:
Before brightening:
After brightening:
Why does this happen? Are the images not loaded properly, or am I simply not using the class correctly? Here is my code:
Java Code: ...
RescaleOp op = new RescaleOp(1.2f, 0.0f, null); op.filter(enemies.get(y).getImage(), enemies.get(y).getImage()); ... mh_sh_highlight_all('java');
This is my code and it works! But how/where do I set a background image for it to appear as the background of my calculator? The code I have for it is this -
import javax.swing.*; import java.awt.*; import java.awt.event.*; /** * Program using SWING components to create a Christmas themed Calculator. */ public class ChristmasCalculator implements ActionListener
I recently made a game. But, I want to package it and give it to my friends. I know that I can create a jar of it and add the images to the folder, but what I would absolutely love is for it to just be a picture with the game name and click to run. The second thing is to replace that java icon to an icon of my preference, which I have been told numerous times to do with
Sir, I'am new to Swing Programming. I have to create an application where an image is displayed on one Label. The same image has to be split in parts and stored in database pert wise. Later the user has to retrieve the entire image by viewing a small part of the image. I have already displayed the full image on the Label, now i don't know how to split the image and store it part wise in the database.
I stored an image into MySQL database using swings and hibernate but I am struggling to retrieve that image from MySQL database and display same image in the jTable cell and same as on jLabel whatever I retrieve from the database using swings and hibernate .
I'm trying to make a method that takes an image and turns it into a tile image. So if the original image looks like this:
[URL] ....
then the output image should look like this:
[URL] ....
Here's a method that's supposed to do that but for some reason the output image looks the same as the original:
public static int[][] tile(int[][] arr){ int[][] tile = new int[arr.length][arr[0].length]; for (int i = 0; i < arr.length; i++) { tile[i]=arr[i]; } return tile; }
I recently changed the method and the error message I'm getting is "bad operand types for binary operator '+'. Here's the method:
public static int[][] tile(int[][] arr){ int[][] tile = new int[arr.length][arr[0].length]; for (int i = 0; i < arr.length; i++) { for(int j=0; j<arr[i].length;j++){ tile[j]=(tile[j])+(arr[i]); } } return tile; }
Here are two codes that I am using but I have one that just doesn't work for some reason and the other does. Encode doesn't work. I don't need the Character.isAlphabetic for encode but not sure what I can use with 'if' to set the String encodedString.
I have been playing around with a snippet I wrote to get the Label on a drive (below). It works fine for me (though I will take any constructive criticism). My question is whether the is a way to set the drive label, purely with Java. I know I could call command line, or even resort to using the Windows API
I tried using this since the jSpinner's minimum value is 1.. (I want it to reset the jSpinner after updating the database):
jSpinner1.setValue(new Integer(1));
But gives me an error:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1 at java.util.Vector.elementData(Vector.java:730) at java.util.Vector.elementAt(Vector.java:473) at javax.swing.table.DefaultTableModel.getValueAt(DefaultTableModel.java:649) at shop.jSpinner1StateChanged(shop.java:267) at shop.access$100(shop.java:22) at shop$3.stateChanged(shop.java:145) at javax.swing.JSpinner.fireStateChanged(JSpinner.java:457)
JFrame{ JPanel(That MenuBar at the top) JPanel(That panel at center with table){ JScrollPane{ JTable } } }
I want to add my custom image to that grey space right there. I guess it is a JScrollPane, because I added that orange background on JPanel that contains it. But when I add this code to my custom class of JScrollPane:
@Override public void paintComponent(Graphics g) { super.paintComponent(g); if(background == null){ background = new ImageIcon(ClassLoader.getSystemResource("tableBg.png")).getImage(); } g.drawImage(background, 0, 0, null); }
The result is the same, no changes.
Then I read some documentation. I found this method:
scrollPane.getViewport().setBackground(Color c);
It works, but it accepts only color and I want to add image. Is there any way to do that? Do I need to subclass JViewport and use paintComponent ? If yes, then how to make getViewport() method return my custom subclassed version?
I have a PDF file and I have a text file that contains this data. It has the name of a PDF field along with a database table column name.
Text file: pdfFieldEmployee=Employee; pdfFieldStartDate=StartDate; pdfFieldSalary=Salary; pdfFieldExempt=Exempt
I also have this hash map that contains the database table column names along with their corresponding values:
Employee, Don Parker StartDate, 5/6/2000 Salary, $55000 Exempt, N
How would I read through the text file and the hash map and at the same time do this:
if the pdf field is equal to pdfFieldEmployee, then set pdfFieldEmployee equal to Don Parker. if the pdf field is equal to pdfFieldStartDate, then set pdfFieldStartDate equal to 5/6/2000.
and so on and so on. I would prefer to do this with a loop because I think it would take less code than writing a bunch of if statements.
This is my frame class, now I want to be able to change the name of the frame, and get the name with frame.getName() in another class. But I'm not sure how to do this, i tried making a new frame in that class but i feel it's just another frame and not the one i made, also tried something like
After installing JDK, I extended my system path to include C:Program FilesJavajdk1.8.0in. However, javac is only recognised if im in directory C: but that doesn't apply to the Java (run) command which works when Im in the sub-directory that has my .class file. Is there a way to make javac work when Im in a sub-directory?
I am rather new to Swing, and I am building a game right now in which I need to display a pop-up window as a reminder for what commands exist within the game. I created a class extending JFrame for this and added all the information I need. However, for some reason, no matter how many different ways I try to set the size of this window (setSize(w, h), pack(), using a different layout, adding the compnents to a JPanel first and setting the preffered size of that, then adding the JPanel to the JFrame), it doesn't work. Instead of a window of my requested size, I get a tiny, maybe 100 x 100 pixel window that needs to be resized in order for its contents to be visible.
Recently I have been working on an executable launcher. I tried to get the executable icons and set them on the JButtons. Still there are some problems. Here is a part of the code:
Here the getConfig() method is already defined to get a string in a "properties" file. However, the icons are very small and they don't fill the entire button.
How can the icon fill the entire button (for example, having a custom size of 48x48, or automatically filled the button)? The frame will not be resized.
I have a requirement where I have a class as Page which itself contains ArrayList<Page>.Here ArrayList<Page> is nothing but the pages which are accessible from the base Page.I know the depth level ( reading from file) which means how many level I need to go to identify more pages.BUT the problem is how to set the base Page class. I need to set the base Page class but for that I need the objects for the subsequent pages and hence an iterative type of implementation.
dynamically create tabs by pressing a button, each tab has Primefaces input texts in which i'll be adding stuff and with a Submit button i'm submitting the form.
My issue now is this; although I can create more buttons through my managed bean, I cannot set the ValueExpression to the InputTexts. When I do:
inputName.setValueExpression("value", createValueExpression("#{cdiBean.name}",String.class)); it doesn't work.
The createValueExpression is a static method in my managed bean and it returns a ValueExpression. I'm most certain I found it online, not sure where though, it's been over a month since the last time I worked with this topic.
Anyway, is my whole "methodology" correct? Should I do anything differently?