RescaleOP - Setting Image Brightness

Aug 1, 2014

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');

View Replies


ADVERTISEMENT

Setting Brightness With RescaleOp

Jul 3, 2014

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');

View Replies View Related

Setting Image As Background?

Jan 9, 2015

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 -

window.setContentPane(new JLabel(new ImageIcon("C:UsersComputerDownloadschristm as1.jpg")));

My code is below.

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

[code]....

View Replies View Related

Setting Background Image In Java

Mar 7, 2014

I want to set a background image in Java but nothing is working...

Java Code:

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.FlowLayout;

class Background extends JPanel{

[Code] ....

Everything works fine except the picture, it's not showing. The b.png file is in the folder where the java file is. What should I do?

View Replies View Related

Setting Image Icon And Closing Up A Game

Jan 23, 2014

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

frame.setIconImage(Image image)

which does not work for me.

View Replies View Related

Load Image From Database And Show In A Label (setting As Icon)

May 31, 2014

I've an image memorized into a databas in tinyblob form.

I call it in java in this mode:

Product p = new Product();
...
p.setImgByte(rs.getByte("ImmagineByte"));

(p is a javabean, and imgByte is a byte format variable)

Once done that, what i've to do for show it into a swing label?

I've already setted an image retrieving it from an url in this mode

PHP Code: Image img = ImageIO.read(new URL(a.getImmagine()));
Image resizedImage = img.getScaledInstance(imgContainer.getWidth(), imgContainer.getHeight(), Image.SCALE_SMOOTH);
imgContainer.setIcon(new ImageIcon(resizedImage)); mh_sh_highlight_all('php');

But i don't know how to do the same thing with a byte format image inteasd of the url...

View Replies View Related

Swing/AWT/SWT :: Image Manipulation - Create Application Where Image Is Displayed On One Label

Apr 7, 2014

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.

View Replies View Related

Retrieve Image From MySQL DB And Display In Jtable If Image Type Is Medium Blob Using Swings And Hibernate

Jan 5, 2015

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 .

View Replies View Related

JSP :: String URL For Image In Database And Show Image In File

Dec 24, 2014

I had string url for image in mysql database and I want show image in mu jsp file bu I can't.

<c:forEach var="urun" items="${listUrun.rows}">
<tr>
<td><c:out value="${urun.kitapresim}" /></td>
<img src="<c:url value="${urun.kitapresim}" /> " width="270" height="190"/>

URL...

View Replies View Related

JButton Image Does Not Show On Background Image

Feb 23, 2014

I successfully added a background image on the Panel but I can't create my JButton image on top of my background image.

ImageIcon piano = new ImageIcon("src/img/piano_backgrd.png");
JLabel backlabel = new JLabel(piano);
panel.add(backlabel, new Integer(Integer.MIN_VALUE));
backlabel.setBounds(0, 0, piano.getIconWidth(), piano.getIconHeight()); 
JButton volup = new JButton(new ImageIcon("src/img/volup.png"));
volup.setLocation(10, 0);
panel.add(volup);

View Replies View Related

How To Turn Image Into Tiled Image

Nov 21, 2014

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;
}

View Replies View Related

Setting X And Y For String

Feb 15, 2014

I have been learning java and studying Swing but now i have a problem, i want to set x and y coordinates for this

Java Code:

JLabel jlbWorld = new JLabel("You have spawned"); mh_sh_highlight_all('java');

But how (I have searched internet for answers but all of them have JPanel)

View Replies View Related

Setting A String Using If

Oct 23, 2014

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.

Java Code:

private String prepareString(String plainText)
{
String preparedString = "";
for(int i = 0 ; i < plainText.length();i++)
if(Character.isAlphabetic(plainText.charAt(i)))
{
preparedString = preparedString+Character.toUpperCase(plainText.charAt(i));

[code]....

View Replies View Related

Setting A Drive Label

Sep 22, 2014

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

import java.util.List;
import java.io.File;
import java.util.Arrays;

[Code]....

View Replies View Related

Error Setting Value For JSpinner

Apr 19, 2014

I'm using a jSpinner Number model:

Here's my code:

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int qty2, total, payment, change;
String title;

[code]....

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)

View Replies View Related

Setting Background Of JScrollPane?

Aug 19, 2014

My program's tree:

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?

View Replies View Related

Setting Values In PDF Field?

Dec 12, 2014

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.

View Replies View Related

Getting And Setting Frame Name From Another Class

Aug 7, 2014

package com.simbaorka101.te.gui;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.event.DocumentListener;

[code]....

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

public JFrame getFrame(){
this.getFrame();
}

and few variations but it was wrong.

View Replies View Related

What Does Setting Object Equal To Another Do

Mar 5, 2014

I've seen this done in code:

For example:

Java Code: BufferedImageOp op = new ConvolveOp() mh_sh_highlight_all('java');

What does this mean? Is it creating an object of convolveOP for the BufferedImage class?

What does it mean when you set an object from one class equal to another?

View Replies View Related

JSP :: Getting And Setting Bean Property With Tag

May 11, 2014

Will it make any difference if I put the last line of code inside the useBean tag ?

<jsp:useBean id="person" class="foo.Person" scope="page" >
<jsp:setProperty name="person" property="name" value="Fred" />
</jsp:useBean>
<jsp:getProperty name="person" property="name" />

It gives me the same output though....

View Replies View Related

Setting Environmental Variables?

Apr 6, 2014

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?

View Replies View Related

Swing/AWT/SWT :: Setting Size Of JFrame

May 26, 2014

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.

import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

[code]....

View Replies View Related

Swing/AWT/SWT :: Setting Icon On JButton

Feb 23, 2014

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:

try {
button[i].setIcon(FileSystemView.getFileSystemView().getSystemIcon(new File(getConfig("path." + (i+1)))));
}
catch (NullPointerException ex) {
}

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.

Here is the whole code...

import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import java.io.File.*;

[Code] ....

View Replies View Related

Recursive Implantation For Setting Objects

Apr 8, 2015

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.

View Replies View Related

Setting Int And String To Index In ArrayList

Apr 27, 2015

I would like to know how to set a int and a string to the same index in Array list. For example index 0 would have 5 and "Apple".

View Replies View Related

JSF :: Binding Components And Setting ValueExpression?

Dec 19, 2014

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?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved