Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) How can i creat an Applet? (Read 6470 times)
marciozenaide
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Jul 24th, 2008
How can i creat an Applet?
Jul 31st, 2008 at 3:18pm
Print Post  
Hi Stoyo,
I´m starting to learn FlowChart, and naturally I have a ton of questions to post on this forum.
I´m doing my application on the Java for Descktop, and I'm need an Applet version. So, forgive my ignorance if I´m being too basic on my questions.

I´m going to start with the following problem:

I have programmatically created a code.
To do it, I have done it like this:

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.*;
import com.mindfusion.jdiagram.*;
import com.mindfusion.jdiagram.Box;
import com.mindfusion.diagramming.Diagram;

public class Org extends JApplet {


private FlowChart fc;


public void init(){


fc = new FlowChart();


fc.setBackground(new Color(255,255,80));




fc.createBox(0, 0, 50, 50);

}


public void paint(Graphics g){




Box box;




fc.clearAll();




g.drawString("Welcome to Applet", 25, 40);


box = fc.createBox(10, 10, 23, 10);


box.setText("first box");

}
}

---------------------------------------------
<html><Title>Applet Organograma</Title>
<head></head><body><p>Um applet</p>

<applet code="Org.class"

archive="JDiagram.jar" width="640" height="480">

</applet>

</body>
</html>
---------------------------------------------

After open the page in Browser, there are no boxes created.

And The import com.mindfusion.diagramming.Diagram cannot be resolved;

Now, how do I created an applet like that? It's possible? Or I need use only JavaScript in my page like this next sample?

------------------------------------------------------------------------------
<applet id="fcapplet" code="com.mindfusion.jdiagram.FlowChartApplet.class"

archive="JDiagram.jar" width="640" height="480" mayscript>

</applet>


The applet shows a JScrollPane which embeds the FlowChart component. Use the getFlowChart method of FlowChartApplet to get a reference to the flowchart
instance, e.g.


function load()

{

var applet = document.getElementById("fcapplet");

fc = applet.getFlowChart();

fc.createBox(0, 0, 50, 50);

}
----------------------------------------------------------------------------

Thanks in advance.
Márcio Z. de O. Alves
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How can i creat an Applet?
Reply #1 - Aug 1st, 2008 at 6:08am
Print Post  
Hi Márcio,

You should add the FlowChart instance to the applet as a child control:

getContentPane().add(fc, BorderLayout.CENTER);

If you are just now starting to learn the control, better move to version 2:
https://www.mindfusion.eu/JDiagramTrial.zip

Additionally, JDiagram.jar already includes an applet (called DiagramApplet in V2), which you could extend, and override its listener methods.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
marciozenaide
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Jul 24th, 2008
Re: How can i creat an Applet?
Reply #2 - Aug 5th, 2008 at 3:36pm
Print Post  
Hi,
Thank you for your help!
Márcio
  
Back to top
 
IP Logged
 
danielapsilva
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Nov 28th, 2008
Re: How can i creat an Applet?
Reply #3 - Nov 28th, 2008 at 9:32pm
Print Post  
I've just started using the JDiagramv2 trial and I didn't find good examples/tutorials about creating javascript applets.

What params can I use in an applet?
<PARAM NAME="NodeCreated" VALUE="onNodeCreated">
<PARAM NAME="NodeCreating" VALUE="onNodeCreating">
These worked.


<PARAM NAME="setAllowInplaceEdit" VALUE="true">
<PARAM NAME="ShapeLibraryLocation" VALUE="C:\test.shl">
These didn't.

Can I develop everything by just using JavaScript?

Thank you,
Daniela
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How can i creat an Applet?
Reply #4 - Nov 30th, 2008 at 9:39am
Print Post  
Most of the PARAMs map events from the DiagramListener interface to names of JavaScript functions invoked when an event is raised. You can find a full list below. That's code from the applet class and the string arguments are what you should use as NAME values of the PARAM tags.

"ShapeLibrary" should specify an URL to the shape library file; "ShapeLibraryLocation" is its old name. It does not work with local file paths, but with http URLs, e.g. the value should be "http://www.abc.com/test.shl".

There is one additional PARAM you could use, called DiagramData. Its value should be a string returned by the saveToString(Xml) method, and if it's set, the applet will call loadFromString to load the diagram content from the string.

If you need to initialize some properties of the Diagram object, add a handler for the AppletStarted event and call the property setter methods from the JavaScript handler.

I hope that helps,
Stoyan


actionRecordedScript = getParameter("ActionRecorded");
actionRecordingScript = getParameter("ActionRecording");
actionRedoneScript = getParameter("ActionRedone");
actionUndoneScript = getParameter("ActionUndone");
appletStartedScript = getParameter("AppletStarted");
cellClickedScript = getParameter("CellClicked");
cellDoubleClickedScript = getParameter("CellDoubleClicked");
cellTextEditedScript = getParameter("CellTextEdited");
cellTextEditingScript = getParameter("CellTextEditing");
containerChildAddedScript = getParameter("ContainerChildAdded");
containerChildRemovedScript = getParameter("ContainerChildRemoved");
containerFoldedScript = getParameter("ContainerFolded");
containerUnfoldedScript = getParameter("ContainerUnfolded");
deserializeTagScript = getParameter("DeserializeTag");
docClickedScript = getParameter("Clicked");
doubleClickedScript = getParameter("DoubleClicked");
drawAnchorPointScript = getParameter("DrawAnchorPoint");
drawBackgroundScript = getParameter("DrawBackground");
drawCellScript = getParameter("DrawCell");
drawLinkScript = getParameter("DrawLink");
drawNodeScript = getParameter("DrawNode");
enterInplaceEditModeScript = getParameter("EnterInplaceEditMode");
expandButtonClickedScript = getParameter("ExpandButtonClicked");
groupDestroyedScript = getParameter("GroupDestroyed");
imageLoadedScript = getParameter("ImageLoadedScript");
initializeLinkScript = getParameter("InitializeLink");
initializeNodeScript = getParameter("InitializeNode");
itemAddedScript = getParameter("ItemAdded");
itemRemovedScript = getParameter("ItemRemoved");
keyDownScript = getParameter("KeyDownScript");
keyPressScript = getParameter("KeyPressScript");
keyUpScript = getParameter("KeyUpScript");
leaveInplaceEditModeScript = getParameter("LeaveInplaceEditMode");
linkActivatedScript = getParameter("LinkActivated");
linkClickedScript = getParameter("LinkClicked");
linkCreatedScript = getParameter("LinkCreated");
linkCreatingScript = getParameter("LinkCreating");
linkDeactivatedScript = getParameter("LinkDeactivated");
linkDeletedScript = getParameter("LinkDeleted");
linkDeletingScript = getParameter("LinkDeleting");
linkDeselectedScript = getParameter("LinkDeselected");
linkDoubleClickedScript = getParameter("LinkDoubleClicked");
linkModifiedScript = getParameter("LinkModified");
linkModifyingScript = getParameter("LinkModifying");
linkMouseEnterScript = getParameter("MouseEnterLink");
linkMouseLeaveScript = getParameter("MouseLeaveLink");
linkRoutedScript = getParameter("LinkRouted");
linkSelectedScript = getParameter("LinkSelected");
linkSelectingScript = getParameter("LinkSelecting");
linkStartModifyingScript = getParameter("LinkStartModifying");
linkTextEditedScript = getParameter("LinkTextEdited");
linkTextEditingScript = getParameter("LinkTextEditing");
nodeActivatedScript = getParameter("NodeActivated");
nodeClickedScript = getParameter("NodeClicked");
nodeCreatedScript = getParameter("NodeCreated");
nodeCreatingScript = getParameter("NodeCreating");
nodeDeactivatedScript = getParameter("NodeDeactivated");
nodeDeletedScript = getParameter("NodeDeleted");
nodeDeletingScript = getParameter("NodeDeleting");
nodeDeselectedScript = getParameter("NodeDeselected");
nodeDoubleClickedScript = getParameter("NodeDoubleClicked");
nodeModifiedScript = getParameter("NodeModified");
nodeModifyingScript = getParameter("NodeModifying");
nodeMouseEnterScript = getParameter("MouseEnterNode");
nodeMouseLeaveScript = getParameter("MouseLeaveNode");
nodeSelectedScript = getParameter("NodeSelected");
nodeSelectingScript = getParameter("NodeSelecting");
nodeStartModifyingScript = getParameter("NodeStartModifying");
nodeTextEditedScript = getParameter("NodeTextEdited");
nodeTextEditingScript = getParameter("NodeTextEditing");
selectionMovedScript = getParameter("SelectionMovedScript");
selectionMovingScript = getParameter("SelectionMoving");
serializeTagScript = getParameter("SerializeTag");
tableSectionCollapsedScript = getParameter("TableSectionCollapsedScript");
tableSectionExpandedScript = getParameter("TableSectionExpandedScript");
treeCollapsedScript = getParameter("TreeCollapsed");
treeExpandedScript = getParameter("TreeExpanded");
validateAnchorPointScript = getParameter("ValidateAnchorPoint");
viewRemovedScript = getParameter("ViewRemoved");
  
Back to top
 
IP Logged
 
danielapsilva
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Nov 28th, 2008
Re: How can i creat an Applet?
Reply #5 - Dec 1st, 2008 at 8:02pm
Print Post  
Thank you for your reply, but I can't make it work yet.

<script  type="text/javascript"  language="JavaScript">

function load()
{
     var applet = document.getElementById("fcapplet");
applet.getDiagramView().setAllowInplaceEdit(true);
}
</script>

<applet id="fcapplet" code="com.mindfusion.diagramming.DiagramApplet.class"
archive="JDiagram.jar" width="850" height="600" mayscript>
<param name="AppletStarted" value="load">
</applet>

<applet id="jShapeListBox" name="jShapeListBox" code="com/mindfusion/diagramming/ShapeListBoxApplet.class" archive="JDiagram.jar" style="height:100%"

mayscript>
<PARAM NAME="ShapeLibrary" VALUE="http://www.somenteaverdade.com/teste.shl">
</applet>

The default shape library is still being used instead of mine and I get an error for the "AppletStarted" param: "java.lang.NoSuchFieldException: appletLoadedCheck in class: com.mindfusion.diagramming.DiagramApplet"
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How can i creat an Applet?
Reply #6 - Dec 2nd, 2008 at 6:19am
Print Post  
Are you using Java 6 Update 10 (1.6.0_10-b33)? That release 'surprised' us with some changes in the Java to JavaScript interoperability layer that lead to the appletLoadedCheck error message. We haven't released an official fix yet, but this pre-release version should work fine:

http://www.mind-fusion.com/jdiagram/JDiagram.jar

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
danielapsilva
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Nov 28th, 2008
Re: How can i creat an Applet?
Reply #7 - Dec 2nd, 2008 at 4:21pm
Print Post  
Thanks! It worked!

My shape library still doesn't show up though.. any idea?

Thanks,
Daniela
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How can i creat an Applet?
Reply #8 - Dec 2nd, 2008 at 6:35pm
Print Post  
Is the .jar file in the same directory on your server? The Java security policy might not allow an applet to load files from a different location.

Stoyan
  
Back to top
 
IP Logged
 
danielapsilva
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Nov 28th, 2008
Re: How can i creat an Applet?
Reply #9 - Dec 2nd, 2008 at 6:52pm
Print Post  
Yes, everything is in the same directory...
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How can i creat an Applet?
Reply #10 - Dec 3rd, 2008 at 12:22pm
Print Post  
Hi,

For the ShapeListBox applet, the PARAM is indeed called "ShapeLibraryLocation". The respective DiagramApplet's PARAM is called "ShapeLibrary".

Stoyan
  
Back to top
 
IP Logged
 
danielapsilva
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Nov 28th, 2008
Re: How can i creat an Applet?
Reply #11 - Dec 3rd, 2008 at 12:45pm
Print Post  
Perfect!
Thank you!!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint