This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 124 - Pages: 9 [ Previous | 1 ... 3 4 5 6 7 8 9 | Next ] - Last Post: 25-Jul-2015 21:51 Last Post By: ctwist Threads: [ Previous | Next ]
ctwist

Posts: 562
Registered: 27-Sep-2003
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 07-Jun-2015 05:01   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff wrote:
ctwist wrote:
The screenshot shows that you executed compile_all.bat in the wrong folder. It must be in "Slide Show 4\src", since it compiles all .java files in the current folder.
javac.exe must be in the system path. When you installed the JDK, the system path should have been updated. Maybe you need to restart the PC to complete this.
I got the compiler working after I changed the bat file into:
C:\Progra~1\Java\jdk1.8.0_45\bin\javac -source 1.6 -target 1.6 -classpath .;c:\progra~1\jAlbum_64\lib\jalbum-core.jar;c:\progra~1\jAlbum_64\plugins *.java > test.txt 2>&1
@echo off
move *.class ..\plugins
But I get a lot of errors:
warning: [options] bootstrap class path not set in conjunction with -source 1.6
CustomUI.java:10: error: package se.datadosen.component does not exist
import se.datadosen.component.*;
^
CustomUI.java:11: error: package se.datadosen.util does not exist
import se.datadosen.util.*;
^
CustomUI.java:12: error: package se.datadosen.jalbum does not exist
import se.datadosen.jalbum.*;
^
etc.
See also enclose file test.txt

Have a nice motorbike week!

At the end of next week I go with my VW camper to Sweden for a holiday, so it will take some time before we get this working!

I am on a tablet on a motel with wi fi connection so this message is not well formatted.

Do not specify a path for javac in the bat file. You will successfully start the program but other components will not be found. You must ensure that the JDK bin folder is in the system path. I cannot tell you how to do this. There must be many sites that can help with this.
AndreWolff

Posts: 1,766
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 07-Jun-2015 09:46   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
I finally got it compiled with this batch file:
javac -source 1.8 -target 1.8 -Xlint:unchecked -classpath .;"C:\Program Files (x86)\jAlbum_64\lib\jalbum-core.jar";"C:\Program Files (x86)\jAlbum_64\plugins" *.java > log.txt 2>&1
@echo off
move *.class ..\plugins

I use for the present the JAVA 8 version, because that was installed with the Java SDK. (I guess at the time I really understand this, David is using also JAVA 8 !!).

I see no error, only warnings and to see these I added -Xlint:unchecked

The compiler says that there are problems with all my comboxes:
SkinPanel.java:68: warning: [unchecked] unchecked call to JComboBox(E[]) as a member of the raw type JComboBox
	JComboBox fontFamily = new JComboBox(new Object[] {
	                       ^
  where E is a type-variable:
    E extends Object declared in class JComboBox


Line 68 contains this statement:
	JComboBox commentPos = new JComboBox(new Object[]
	 {"above image", "below image without shadow", "below image with shadow large", "below image with shadow small", "below image in box", "below image in the border","above image in the border" }
	);

I use this already for years in the uncompiled version of onload.bsh.
The only difference I see is that ctwist did add 'import javax.swing.JComboBox;' which was not in my original onload.bsh file.

So what is wrong with the declaration of my comboboxes?
monkeyboy

Posts: 83
Registered: 21-Jun-2008
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 07-Jun-2015 11:44   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
Replace all instances of:
JComboBox xyz = new JComboBox(new Object[] {

.. with:
JComboBox<Object> xyz = new JComboBox<Object>(new Object[] {

BeanShell (interpreted Java) does not support generics but the format above is required (for JComboBox) if you want to compile your code in Java 7 or 8 and avoid unchecked warnings during compilation.
You can read more about generics here: https://docs.oracle.com/javase/tutorial/java/generics/index.html
JeffTucker

Posts: 6,883
Registered: 31-Jan-2006
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 07-Jun-2015 14:30   in response to: monkeyboy in response to: monkeyboy
 
  Click to reply to this thread Reply
NetBeans says that this is redundant:
JComboBox<Object> xyz = new JComboBox<Object>(new Object[] {
It wants this, instead:
JComboBox<Object> xyz = new JComboBox<>(new Object[] {
AndreWolff

Posts: 1,766
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 07-Jun-2015 19:34   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Thanks, that helps removing warnings, but I still have warnings of this type:
PanCustomUI.java:41: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type HashMap
						vUserVars.put("maxImageWidth", new String("50000"));
						             ^
  where K,V are type-variables:
    K extends Object declared in class HashMap
    V extends Object declared in class HashMap

for this statement:
vUserVars.put("maxImageWidth", new String("50000"));

Any idea how to remove this warning?
JeffTucker

Posts: 6,883
Registered: 31-Jan-2006
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 07-Jun-2015 19:52   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
Just a guess, but try:
vUserVars<String, String>.put("maxImageWidth", new String("50000"));
The other option is to turn off the warnings. The compiler is a bit over-fussy.
AndreWolff

Posts: 1,766
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 08-Jun-2015 00:21   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
jGromit wrote:
Just a guess, but try:
vUserVars<String, String>.put("maxImageWidth", new String("50000"));

No that is not correct, so I will follow your advice and turn off the warnings
AndreWolff

Posts: 1,766
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 08-Jun-2015 08:44   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
ctwist wrote:
I have attached an updated Java zip file to my previous message.

Eclipse identified these problems. I have not fixed them:

int returnVal = fc.showOpenDialog(window);
if (returnVal != null)
This is the correct code:
	int returnVal = fc.showOpenDialog(window);
	if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {
ctwist

Posts: 562
Registered: 27-Sep-2003
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 08-Jun-2015 15:30   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
Don't worry about compiler warnings. I reviewed the warnings and I don't think they will cause any problems. Most of the warnings are because you don't catch unexpected objects in the maps. However since SS4 controls what is added to each map, the map will never contain an unexpected object.

Also when declaring a map, you can identify the type of objects that the map can contain. You could do this, and this will eliminate some warnings, but this is not necessary.

Edited by: ctwist on 08-Jun-2015 09:31
JeffTucker

Posts: 6,883
Registered: 31-Jan-2006
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 11-Jun-2015 00:53   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
I'm using a variation on ctwist's excellent code in the next releases of a couple of my skins. I allow Matrix/MatrixSlide users to tell the skin to treat a specific image as a pano, and let them choose image bounds different from those in the album project. I also turn off the run through XBorderFilter for drop-shadows, which look crappy on a pano.

I thought I could take a couple of shortcuts along the way, but those just produced the occasional nasty "null pointer" error, so stick with what ctwist has kindly given us. ;)

I'd love to get rid of the compiler warnings - it really doesn't like the vUserVars.put() method. They are, of course, just warnings, not actual errors, but like most techies, I have a touch of OCD. I've tried all sorts of gyrations to make the compiler happy, but nothing seems to work. Perhaps David can take pity on us....

(FWIW, I've now abandoned Java 6 and Java 7 - next skin releases will require Java 8. I even dumped the JDK 6 and JDK 7 files from my PC.)
monkeyboy

Posts: 83
Registered: 21-Jun-2008
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 11-Jun-2015 01:28   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
jGromit wrote:
I'd love to get rid of the compiler warnings - it really doesn't like the vUserVars.put() method.

If you are referring to the 'PanCustomUI.java' file of Slide Show 4, try changing lines 36-39 from:
HashMap vUserVars = (HashMap)vProps.get("userVariables");
if (SIVPanorama.isSelected())
{	if (vUserVars == null)
	{	vUserVars = new HashMap();

... to:
HashMap<String, String> vUserVars = vProps.get("userVariables", new HashMap<>());
if (SIVPanorama.isSelected())
{	if (vUserVars == null)
	{	vUserVars = new HashMap<>();

I'm not sure if it will work but might be worth a shot.
JeffTucker

Posts: 6,883
Registered: 31-Jan-2006
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 11-Jun-2015 01:46   in response to: monkeyboy in response to: monkeyboy
 
  Click to reply to this thread Reply
No joy, I'm afraid. The warning is:
warning: [unchecked] unchecked call to put(K,V) as a member of the raw type HashMap
vUserVars.put("maxImageWidth", panoWidth.getValue());
             ^
  where K,V are type-variables:
    K extends Object declared in class HashMap
    V extends Object declared in class HashMap
It's the "put" that it's choking on. I've got three of them, two that are putting integers into the map, and one that's putting a boolean into it.
ctwist

Posts: 562
Registered: 27-Sep-2003
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 11-Jun-2015 01:48   in response to: monkeyboy in response to: monkeyboy
 
  Click to reply to this thread Reply
I have fixed some of the compiler warnings, but I didn't want to overcomplicate this example. I will describe this in a separate thread.

I would like to provide details, but right now I am drinking some wine next to the swimming pool in Beckley WV, and the only nightspot within walking distance is Hooters.

Sometimes life forces us to make difficult choices.
JeffTucker

Posts: 6,883
Registered: 31-Jan-2006
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 11-Jun-2015 01:50   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
Your fundamental error was in choosing West By-God Virginia in the first place. Been there - I used to live in the VA suburbs of D.C., so I've done a fair amount of hiking and camping in the boonies to the west.

The hills of NW Connecticut are much more refined. We have The Brass Horse Cafe, a biker bar that features karaoke on Friday nights. No, I have not checked it out....
monkeyboy

Posts: 83
Registered: 21-Jun-2008
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 11-Jun-2015 13:22   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
jGromit wrote:
It's the "put" that it's choking on. I've got three of them,
It might be the 'put' method that is causing the warning but I think the root of the problem is with the definition of the HashMap.
... two that are putting integers into the map, and one that's putting a boolean into it.
If you define the HashMap using HashMap<String, Object>, the compiler should sail right past the 'put'. (It does in my own tests.)
The following (modified from the 'PanCustomUI.java' Slide Show 4 code attached to a post on the previous page of this thread) compiles without warnings:
new StateMonitor()
{	public void onChange()
	{ if (vAO != null)
		{	AlbumObjectProperties vProps = vAO.getProperties();
	
			// Following line modified from original source
			HashMap<String, Object> vUserVars = vProps.get("userVariables", new HashMap<>());
 
			if (SIVPanorama.isSelected())
			{	if (vUserVars == null)
 
				// Following line modified from original source
				{	vUserVars = new HashMap<>();
 
				}
				vUserVars.put("maxImageWidth", new String("50000"));
			}
			else
			{	if (vUserVars != null)
				{	vUserVars.remove("maxImageWidth");
				}
			}
 
			// Test 'put' entries
			vUserVars.put("bool", true);
			vUserVars.put("int", 21);
			vUserVars.put("str", "Hello");
 
			if (vUserVars == null || vUserVars.isEmpty())
			{ vProps.remove("userVariables");
			}
			else
			{ vProps.put("userVariables", vUserVars);
			}
			vProps.save();
		}
	}
}.add(SIVPanorama).done();
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums