I'm trying to load an image into Java to create a texture in JoGL. I need to use a call to BufferUtils for this:
dest = ByteBuffer.allocateDirect(data.length * BufferUtils.SIZEOF_INT);
But it's telling me that it can't find it. This is all I have imported:
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import com.sun.opengl.util.*;
import com.sun.opengl.util.j2d.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import java.net.*;
import java.nio.*;
import javax.imageio.*;
import javax.swing.*;
I think you mean BufferUtil (no 's').
Related
When I do optimize imports in IntelliJ (CTRL + ALT + O) I get two (according to me) weird consequences.
The imports go from alphabetical order --> not alphabetical order
A space is added between imports and java.util imports.
Example before optimize:
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.filter.ClientFilter;
import java.util.HashMap;
import java.util.List;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
Example after optimize:
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.filter.ClientFilter;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import java.util.HashMap;
import java.util.List;
Why is it that java.util packages seem to get some special treatment and end up here in the bottom with an additional space before them?
The import organizing is defined at File/Settings menu, under Editor/Code Style/Java, in the Import Layout section (assuming IDEA 14). In your case I suppose it contains com.* , followed by org.* , followed by blank line, followed by java.* etc. You can customize it here according to your needs.
I've bought a pro Javafx2 book and I tried to compile the first program from this book. The problem is that a few imports are underlined, as they can't be found. These are the problematic import statements:
import javafx.builders.GroupBuilder;
import javafx.builders.ImageViewBuilder;
import javafx.builders.RectangleBuilder;
import javafx.builders.SceneBuilder;
import javafx.builders.TextBuilder;
import javafx.builders.TranslateTransitionBuilder;
But these give no error:
import javafx.animation.Interpolator;
import javafx.animation.Timeline;
import javafx.animation.TranslateTransition;
import javafx.application.Application;
import javafx.geometry.VPos;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage;
import javafx.util.Duration;
The question is if I'm doing something wrong? Do I need install something else to compile this code? Recently, I compiled a simple Hello World example and it worked fine.
What javafx are you using?Maybe JavaFX 8?If yes 'javafx.builders' doesn't exist anymore.
For example 'javafx.builders.GroupBuilder' is in package 'javafx.scene.GroupBuilder' and it is #Deprecated:
I got some source code for an Entertainment Game Bot (for Runescape) years ago and am trying to run it now. However, a lot of the imports are unrecognized by jGrasp and I don't know how to fix the code as I am still only a student. The code for the imports is below:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Map;
import org.rsbot.bot.Bot;
import org.rsbot.event.events.MessageEvent;
import org.rsbot.script.util.*;
import org.rsbot.script.*;
import org.rsbot.script.wrappers.*;
import java.util.Random;
import javax.swing.JOptionPane;
import org.rsbot.event.listeners.MessageListener;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.script.methods.Game;
import org.rsbot.util.GlobalConfiguration;
#ScriptManifest(authors = { "Enfilade" }, keywords = {"rune", "riot"}, name = "Rune Riot", version = 1.0)
The program code is not shown as it is far over the character limit of this post. When I attempt to compile the code it gets a lot of import-related errors such as:
RuneRiot.java:17: error: package org.rsbot.bot does not exist
import org.rsbot.bot.Bot;
Please tell me what I need to do to solve the import errors and get the code to run properly. Thanks!
package org.rsbot.bot does not exist means that you are missing your org.rsbot.bot package.
This can mean one of two things:
You don't have the package. Solution: get the package.
You haven't added the package correctly. You need to get your jGrasp to put the Jar or source files (whatever format they are in) for the missing packages on your build path.
I have an element defined as a HTML element, namely <canvas id = 'foo' width = '25' height = '40'></canvas>. I am trying to draw to it like this:
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;
Canvas canvas2 = Canvas.createIfSupported();
Element el = DOM.getElementById("foo");
canvas2.setElement(el);
The last line is throwing an error in Eclipse, error message being The method setElement(Element) from the type UIObject is not visible. What should I do to correct it? This is the list of classes I am importing, is there any JAR conflict?
import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.canvas.dom.client.Context2d;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
Unfortunately there is no easy way to do this currently. Issue #6683 is open for that in GWT's issue tracker. The suggested workaround is to copy the Canvas widget class and loose the visibility of the constructor... not very convenient I admit.
I have seen Google Contacts API but I am not getting any thing I want to fetch email contacts from logged in users.
I found a simple example with php which is very easy but I am not able to convert it in to java. I am trying with Google contact API problem is the import statement is showing error.
How to import these.
import com.google.gdata.client.*;
import com.google.gdata.client.contacts.*;
import com.google.gdata.data.*;
import com.google.gdata.data.contacts.*;
import com.google.gdata.data.extensions.*;
import com.google.gdata.util.*;
import java.io.IOException;
I am not getting jar file for these imports. If is there any example other than google please give links.
I found the following maven entry:
<dependency>
<groupId>com.google.gdata</groupId>
<artifactId>gdata-contacts-3.0</artifactId>
<version>1.41.5</version>
</dependency>
supported the following imports, which allowed me to access the gmail contacts
import com.google.gdata.client.Service.GDataRequest;
import com.google.gdata.client.contacts.ContactsService;
import com.google.gdata.data.Link;
import com.google.gdata.data.TextConstruct;
import com.google.gdata.data.contacts.Birthday;
import com.google.gdata.data.contacts.ContactEntry;
import com.google.gdata.data.contacts.ContactFeed;
import com.google.gdata.data.extensions.Email;
import com.google.gdata.data.extensions.FamilyName;
import com.google.gdata.data.extensions.FormattedAddress;
import com.google.gdata.data.extensions.GivenName;
import com.google.gdata.data.extensions.Name;
import com.google.gdata.data.extensions.OrgName;
import com.google.gdata.data.extensions.Organization;
import com.google.gdata.data.extensions.PhoneNumber;
import com.google.gdata.data.extensions.StructuredPostalAddress;
import com.google.gdata.util.AuthenticationException;
import com.google.gdata.util.ContentType;
import com.google.gdata.util.PreconditionFailedException;
import com.google.gdata.util.ServiceException;