I'm not even sure if I'm trying to place it in the correct area in the code. However I like to perform this prior to the receipt being displayed so if there a issue the user can correct this before the final receipt has been sent .......
So what I do normally is draw the bottom layer of grass, and when I draw the second layer with trees, the tree layer has a shadow, that shadow doesn't go ontop of the grass layer, but instead it overwrites the grass layer aswell and I've checked the color codes, the shadow has combined with white, not the first layer.
it's obvious that that's not how alpha works then, how do I do it?
There is a method taken from a class with several try and catch blocks. If you think it is possible, add one more catch block to the code to catch all possible exceptions, otherwise say 'Not possible' with your reason.
for (int w=0;w<bi.getWidth();w++) { for (int h=0;h<bi.getHeight();h++) { int color = bi.getRGB(w, h); color = color << 5; bi.setRGB(w, h, color); } }
I am using a solid green image so
11111111000000001111111100000000
I just wanted to see how it looked so bumped it over 5 places (obviously changing the color). To my surprise, there was no added transparency. I mean moving it to the left would make the alpha:
11100000
I am thinking that setRGB() doesn't effect alpha. Is this accurate?Tested it and in fact setRGB has no effect on the alpha bits. So now the question is how can I gain access to them. I am going to look into the writable Raster API. Perhaps, I can also use a modified awt to access directly OS data.
I have java program that I am debugging with NetBeans. In it I open a serial com port. It seems that if I exit the program the serial port is not closed so I cannot get the port the next time I start the program.
Is there a way I can detect that either the user clicked the "X" in the upper ight of the GUI or I clicked the "Stop Button" in NetBeans?
I just started learning Java, I was asked to write a simple program that prints a message if it encounters the number 7 or its multiple.
This should be achievable using simple loops and simple operations...
Here is my attempt:
Java Code:
Scanner scan = new Scanner(System.in); int i, j, temp; i = scan.nextInt(); // Awaiting user input j = scan.nextInt(); // Awaiting user input if (i > j){ // i = 10 j = 0 temp = i; // temp = 10
[Code]...
Now it works fine for numbers that are less than 70...
I am not sure what to do in case if for example 'i' and 'j' are very big numbers
I mean, I need it to detect the 7s even if it in the thousands place, actually - no matter how big is the number... So far I only made it to work for numbers that are less than 70...
i can use this current code to change it so that it use TextArea in jsp and the keylistener code in servlet. i know i have to take out the JFrame,JTextfield and ContentPane but still i could not do it.
i want to create an application which detect an image which took from camera and to process it so that it can be verified ..for example number plate of the vehicle ..if i need to extract the numbers from the image ..
I am new to java and i want to create an application which detect an image which took from camera and to process it so that it can be verified ..for example number plate of the vehicle ..if i need to extract the numbers from the image ..
My project builds a war. In the war there is a jar A which provides the implementation I1 of interface I. I1 is injected in a JSF controller. There is an optional jar B which provides another implementation I2 of interface I. I2 has an higher priority than I1. Is there a possibilty to achieve when jar B is present in the war I2 is injected. I tried it with @Alternative on I2 with an entry in beans.xml as alternative in jar B without success. I1 is injected. Something like a priority would be necessary. Or probably I am on a wrong way and there's another one that fits for my use case?
I would like to know how much of memory is free and used my java program.I have used Runtime.totalMemory and freeMemory() functions. However, how come used memory is so different than java.exe process show in windows task manager?
I am working on SpringMVC web application. Is there any way to detect from browser(jsp page) that any (exe) application is installed or not on client machine? And if not installed then show user the Popup to download that Application or Software . And if the user rejects to download that application then not allow him/her to login ....
I have a JTable with 5 columns, named: "ID", "Name", "UnitPrice", "Qty", and "Total". Only the columns UnitPrice and Qty are editable by the user. When, for example, for a row in the JTable, the user types 5000 in the UnitPrice column, and types 15 in the Qty column, I would want that when he types the first character in the Qty column (i.e. the character 1) in the Qty column, the Total column displays 5000*1, in other terms 5000.
And when the user types the second character in the Qty column, i.e the character 5, after having typed 1, the Total column should display 5000*15, in other terms 75000. So, to say it concisely, I would want that the Total column refreshes accordingly each time the user types a character in the Qty column. I have tried to use the MouseClicked event of the JTable, but noticed that that does not solve my problem. is there an event I should use to refresh my Total column? Or should I proceed in another fashion?
I wrote a program using switchcase.I used do while to show the menu to the user until the user decides to exit the menu.I used try catch to prevent ant exception and it worked properly.But i got one problem.When exception occurs,desired msg is printed but i am unable to display the menu to the user.So user wont be able to continue after an exception is caused.
public class ThrowException { public static void main (String[] args) { var x=prompt("Enter a number between 0 and 10:",""); try { if (x>10){ throw "Err1"; } else if (x<0){ throw "Err2"; } else if (isNaN(x)){ throw "Err3"; } } catch(er){
[code]...
It's telling me where catch(er) is: <identifier> expected..I've watched videos, but no one seems to encounter this error....am I missing a segment of code?
In the following piece of code Iam confused as to where the InputMismatchException in the catch block is thrown on the first place? Is the InputMismatchException thrown automatically with declaring to throw the exception?
import java.util.*;
public class InputMismatchExceptionDemo { public static void main(String[] args) { Scanner input = new Scanner(System.in); boolean continueInput = true;
Is it a best practice to return from try block or place return statement after try-catch when we intend to return a value from a method(* Catch block is being also used to rethrow the exception)??
So method invia call the method popolaScompiute, inside popolaScompiute there is an iteration through some id and for some id can occur an error; what i want is the getting the value of id in the first method invia, using the block try/catch. Is there a way to accomplish this?
Regarding return statements within methods. So I have a method containing try and catch block (as required) and much like when you have an if else statement... I noted you have to return an object for both the try and catch blocks. Now in my case my method should return a List object.
The way I have tried to overcome this:
- I've initialised a List object to null as an attribute of the class I'm working in. - Therefore in the catch block would just simply return the null List object, where as the try block would return the non-empty List (which is what I want). - I then just test to see if the List != null, when the method is invoked... and that is that.
However the method always seems to return null (when it shouldn't).
I've been assigned to write a program that will convert binary to decimal that uses the try/catch block. In the program that I have written, I was wondering if it is possible to write an addition catch statement that will present an error if any number other than a 0 or 1 is entered by the user. I have already done this in the binaryToDecimal method, but I am just messing around to see if it is, in fact, possible.
Java Code:
import java.io.IOException; import java.util.Scanner; public class BinaryToDecimal { public static void main(String[] args){ Scanner input = new Scanner(System.in);