Help needed to add an image to a datagrid cell in actionscript
Morning all,
I am still quite new to flex development and I have an application which uses xml to populate a datagrid. One of the row columns should display a small image but I don't know how to do that.
Can anyone show me how to add an image to a datagrid cell in actionscript?
I've added a sample of the code I have written already below. Any help would be much appreciated.
Thanks in advance,
Xander
My XM
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
<modules>
<module id="1">
<icon>assets/sample_image1.png</icon>
<key>core</key>
<name>Core</name>
<description>Description of module</description>
<installed>Wednesday, 24th June 2009 @ 15:59 UK</installed>
</module>
<module id="2">
<icon>assets/sample_image2.png</icon>
<key>webproject</key>
<name>Web Project</name>
<description>Description of module</description>
<installed>Wednesday, 24th June 2009 @ 17:32 UK</installed>
</module>
</modules>
</dataset>
My Actionscript
private function dataSetHandler(event:Event):void {
var ds:XML = new XML(event.target.data);
var rows:XMLList = ds.elements('modules').elements('module') as XMLList;
var columns:Array = new Array();
for (var i:int=0; i<rows[0].elements().length(); i++) {
var column:DataGridColumn = new DataGridColumn();
var tag:String = rows.*[i].name();
column.headerText = rows.*[i].name();
column.dataField = rows.*[i].name();
if (tag == 'icon') {
var img:Image = new Image();
img.id = "iconpath";
img.width = 23;
img.height = 20;
img.source = rows.*[i].name();
column.itemRenderer = img; <-- this line shows as an error when I try to compile
columns[i] = column;
mydatagrid.columns = columns;
mydatagrid.dataProvider = rows;
you cant just set image object to itemrenderer, you need to use classfactory.
http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_4.html
Similar Messages
-
[HELP] need TX2 recovery DVD/Image
[HELP] need TX2 recovery DVD/Image HP won't repair it b/c i dont have the original software....can someone provide me an image or i will pay $ for DVD plz full model is TX2-1024CA
That is a notebook PC. Maybe this document will help? http://h10025.www1.hp.com/ewfrf/wc/document?docname=c00810334&cc=us&dlc=en&lc=en&jumpid=reg_R1002_US...
... an HP employee expressing his own opinion.
Please post rather than send me a Message. It's good for the community and I might not be able to get back quickly. - Thank you. -
I need to add a watermark in a datagrid
How can I add a watermark in a datagrid?
With Flextras Components, we put the watermark under the component and make the component slightly transparent. Most Flex components are already slightly transparent, so it's no big deal.
Although I have not experimented with this, I believe you can put it on top and specify mouseEnabled and tabEnabled to make it a virtually invisible watermark. -
Help needed in designing dynamic images
Hi,
I just posted a thread before, but there is something wrong in that post.
Any ways, I am new to Java and am trying to design a GUI which has images, which change dynamically. One of the examples is on this webpage
http://images.google.com/imgres?imgurl=http://www.snapstream.com/images/blog/godzilla/overheating_max_cpu_tn.jpg&imgrefurl=http://blogs.snapstream.com/2006/01/18/godzilla-pvr/&h=516&w=683&sz=80&hl=en&start=3&tbnid=huDY6gDdtS_o-M:&tbnh=105&tbnw=139&prev=/images%3Fq%3DCPU%2Btemperature%26gbv%3D2%26svnum%3D10%26hl%3Den%26sa%3DG
I need help desperately. I would appreciate, if you can help me. What do i need to use? Can it be done by using Swing? Are there any good examples of it on web? I am basically not clear, what do I need to use...
waiting for your reply. thanks in advance.
Ankitconsider you have a JFrame called "frame"
what you can do:
JLabel lab = new JLabel("../firstPic.jpg");
frame.getContentPane().add(lab);
then, each time you will call "setIcon()" on the lab and refresh the frame it will display a new picture -
Help needed; underscore in rollover image name will not validate at WC3
GoLive CS on an Intel PC
UTF8 encoded, HTML 4.01 Transitional
I have several rollovers in a page created by using the GoLive palletes, and because GoLive automatically adds an underscore to an image name in a nested folder the page cannot validate at the WC3 site. What do I need to do so that the underscore will not be added automatically? I've tried adding a name/ID to the image before creating the rollover, but it disregards the name and uses what it thinks is best, adding the underscore.
The page is located here:
http://www.redshift.com/~lorac/sdy-55.html
I have attached three images that show the file names used and the results in the GoLive pallete. The first is a screenshot of the folder structure, the second is the placed image pallete and the third is the rollover pallete view.GoLive is set to strip all the GoLive code from the page before uploading, so the web version will not have any GL code.
A sample WC3 comment is:
Line 86, Column 226: value of attribute "ID" invalid: "_" cannot start a name
…pg');return true" href="#"><img id="_5502" class="img_border" src="images/jhj
✉
It is possible that you violated the naming convention for this attribute. For example, id and name attributes must begin with a letter, not a digit.
Do I need to unnest any folders with potential rollover images? That would be a real pain... considering the amount sections and images used in the site.
Thank you in advance for any help you can give.
CarolI did as you suggested and added to the beginning of the default underscored name in the "name/ID" section and it was accepted. I changed all the rollover image names and uploaded the modified page, and was then able to validate at the WC3 validation site.
Thank you so much! It was an easy fix... a solution I had overlooked. Oddly enough this never occurs with a remote rollover, but that is probably because GL lets you name the base image without suggesting a name first.
Carol -
Help needed for downloading the image from Inage URL
Hello everyone,
I need some help regarding setting a timeout for dowloading image from image URL
Actually I have a hash table with set of image URL's...
for example:
http://z.about.com/d/politicalhumor/1/0/-/6/clinton_portrait.jpg
which gives a image.
for(Enumeration e = google_image_links.elements() ; e.hasMoreElements() ;) {
//System.out.println("final");
//System.out.println(e.nextElement());
try{
System.out.println("Images download started....");
//System.out.println(e.nextElement());
//imageio is the BufferedImagereader object
imageio = ImageIO.read(new URL((String) e.nextElement()));
image_title = created_imagepath +"\\"+ array_words[i] + counter_image_download + "." + "jpg";
img = ImageIO.write(imageio,"jpg", new File(image_title));
imageio.flush();
}catch(Exception e1){
System.out.print(e1);
if(img){
System.out.println("The image " + image_title + " has been saved to local disk succesfully.");
counter_image_download++;
}//end of for loopi am using the above code to download all the image from the Image URL's that r present in hashtable.
The problem i have been encountered with is...
Some URL's does not return any bytes, The code is not totally broken. In such cases, my code is hanging off at that particular URL and waiting to get some output data from the URL. The execution does not proceed furthur But if the URL is a totally broken link, the code is throwing an exception and I am able to handle it successfully.
But in the case of partially broken links, I am not able to go furthur because the code keeps waiting to get some data.
So for this reason I want to setup a timer and tell the code to wait for 5-10 min, in that time if it does not get any data, proceed furthur to download other links...
Please tell me how can I do this.. or plzzz tell me an alternative...
Please help me ans its a bit urgent plzzzz.
Thank you,
chaitanyaHello everyone,
I need some help regarding setting a timeout for dowloading image from image URL
Actually I have a hash table with set of image URL's...
for example:
http://z.about.com/d/politicalhumor/1/0/-/6/clinton_portrait.jpg
which gives a image.
for(Enumeration e = google_image_links.elements() ; e.hasMoreElements() ;) {
//System.out.println("final");
//System.out.println(e.nextElement());
try{
System.out.println("Images download started....");
//System.out.println(e.nextElement());
//imageio is the BufferedImagereader object
imageio = ImageIO.read(new URL((String) e.nextElement()));
image_title = created_imagepath +"\\"+ array_words[i] + counter_image_download + "." + "jpg";
img = ImageIO.write(imageio,"jpg", new File(image_title));
imageio.flush();
}catch(Exception e1){
System.out.print(e1);
if(img){
System.out.println("The image " + image_title + " has been saved to local disk succesfully.");
counter_image_download++;
}//end of for loopi am using the above code to download all the image from the Image URL's that r present in hashtable.
The problem i have been encountered with is...
Some URL's does not return any bytes, The code is not totally broken. In such cases, my code is hanging off at that particular URL and waiting to get some output data from the URL. The execution does not proceed furthur But if the URL is a totally broken link, the code is throwing an exception and I am able to handle it successfully.
But in the case of partially broken links, I am not able to go furthur because the code keeps waiting to get some data.
So for this reason I want to setup a timer and tell the code to wait for 5-10 min, in that time if it does not get any data, proceed furthur to download other links...
Please tell me how can I do this.. or plzzz tell me an alternative...
Please help me ans its a bit urgent plzzzz.
Thank you,
chaitanya -
Help Needed! To upload image to db2 using struts & hibernation[code inside]
Hi all, currently i have successfully created the application for inserting text data into my db2 through the use of struts with hibernation. But i need to insert image now which seems to be different from just inserting text data.
From my understanding, the image will be converted to bytes and store as Blob in my db2, but i need hlp in knowing how to do this, i did a search and i found the following codes posted by another guy in this forum but he did not reply his thread at all...i am feeling very puzzel about the last file which is /RegPersonalDetails.java. Did he missed out a bean file?? which is the TempPhoto bean? i really do not understand the last file, The first file is the JSP , the second is the bean and the third is the Action class. i did exactly the same as his but i do not know how to use the RegPersonalDetails.java. please help thanks.. i am using websphere studio 5 and hibernate 2.
Below is the example i got from the guy:
//Registration.jsp
--Below is the script for image type validation.
<script>
var fileTypes=["bmp","gif","png","jpg","jpeg","tif","tiff","jif","jfif","jp2","jpx" ,"j2k","j2c","fpx","pcd" ];
function preview(what){
var source=what.value;
var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
for (var i=0; i<fileTypes.length; i++) if (fileTypes==ext) break;
var globalPic=new Image();
if (!(i><fileTypes.length)){
alert("THAT IS NOT A VALID IMAGE\nPlease load an image with an extention of one of the following:\n\n"+fileTypes.join(", "));
what.fileUpload.focus();
return false;
else
return true;
</script>--You have to write relevent code for view.For browse filed i given below
<INPUT type=file name="fileUpload" onchange="preview(this)">
===============================================================
//RegistrationForm.java
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class Regstep5Form extends ActionForm {
private FormFile fileUpload;
public FormFile getFileUpload() {
return fileUpload;
public void setFileUpload(FormFile fileUpload) {
this.fileUpload = fileUpload;
===================================================================
//RegistrationAction.java
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
public class Regstep5Action extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception, ServletException {
Regstep5Form rf= (Regstep5Form)form;
FormFile myFile = rf.getFileUpload();
String contentType = myFile.getContentType();
String fileName = myFile.getFileName();
int fileSize = myFile.getFileSize();
byte[] fileData = myFile.getFileData();
String result=RegPersonalDetails.process(rf);
System.out.println("result taken");
return mapping.findForward("success");
===================================================================
//RegPersonalDetails.java
import com.model.orm.TempPhoto;
import com.util.HibernateUtil;
import org.hibernate.*;
import java.io.*;
import org.apache.struts.upload.*;
public class RegPersonalDetails {
public static String process(Regstep5Form rf) throws Exception {
TempPhoto temp=new TempPhoto();
Session session=null;
Transaction tx=null;
try{
session = HibernateUtil.getSession();
tx = session.beginTransaction();
String uname=rf.getUserId();
FormFile myFile=rf.getFileUpload();
byte[] filedata=myFile.getFileData();
temp.setUserId(uname);
temp.setPhoto(filedata);
session.saveOrUpdate(temp);
tx.commit();
}catch(Exception ex){ }
finally{
HibernateUtil.closeSession();
return "success";
--Here TempPhoto is the pojo class i.e hibernate generated class for the table in which we have to insert image...
--You will understand this if u have idea of hibernate..
--There may some import as statements missing...try it and configure your "struts-config.xml" file with the above files.
Message was edited by:
HaRouhaha....that thread starter is my friend siting next to me....he is having problem with struts and jsp only, which you already solve the problem for him.. but i need to know how to do the same thing with hibernate...pls hlp?
-
Adobe PE8 Help needed...blocky images when in play mode.
I have a Problem with blobby images and frame rates ( not sure if frame rates is the correct word!)
I'm attempting to captured my DVD from disc onto the program, which i have done, It loads ok, however it seems to be all blobby, blocky squares on the screen, as soon as it run plays. The audio runs fine.
My system in case anyone wants to know is Dell Dimension DXP051 Intel(R) Pentuim(R) 4CPU 3.00 Ghz 2.99 Ghz 3.50 gb RAM, although there is 4gb in there, i have added the rest in the past 6 months !, why it only show 3.5 i don't know! 1 x 160 gb HDD, 1 x 500 HDD, both internal and a 1.5 TB external HDD, plenty of HDD space! although i'm not sure if the RAM is enough? i have quite a few software programs, however I never have more than 1-4 running at the same time, only have PE8 running on its own at the moment.
Anyway going back to my issue, it seems to do this even if i put 3,4 images in the timeline, ( on a seperate project) is this an issue with my PC, graphics card to do with PE8, I have installed the updates by the way. Any help would be appreciated.
I do not seem to have this issue with other picture programes.
Thanks
AndrewAndrew,
Glad that things went well. One needs to read the instructions for each driver, and never trust that the procedure is exactly as it was only a month ago for the same card. Normally, it is and is only a simple download and execute, but I have seen times, where one had to first disable certain features in the card driver's console first. Always check carefully.
The two main drivers to be aware of are the video and the audio, as they often get broken by OS updates. Next most likely is not really a driver, but the firmware in one's DVD burner. Those get replaced about every 6 mos. +/-. Many of the other drivers are provided by the OS, but there can be many exceptions.
There are some utilities, that claim to get all necessary drivers on a system updated automatically. I have never seen one that worked very well. This is especially true with the video and audio drivers. What those utilities say is up to date is usually 9 mos. out of date and maybe 6-10 updates out. I would not trust such utilities, and would just do it by hand and get the drivers from the mfgr's. site, at the first sign of trouble.
Good luck,
Hunt -
Help Needed to add Hyphen in REGEXP_REPLACE
Hi All,
I need a help to add hyphen in my select criteria so that it does not filter the hypen.
I am using below REGEXP_REPLACE to get my output, everything is fine now except the Hyphen (-) character is not recognized.
select REGEXP_REPLACE('abcd-efgh123{}$(),', '[^[a-z,A-Z,0-9,(,),{,},_,$,.,'',[:space:]]]*','') from dual;
Can you please help?
ThanksThe hyphen has a special meaning inside a regular expression. You can use if you make clear that the extended meaning is not possible in this case.
example
with testdata as (select 'A-C' txt from dual union all
select 'X-12' txt from dual union all
select '1''2' txt from dual union all
select 'ab#' txt from dual union all
select '()' txt from dual union all
select 'a b*~' txt from dual union all
select 'ab' txt from dual union all
select 'abcd-efgh123{}$(),' txt from dual
select txt
,REGEXP_REPLACE(txt, '[^[a-zA-Z0-9(){}_$.''[:space:]-]]*','') keep_chars
,REGEXP_REPLACE(txt, '[[a-zA-Z0-9(){}_$.''[:space:]-]]*','') remove_chars
from testdata;
TXT KEEP_CHARS REMOVE_CHARS
A-C A-C
X-12 X-12
1'2 1'2
ab# ab #
a b*~ a b *~
ab ab
abcd-efgh123{}$(), abcd-efgh123{}$() ,I removed the comas. In case you want that char also to be removed just add it somewhere. It is not used as a separator in this specific case. -
Help, need to add a delete button to my application?
i have a little application that you can add numbers and friends email too
i would like to add a minus selection/entry button?
do any of you guys have any ideas?
stop();
//create a new sql connection
var conn:SQLConnection= new SQLConnection();
//add an event handeler for the open event
conn.addEventListener(SQLEvent.OPEN, openHandler);
//create the database if it doesn't exist, otherwise just opens it
var dbFile:File =File.applicationDirectory.resolvePath ("exemplu.db");
conn.openAsync(dbFile);
function openHandler(event:SQLEvent):void {
//create a new sql statement
var sql:SQLStatement=new SQLStatement();
//set the statement to connect to our database
sql.sqlConnection=conn;
//parse the sql command that creates the table if it doesn't exist
sql.text= "CREATE TABLE IF NOT EXISTS contacte(" +
"id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"nume TEXT, " +
"telefon INTEGER)";
//add a new event listener to the sql when it completes creating the table
sql.addEventListener(SQLEvent.RESULT,retrieveData);
//call the execute function to execute our statement
sql.execute();
function retrieveData(event:SQLEvent = null):void {
//create a new sql statemant
var sql:SQLStatement = new SQLStatement();
sql.sqlConnection=conn;
//this sql command retrieves all the fields from our
//table in the database and orders it by name
sql.text = "SELECT id, nume, " +
"telefon " +
"FROM contacte ORDER BY nume";
//add a new event listener if there is data
//to display it
sql.addEventListener(SQLEvent.RESULT, selectHandler);
sql.execute();
function selectHandler(event:SQLEvent):void {
//first we clear our list
lister.removeAll();
//the we create a result variable that holds
//all our contacts
var result:SQLResult=event.target.getResult();
//we check if results is not empty
if (result!=null&&result.data!=null) {
//and we add a new item to our list for
//each contact in our database
for (var i:Number = 0; i < result.data.length; i++) {
lister.addItem ({ label:result.data[i].nume + "-" +result.data[i].telefon
, nr:result.data[i].id });
plus.addEventListener(MouseEvent.CLICK,adder);
xu.addEventListener(MouseEvent.CLICK,closeapp);
back.addEventListener(MouseEvent.MOUSE_DOWN,drag);
//because my buttons are not real buttons
//but movieclips i need to set the
//buttonMode property to true
plus.buttonMode=true;
xu.buttonMode=true;
function adder(e:MouseEvent):void{
//remove the eventlistener and move to the
//next frame
plus.removeEventListener(MouseEvent.CLICK,adder);
nextFrame();
function closeapp(e:MouseEvent):void {
//close the application
NativeApplication.nativeApplication.exit();
function drag(e:MouseEvent):void {
//drag the application
this.stage.nativeWindow.startMove();
this is on the second key frame-
//this line restricts the user input
//to just numbers in the phone input box
//add a new event listener to our plus button
plus.addEventListener(MouseEvent.CLICK,adder2);
function adder2(e:MouseEvent):void {
//create a new sql statement variable
var sql:SQLStatement=new SQLStatement();
sql.sqlConnection=conn;
//the next sql command creates a new entry
//in the table contacte from our database
sql.text = "INSERT INTO contacte(nume, " +
"telefon)" +
"VALUES(@nume, " +
"@telefon)";
//to insert variables into sql commnads
//we use the parameters definition
sql.parameters["@nume"]=nume.text;
sql.parameters["@telefon"]=tel.text;
//add a new event listener that calls the
//function that retrieves the data
sql.addEventListener(SQLEvent.RESULT,retrieveData);
sql.execute();
//go to frame no. 1
prevFrame();
//remove the eventlistener from our plus button
plus.removeEventListener(MouseEvent.CLICK,adder2);use:
minus_btn.addEventListener(Event.MouseEvent,CLICK, clear)
function clear(e:MouseEvent){
var sql:SQLStatement = new SQLStatement();
sql.sqlConnection = conn;
var s:String = "DELETE from contacte WHERE nume= :numeparam AND telefon=:telefonparam";
sql.text = s;
sql.parameters[":numeparam"] = whatever;
sql.parameters[":telefonparam"] = whatever else;
//add listeners if you want
sql.execute(); -
Help need in keylistener with image
Hi experts,
How to add the keylistener to a scrollpane for an image update or add image to the scrollpane. The solution will not using swing. Please send an example with a source code.
Thanks in advance.import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.List;
import java.net.*;
public class KeyTest4 extends Applet
public void init()
ImageEditorPanel editorPanel = new ImageEditorPanel();
ScrollPane scrollPane = new ScrollPane();
scrollPane.add(editorPanel);
setLayout(new BorderLayout());
add(new GridPanel(editorPanel), "North");
add(scrollPane);
public static void main(String[] args)
Applet applet = new KeyTest4();
Frame f = new Frame();
f.addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
System.exit(0);
f.add(applet);
f.setSize(400,400);
f.setLocation(200,200);
applet.init();
applet.start();
f.setVisible(true);
class ImageEditorPanel extends Panel
ImageLoader imageLoader;
List imageList;
int rows, cols;
Choice rowChoice;
boolean showGrid;
Color gridColor;
int gridSize;
int dx, dy;
Point cursor;
public ImageEditorPanel()
imageLoader = new ImageLoader(this);
imageList = new ArrayList();
rows = 1;
cols = 3;
showGrid = true;
gridColor = new Color(200,240,240);
gridSize = 100;
addKeyListener(new KeyNavigator(this));
dx = dy = 10;
cursor = new Point(10,10);
public void paint(Graphics g)
super.paint(g);
int w = getWidth();
int h = getHeight();
if(showGrid)
g.setColor(gridColor);
int xInc = (w - cols * gridSize)/cols + gridSize;
int yInc = (h - rows * gridSize)/rows + gridSize;
int x1 = xInc, y1 = 0, x2, y2 = h;
for(int j = 0; j < cols - 1; j++)
g.drawLine(x1, y1, x1, y2);
x1 += xInc;
x1 = 0; y1 = yInc; x2 = w;
for(int j = 0; j < rows - 1; j++)
g.drawLine(x1, y1, x2, y1);
y1 += yInc;
// render images
ImageLocator locator;
Image image;
Point p;
int x, y;
int xInc = w / cols;
int yInc = h / rows;
for(int j = 0; j < imageList.size(); j++)
locator = (ImageLocator)imageList.get(j);
image = locator.getImage();
p = locator.getCell();
x = p.y * xInc - xInc/2 - image.getWidth(this)/2;
y = p.x * yInc - yInc/2 - image.getHeight(this)/2;
g.drawImage(image, x, y, this);
// render cursor
g.setColor(new Color(240,200,200));
int cx = cursor.x;
int cy = cursor.y;
g.fillOval(cx - 10, cy - 10, 20, 20);
g.setColor(new Color(140,200,100));
g.drawLine(cx, cy - 12, cx, cy - 16);
g.drawLine(cx - 12, cy, cx - 16, cy);
g.drawLine(cx, cy + 12, cx, cy + 16);
g.drawLine(cx + 12, cy, cx + 16, cy);
public Dimension getPreferredSize()
Dimension d = new Dimension(400,400);
ScrollPane sp = getScrollPane(this);
Insets insets = sp.getInsets();
int hInsets = insets.left + insets.right;
int vInsets = insets.top + insets.bottom;
if(sp != null)
d = sp.getViewportSize();
if(d.width - hInsets < cols * gridSize)
d.width = cols * gridSize;
if(d.height - vInsets < rows * gridSize)
d.height = rows * gridSize;
return d;
public void addImage()
Point p = getCell();
Graphics g = getGraphics().create();
g.setColor(Color.red);
Image image = imageLoader.getImage();
imageList.add(new ImageLocator(image, p));
resetGrid();
public void removeImage()
Point cell = getCell();
ImageLocator locator;
for(int j = 0; j < imageList.size(); j++)
locator = (ImageLocator)imageList.get(j);
Point p = locator.getCell();
if(cell.equals(p))
imageList.remove(j);
break;
resetGrid();
private Point getCell()
Point p = new Point();
int w = getWidth();
int h = getHeight();
int xInc = w / cols;
int yInc = h / rows;
p.x = 1 + cursor.y / yInc; // row
p.y = 1 + cursor.x / xInc; // col
return p;
private void resetGrid()
int oldGridSize = gridSize;
int maxWidth = 0;
int maxHeight = 0;
ImageLocator locator;
Image image;
int w, h;
for(int j = 0; j < imageList.size(); j++)
locator = (ImageLocator)imageList.get(j);
image = locator.getImage();
w = image.getWidth(this);
h = image.getHeight(this);
if(w > maxWidth)
maxWidth = w;
if(h > maxHeight)
maxHeight = h;
if(maxWidth != gridSize || maxHeight != gridSize)
gridSize = Math.max(maxWidth, maxHeight);
if(maxWidth == 0 && maxHeight == 0)
gridSize = 100;
if(gridSize != oldGridSize)
validateScrollPane();
else
repaint();
private ScrollPane getScrollPane(Component c)
while((c = c.getParent()) != null)
if(c instanceof ScrollPane)
return (ScrollPane)c;
return null;
public void addRow()
rows++;
rowChoice.add(String.valueOf(rows));
rowChoice.select(rowChoice.getSelectedIndex() + 1);
validateScrollPane();
public void setShowGrid(boolean isVisible)
showGrid = isVisible;
repaint();
public void setCursor(int x, int y)
cursor.translate(x * dx, y * dy);
if(!isInBounds())
scrollToView();
repaint(cursor.x - 28, cursor.y - 28, 56, 56);
public void centerCursor()
ScrollPane sp = getScrollPane(this);
if(sp == null)
return;
Point p = sp.getScrollPosition();
Dimension d = sp.getViewportSize();
cursor.x = p.x + d.width/2;
cursor.y = p.y + d.height/2;
repaint();
private boolean isInBounds()
ScrollPane sp = getScrollPane(this);
if(sp == null)
return true;
Point p = sp.getScrollPosition();
Dimension viewSize = sp.getViewportSize();
if(cursor.x + 16 > p.x - viewSize.width ||
cursor.x - 16 < p.x || cursor.y - 16 < p.y ||
cursor.y + 16 > p.y - viewSize.height)
return false;
return true;
private void scrollToView()
ScrollPane sp = getScrollPane(this);
Point p = sp.getScrollPosition();
Dimension viewSize = sp.getViewportSize();
int x = p.x, y = p.y;
if(cursor.x + 16 > p.x + viewSize.width)
x = cursor.x + 16 - viewSize.width;
if(cursor.x - 16 < p.x)
x = cursor.x - 16;
if(cursor.y + 16 > p.y + viewSize.height)
y = cursor.y + 16 - viewSize.height;
if(cursor.y - 16 < p.y)
y = cursor.y - 16;
sp.setScrollPosition(x,y);
public void setRows(int rows)
this.rows = rows;
validateScrollPane();
public void setCols(int columns)
cols = columns;
validateScrollPane();
private void validateScrollPane()
ScrollPane sp = getScrollPane(this);
if(sp == null)
return;
invalidate();
repaint();
sp.validate();
public void setReference(Choice choice)
rowChoice = choice;
class GridPanel extends Panel
ImageEditorPanel imagePanel;
public GridPanel(ImageEditorPanel iep)
imagePanel = iep;
final Checkbox marker = new Checkbox("mark", true);
marker.addItemListener(new ItemListener()
public void itemStateChanged(ItemEvent e)
imagePanel.setShowGrid(marker.getState());
final Choice
rowChoice = new Choice(),
colChoice = new Choice();
rowChoice.add("1");
for(int j = 0; j < 4; j++)
colChoice.add(String.valueOf(j + 1));
colChoice.select(2);
ItemListener l = new ItemListener()
public void itemStateChanged(ItemEvent e)
if(e.getStateChange() == ItemEvent.SELECTED)
Choice choice = (Choice)e.getSource();
int value = choice.getSelectedIndex() + 1;
if(choice == rowChoice)
imagePanel.setRows(value);
if(choice == colChoice)
imagePanel.setCols(value);
rowChoice.addItemListener(l);
colChoice.addItemListener(l);
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(2,2,2,2);
gbc.weightx = 1.0;
add(marker, gbc);
gbc.anchor = gbc.EAST;
add(new Label("rows"), gbc);
gbc.anchor = gbc.WEST;
add(rowChoice, gbc);
gbc.anchor = gbc.EAST;
add(new Label("cols"), gbc);
gbc.anchor = gbc.WEST;
add(colChoice, gbc);
imagePanel.setReference(rowChoice);
class ImageLocator
Image image;
Point cell;
public ImageLocator(Image image, Point p)
this.image = image;
cell = p;
public Image getImage()
return image;
public Point getCell()
return cell;
class ImageLoader
Image[] images;
int index;
public ImageLoader(Component c)
loadImages(c);
index = 0;
public Image getImage()
return images[index++ % images.length];
private void loadImages(Component c)
String prefix = "images/";
String ext = ".jpg";
String[] fileNames = {
"greathornedowl", "owls", "bclynx", "coyote"
images = new Image[fileNames.length];
MediaTracker tracker = new MediaTracker(c);
Toolkit toolkit = Toolkit.getDefaultToolkit();
int id = 0;
for(int j = 0; j < images.length; j++)
URL url = getClass().getResource(prefix + fileNames[j] + ext);
images[j] = toolkit.getImage(url);
tracker.addImage(images[j], id++);
try
tracker.waitForAll();
catch(InterruptedException ie)
System.out.println("interrupted: " + ie.getMessage());
class KeyNavigator extends KeyAdapter
ImageEditorPanel imagePanel;
final static int
UP = KeyEvent.VK_UP,
LEFT = KeyEvent.VK_LEFT,
DOWN = KeyEvent.VK_DOWN,
RIGHT = KeyEvent.VK_RIGHT,
ADD = KeyEvent.VK_A,
REMOVE = KeyEvent.VK_R,
CENTER = KeyEvent.VK_C,
ENTER = KeyEvent.VK_ENTER;
public KeyNavigator(ImageEditorPanel iep)
imagePanel = iep;
public void keyPressed(KeyEvent e)
int keyCode = e.getKeyCode();
int x = 0, y = 0;
switch(keyCode)
case UP:
y = -1;
break;
case LEFT:
x = -1;
break;
case DOWN:
y = 1;
break;
case RIGHT:
x = 1;
break;
case ADD:
imagePanel.addImage();
return;
case REMOVE:
imagePanel.removeImage();
return;
case CENTER:
imagePanel.centerCursor();
return;
case ENTER:
imagePanel.addRow();
return;
default:
return;
imagePanel.setCursor(x, y);
} -
Need to add jpg image file to flash file
Dear All,
I am new to flash. I have one flash file in which I want to show some images in a slide show way at start of the flash file.
Please let me know the step by step if possible.
ThanksYou're not likely to get a step by step created just for you here, but there are probably plenty of folks that have already done that for you elsewhere. Try searching Google for "Flash slideshow tutorial" or if you plan to make it actionscript controlled, use "AS# slideshow tutorial" where you substitute 2 or 3 for # depending on which version of actionscript you want to use.
If your title has any bearing on what you really need to know, then in the File menu select Import, select between the cjoices offered, and select the file from the directory search interface that appears. -
Help need for loading aligned images in JEditorpane
Hi all,
I need to align image with text using JEditorpane, If i load the html document with aligned image, there is no alignment for image in final display. So please suggest any ideas if u have on this topic. I am in great hurry.
Thanks in advance,
Nageswara Rao.VHello,
I'm also having the same problem, did anybody find any solution ?
-sanjaymishra70 -
Help needed to add ecommerce functionality
i am in the process of creating a website using dreamweaver
cs3. Almost completed. i have some e books with master reseller
rights. So i want to sell it through my website. i cannot spend
initial investment for 3 party sites so i thought of going via
paypal. but the site instructions aree to complicated.
1.how do i integrate paypal into my website with shopping
cart feature?
2. how do i allow people to download the files only after
they payed for them?
3.i have like 20 ebooks which i can sell. So how do i give
people the option of selecting what they want(adding to cart all
the individual ebooks they select) and then proceeding to check
out?
4.in paypal website they said about something like encryption
for security.not the ssl but something like to prevent users from
modifying the code and submitting wrong amount. is it actually
necessary?"coolguythampy" <[email protected]> wrote in
message
news:[email protected]...
>i am in the process of creating a website using
dreamweaver cs3. Almost
> completed. i have some e books with master reseller
rights. So i want to
> sell
> it through my website. i cannot spend initial investment
for 3 party sites
> so i
> thought of going via paypal. but the site instructions
aree to
> complicated.
Hm.. if you feel that way, you might want to hire someone to
do this.
Setting up a PayPal shopping cart is about the simplest
method of creating a
shopping cart site.
> 1.how do i integrate paypal into my website with
shopping cart feature?
This is a large general question which would be answered by
following the
instructions on the PayPal site. However, see below re.
digital downloads.
> 2. how do i allow people to download the files only
after they payed for
> them?
PayPal doesn't provide for digital downloads. I can
personally recommend a
service called Payloadz (www.payloadz.com) which works with
PayPal and
delivers your digital items automatically.
> 3.i have like 20 ebooks which i can sell. So how do i
give people the
> option
> of selecting what they want(adding to cart all the
individual ebooks they
> select) and then proceeding to check out?
I'm not sure how that would work with Payloadz/PayPal, since
I only sell one
item. The answer should be on the Payloadz site, or else a
support ticket to
them should get you an answer.
> 4.in paypal website they said about something like
encryption for
> security.not
> the ssl but something like to prevent users from
modifying the code and
> submitting wrong amount. is it actually necessary?
I'm not sure if it's necessary, but you could just be safe
rather than sorry
and use the encryption. PayPal support will be able to answer
a question
like that.
Patty Ayers | www.WebDevBiz.com
Free Articles on the Business of Web Development
Web Design Contract, Estimate Request Form, Estimate
Worksheet -
Urgent help needed!! Layout table and Draw layout cell dissapeared.
I need some urgent help. I'm using CS3 but for a while my
Layout Table and Draw Layout Cell icons appear greyed and can't use
them at all. Is there any kind soul out there who knows how to fix
this? I'm going nuts trying all the possible options but none seem
to work.
Help please!!!!!!> How would you about designing a page without using html?
You don't. But I don't recall suggesting that you not use
HTML. I just
suggested that you use best-practice HTML, no? Or maybe you
meant to ask
how you would go about building your site without learning
HTML? In that
case, I think you are outta luck. Using DW without knowing
HTML is a very
punishing experience, I'm afraid.
> PS: A virtual box of 12 bottles of Moet Chandon is
already on your way!!
I'd prefer Cristal, please.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"Untersberg" <[email protected]> wrote in
message
news:g4tj9a$m5o$[email protected]..
> Ahhhhhh!!!!! They came up!!!! They came up again!!
> I was on standard mode. Now going back to your
suggestion, which I really
> appreciate. How would you about designing a page without
using html? I'm
> just
> redesigning my website at the moment and need it to get
going urgently,
> hence
> the reluctance to start learning HTML at the moment.
I'll do after but I
> need
> to get this up and running fairly quickly.
>
> Cheers.
>
> PS: A virtual box of 12 bottles of Moet Chandon is
already on your way!!
>
Maybe you are looking for
-
Unable to change field from available text options in SM30?
It is either yes or no. I cannot change to yes , it keeps going back to no when I save. Anysuggestions? Thanks.
-
ITunes Store account for two different countries
Greetings to all, Until now my my Apple Id is used to purchase items on the Swiss iTune store. Presently I would like to have the following setup: One Apple Id to use with the Swiss iTune Store when I reside in Switzerland (this i have) with swiss cr
-
Block users from Home Hub 3 wi-fi without them kno...
Is there any way on the homehub 3 to block users on the wifi without it giving them a notification? When you use the parental lock down between certain times when the user opens a web page it says they've been locked down by the hub but I don't want
-
I receive attached photos by email from other friends. I open photos in my new iPad3, and I go to " save photos". But no photos go to my iPad3 photo albums. Any suggestion, please.
-
Cant open digital edition 4.0
Hello, Just installed Adobe DE, but cant open it. Windows XP. Adobe DE 4.0 has encountered a problem and needs to close. Thank u.