I have a method in which i use gwt PopupPanel to display an image while screen loads and server workloads.
final static PopupPanel popup = new PopupPanel(false, true);
The method i use is :
public static void sBanner() {
popup.setWidget(new Image("Images//Progress.gif"));
popup.setGlassEnabled(true);
popup.center();
}
What i dont manage to do it is to show the image when the method its called.
In local, runs fine; but when i deploy the code to Google App Engine, I get an icon like Google App Engine isnt finding the referenced file.
I have also tried to upload the image to Google Drive and use the sharing url as the url to use, but so far i havent been successful.
Anyone can enlight me?.
Thank you.
Use com.google.gwt.resources.client.ImageResource to provide images.
progress.gif should be in the same folder of Resources class (relative path can also be used-change #source value)
public interface Resources extends ClientBundle {
#Source("progress.gif")
ImageResource getPreloader();
}
Resources resources = GWT.create(Resources.class);
popup.setWidget(new Image(resources.getPreloader()));
Related
Im making a game with JavaFX and want to load images into it. Im having trouble with finding the correct URL to load the image
Its supposed to be a Memory game and the image is supposed to be loaded into a button for the player to interact with. Normally when I tried working with images, I start the URL at the projects folder and it works fine but here I keep getting error messages. I only get it to work when I type in the full URL from the C: Drive but shouldnt it also be possible to access it just from projects folder?
This is the constructor of the class for the Memory Cards
public MemoryCard(String front, int picID)
{
front = new ImageView(front);
picBack = new ImageView("src/grafics/back.jpg");
setGraphic(picBack);
//...
}
I have created a folder called 'grafics' under the source folder with the correct images inside. I thought this would work but it just gives me the IllegalArgumentException message on the line where I load the image.
I made a custom Eclipse plugin that uses and displays multiple dialogs, and I want to know if I could set the top left icon image with the one I use in the plugin's icons folder. I want to get that icon and set it instead of the default one that Eclipse uses.
I'm overriding the configureShell() method to change the dialog title, and I also want to change the icon.
#Override
protected void configureShell(Shell parent){
super.configureShell(parent);
parent.setText("Choose variant...");
Image icon = new Image(parent.getDisplay(), "icons/best.gif"); - this method does not work as it cannot find the file
parent.setImage(icon);
}
I also tried using the getClass().getResource("best.gif") and having the image in the same package, still can't find the location I'm giving(FileNotFoundException), and also, the Image constructor does not accept URL objects.
#Override
protected void configureShell(Shell parent){
super.configureShell(parent);
parent.setText("Choose variant...");
Image icon = new Image(parent.getDisplay(), getClass().getResource("icons/best.gif"));
parent.setImage(icon);
}
Is there a way to use the icon that I already have in my eclipse plugin?
The main problem is getting the icon from the icons folder of the plugin and making it a Image object.
Thank you.
You can register the icon in your plugins activator class like this:
#Override
protected void initializeImageRegistry(final ImageRegistry reg) {
reg.put(IMAGE_PATH, imageDescriptorFromPlugin(PLUGIN_ID, IMAGE_PATH));
}
The image path is relative to your plugin, e.g. icons/icon.png.
You can access these images via the activator class as well:
final Image image = MyActivatorClass.getDefault().getImageRegistry().get(IMAGE_PATH);
myShell.setImage(image);
(Note that I used the image path as key in the image registry, you do not have to do it like this but it makes everything a little bit less complicated by just using the same static String.)
For an Eclipse plugin you use the FileLocator class to find resources in your plugin.
For an image use something like:
String path = "icons/best.gif";
URL url = FileLocator.find(bundle, new Path(path), null);
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
Image image = desc.createImage();
Note: You must arrange for the image to be disposed when no longer needed.
If your activator extends AbstractUIPlugin you can also use the ImageRegistry available from that. The registry will deal with disposing.
Be sure that the icons directory is listed in the build.properties file. Missing this will causes issues when you export your plugin.
I have integrated the GWT application with Chrome packaged app with help of DirectLinkerinstaller like the code below:
public class CSPCompatibleLinker extends DirectInstallLinker {
#Override
protected String getJsInstallLocation(LinkerContext context) {
return "com/google/gwt/core/ext/linker/impl/installLocationMainWindow.js";
}
}
But now I want to call print function from Chrome packaged app. When I call window.print() it allows me to print current window, but I need to open a new separate window and print that.
Could you anyone please help me in this?
I can't answer anything about GWT or DirectLinkerinstaller, but here's an answer about Chrome Apps, assuming that's what you're asking about:
You use the chrome.app.window.create API to create a window. Then, you can call the print method for that window.
In my apps, I seldom want to print what's in a window, but rather something I've generated specifically for printing. For that, I create a PDF with jsPDF (Google it), which works well. Then I display the PDF in a window, and let the user print the PDF (or save it).
I am creating an windows desktop swt application.
I need to change the frame icon, for that I used
frame.setIconImage((new ImageIcon("C:\\Documents and Settings\\arjuns\\Desktop\\logo1 copy.png")).getImage());
The icon is displaying when I manually run the code from eclipse, but when I create an installer using Install4j the icon is not appearing.
Can anyone please help me.
URL url = ClassLoader.getSystemResource("ressources/logo.png");
Toolkit kit = Toolkit.getDefaultToolkit();
Image img = kit.createImage(url);
setIconImage(img);
This is similar to the previous answer, but I need to add a bit of information.
You can still use a direct path to your image (C:/User/logo.png) BUT imagine you give your program to someone else, he wont have the image in that specific path.
So I recemmend you insert it in your project like so:
(I usualy do a sperate package for any ressources).
so it will become ressources/logo.png and it will work for anybody opening your project.
import java.awt.*;
import javax.swing.*;
class set extends JFrame
{
set()
{
setSize(100,100);
setVisible(true);
setIconImage(new ImageIcon("navbit-home.png").getImage());
}
public static void main (String[] args) {
new set();
}
}
please set appropriate path.like C:/Documents and Settings/arjuns/Desktop/logo1copy.png
The image should be available in the JAR file you create. Then use getResource() to get the image from the jar file.
For example,
URL resource = this.getClass().getResource("resources/logo.png");
frame.setIconImage(new ImageIcon(resource).getImage());
Here the logo.png is located under 'resources' folder of the class file where this code is executed.
I am using QT Jambi (java) to make screenshots of a browser window.
My main method starts the framework like this:
QApplication.initialize(new String[1]);
ScreenshotMain widget = new ScreenshotMain();
widget.showFullScreen();
QApplication.exec();
and when the browser is done with the loading the following method is invoked and takes the screenshot.
public void loadDone() {
// Taking screenshot
QPixmap pixmap;
pixmap = QPixmap.grabWidget(browser);
pixmap.save(writeTo, "png");
System.out.println("Made screenshot "+writeTo);
browser.loadProgress.disconnect(this);
browser.loadFinished.disconnect(this);
QApplication.closeAllWindows();
}
My question now is the following:
How can I make screenshots out of an application without having to open a browser window, have it load the content. The idea is that I have a server application and I donĀ“t want to open a window to make the screenshot.
Does anyone of you have experience to make screenshots using QT Jambi in this way.
Thanks a lot for your help
Marc
This might be what you are looking for: linky