Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 103364 Details for
Bug 235242
creating an image with a filename produces a corrupt file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
snippet
IconTest.java (text/plain), 2.19 KB, created by
Shawn Minto
on 2008-06-03 12:50:32 EDT
(
hide
)
Description:
snippet
Filename:
MIME Type:
Creator:
Shawn Minto
Created:
2008-06-03 12:50:32 EDT
Size:
2.19 KB
patch
obsolete
>import java.io.FileInputStream; >import java.io.FileNotFoundException; >import java.io.InputStream; > >import org.eclipse.swt.SWT; >import org.eclipse.swt.graphics.Image; >import org.eclipse.swt.graphics.ImageData; >import org.eclipse.swt.layout.GridData; >import org.eclipse.swt.layout.GridLayout; >import org.eclipse.swt.widgets.Button; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Event; >import org.eclipse.swt.widgets.FileDialog; >import org.eclipse.swt.widgets.Listener; >import org.eclipse.swt.widgets.Shell; >import org.eclipse.swt.widgets.ToolBar; >import org.eclipse.swt.widgets.ToolItem; > >public class IconTest { > > /** > * @param args > * @throws FileNotFoundException > */ > public static void main(String[] args) throws FileNotFoundException { > final Display display = new Display(); > final Shell shell = new Shell(display); > > shell.setLayout(new GridLayout()); > final Button button = new Button(shell, SWT.PUSH); > GridData gd = new GridData(); > gd.grabExcessHorizontalSpace = true; > gd.minimumWidth = 100; > gd.minimumHeight = 20; > button.setLayoutData(gd); > > final ToolBar toolbar1 = new ToolBar(shell, SWT.FLAT); > final ToolBar toolbar2 = new ToolBar(shell, SWT.FLAT); > > button.addListener(SWT.Selection, new Listener() { > public void handleEvent(Event e) { > FileDialog dialog = new FileDialog(shell); > dialog.setFilterExtensions(new String[] { "*.ico", "*.gif", > "*.*" }); > String name = dialog.open(); > if (name == null) > return; > > Image oldImage = button.getImage(); > > try { > > button.setImage(new Image(display, name)); > > ToolItem i1 = new ToolItem(toolbar1, SWT.NONE); > i1.setImage(new Image(display, name)); > > InputStream is = new FileInputStream(name); > ToolItem i2 = new ToolItem(toolbar2, SWT.NONE); > i2.setImage(new Image(display, is)); > is.close(); > > shell.redraw(); > shell.layout(); > > if (oldImage != null) > oldImage.dispose(); > } catch (Exception e2) { > } > } > }); > > shell.setSize(300, 300); > shell.open(); > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) > display.sleep(); > } > display.dispose(); > > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 235242
:
103229
|
103360
| 103364 |
103365