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


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

Posts: 546
Registered: 27-Sep-2003
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 25-May-2015 14:52   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
You have added the code in the correct place.
I will have to look at this again; at this point I don't know why it is failing.
ctwist

Posts: 546
Registered: 27-Sep-2003
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 25-May-2015 15:13   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
One more change I should have mentioned.

Before calling init(), add:
SIVPanorama.addFocusListener(fl);
AndreWolff

Posts: 1,775
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 25-May-2015 17:59   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
ctwist wrote:
One more change I should have mentioned.

Before calling init(), add:

SIVPanorama.addFocusListener(fl);
I did this, but it does not help, The checkbox is cleared if I navigate to another image,
ctwist

Posts: 546
Registered: 27-Sep-2003
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 26-May-2015 00:41   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
I don't use loadUI() and saveUI() in setAlbumObject(), since these duplicate part of super.setAlbumObject().

To make it the same as mine, make these changes to setAlbumObject()
  • After loadUI(), add
    updateUI();
    
  • Remove loadUI() and saveUI().
I don't know whether or not this will help.
AndreWolff

Posts: 1,775
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 26-May-2015 08:45   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
Attachment onload.bsh (43,7 KB)
ctwist wrote:.
I don't know whether or not this will help.
This does not help. If I set the checkbox, I get a silent crash and the System consol;e window shows:
Exception in thread "AWT-EventQueue-0" java.security.PrivilegedActionException: java.security.PrivilegedActionException: bsh.EvalError: 
Attempt to resolve method: isSelected() on undefined variable or class name: SIVPanorama : at Line: 159 : in file: inline evaluation of: ``/*   * This script produces the user interface for the Slide Show 4 skin.   * Or . . . '' : SIVPanorama .isSelected ( ) 
The contents of line 159 is:
					if (SIVPanorama.isSelected())

see also the enclosed onload.bsh file.
ctwist

Posts: 546
Registered: 27-Sep-2003
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 26-May-2015 14:22   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
Change line 156 to
if (vAO != null && !vAO.getFile().isDirectory())
AndreWolff

Posts: 1,775
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 26-May-2015 16:05   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
ctwist wrote:
Change line 156 to
if (vAO != null && !vAO.getFile().isDirectory())
I did this, but I have the same problem as reported above and the album did not contain a folder album.

I think it is faster and more efficient if you download the Slide Show 4 skin and replace the onload.bsh file by the onload.bsh file enclosed above and test it yourself!

Edited by: AndreWolff on 26-May-2015 16:05
ctwist

Posts: 546
Registered: 27-Sep-2003
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 27-May-2015 05:34   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
Attachment SS4_java.zip (11,7 KB)
I couldn't see the problem, so I imported onload.bsh into Eclipse, as Java classes.

I have fixed some errors, but I can't fix the remaining problems (or to be more precise, I don't want to spend any more time on this).

I have attached my in-progress changes. I strongly recommend that you should import this into an IDE (i.e. Eclipse or Netbeans). It is much easier to fix problems in an IDE.

I can't offer any more assistance until this is compiled. JGromit recently posted a guide that describes how to migrate to an IDE.

Edited by: ctwist on 27-May-2015 07:51

I fixed 2 errors in the attachment that I had misinterpreted.
AndreWolff

Posts: 1,775
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 27-May-2015 11:20   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
Attachment onload.bsh (43,3 KB)
ctwist wrote:
I have fixed some errors, but I can't fix the remaining problems (or to be more precise, I don't want to spend any more time on this).
Thanks for your patience and your help!

I did structure the code more like the first Link panel and I have it working now, no longer a silent crash and some slides are enlarged if the check-box is set, but some slides are not enlarged if the check-box is set and I use the "Make" button. However if I use the "Make all" function, all slides with the check-box set are enlarged.

This is the code:
public class PanCustomUI extends JCustomPanel {
	JCheckBox SIVPanorama = new JCheckBox("Enlarge the image of this panorama picture");	
 
 public void setAlbumObject(AlbumObject ao) {
    super.setAlbumObject(ao);
    removeAll();
    
    vAO = ao;
    new StateMonitor()
		{	public void onChange()
			{ if (vAO != null)
				{	AlbumObjectProperties vProps = vAO.getProperties();
					HashMap vUserVars = (HashMap)vProps.get("userVariables");
					if (SIVPanorama.isSelected())
					{	if (vUserVars == null)
						{	vUserVars = new HashMap();
						}
						vUserVars.put("maxImageWidth", new String("50000"));
					}
					else
					{	if (vUserVars != null)
						{	vUserVars.remove("maxImageWidth");
						}
					}
					if (vUserVars == null || vUserVars.isEmpty())
					{ vProps.remove("userVariables");
					}
					else
					{ vProps.put("userVariables", vUserVars);
					}
					vProps.save();
				}
			}
		}.add(SIVPanorama).done();
 
    if (ao != null) {
      File currentContextFile = ao.getFile();
      if (currentContextFile.isDirectory()) {
		add("br", new JLabel(texts.getString("ui.noPanoramaPossible")));
      }
      else {
		add(SIVPanorama);	
      }
    }
    loadUI();
  }
 
	public PanCustomUI(JAlbumContext context) {
		super(context);	
		// Subclasses like us should call init after components are initiated
		init();
	}	
}
// Install custom panel in Jalbum's edit panel
PanCustomUI customUI2 = new PanCustomUI(context);
editPanel.addCustomTab("Panorama", customUI2);
The rest of the code is in the enclosed onload.bsh file

Edited by: AndreWolff on 27-May-2015 11:28
ctwist

Posts: 546
Registered: 27-Sep-2003
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 27-May-2015 13:55   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
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)
The operator != is undefined for the argument type(s) int, null
DirectoryChooser dc = ChooserFactory.createDirectoryChooser(window);
dc.showDialog(window, "Ok");
The method showDialog(JAlbumFrame, String) is undefined for the type DirectoryChooser
ctwist

Posts: 546
Registered: 27-Sep-2003
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 27-May-2015 14:25   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
Another error that Eclipse reported:
getFileToRes(new FileFilter(ext, "allowed files"), name);
Cannot instantiate the type FileFilter

Examples of correct usage are at:
http://docs.oracle.com/javase/8/docs/api/javax/swing/filechooser/FileFilter.html
https://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html

Eclipse really does speed up development!!
AndreWolff

Posts: 1,775
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 27-May-2015 18:02   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
ctwist wrote:
Eclipse really does speed up development!!
I do believe that, if you don't count the time to learn the Eclipse system!

Thanks for reporting this! However I checked the working of all your reported errors and all these constructrions deliver the correct result without a (silent) crash!

All these constructions are not invented by me but copied from examples in this forum ( see for example: http://jalbum.net/forum/thread.jspa?messageID=296706) or from skins like the Base skin, so more people should have problems!

The panorama panel code is still not reliable working: with a new album it did not work at all, maybe there is still an initializing problem.

Edited by: AndreWolff on 29-May-2015 09:20
ctwist

Posts: 546
Registered: 27-Sep-2003
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 03-Jun-2015 02:58   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff wrote:
The panorama panel code is still not reliable working: with a new album it did not work at all, maybe there is still an initializing problem.
The stateMonitor() should not be inside setAlbumObject(), but if I move it before setAlbumObject(), the panel is not created. I don't know why.
I have taken this as far as I can.
davidekholm

Posts: 3,312
Registered: 18-Oct-2002
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 03-Jun-2015 11:05   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)
The operator != is undefined for the argument type(s) int, null
</div>
 
As returnVal is an integer you cannot compare it with null. You probably want returnVal != 0
 
<div class="jive-quote">DirectoryChooser dc = ChooserFactory.createDirectoryChooser(window);
dc.showDialog(window, "Ok");
The method showDialog(JAlbumFrame, String) is undefined for the type DirectoryChooser

See our Javadocs for the correct method to call, i.e. showOpenDialog
davidekholm

Posts: 3,312
Registered: 18-Oct-2002
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 03-Jun-2015 11:11   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
ctwist wrote:
AndreWolff wrote:
The panorama panel code is still not reliable working: with a new album it did not work at all, maybe there is still an initializing problem.
The stateMonitor() should not be inside setAlbumObject(), but if I move it before setAlbumObject(), the panel is not created. I don't know why.
I have taken this as far as I can.

True. As the StateMonitor attaches to a component that's bound to the class itself, it should only be called initially. However, when you call .done() it calls onChange() which refers to your vAO variable, which hasn't been set up yet. To solve this, remove the .done() call and add a myStateMonitor.done(); or myStateMonitor.onChange() call inside setAlbumObject(). You naturally need to assign the StateMonitor to a reference variable that's bound to that class. Furthermore, you don't need that vAO variable as the base class keeps a reference to the current AlbumObject. It's called "currentAO" and is documented in the Javadocs for JCustomPanel
Legend
Forum admins
Helpful Answer
Correct Answer

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