I am trying to use the Williams objectdraw library (http://eventfuljava.cs.williams.edu/library/objectdrawJavadocV1.1.2/index.html) to make a line on my drawing canvas. I am very new to Java and am unsure whether I am setting it up correctly. Attached is a screenshot of what happens when I run the code.
You have extended WindowController,i think you are suppose to extend Applet..
http://spot.colorado.edu/~cathyb/hiapplet.html have a look at this page it will be useful.
Related
Java noob here.
I am taking an intro to java class. The professor wants me to create a gui that looks like this:
But I have no idea what those blocked sections are (labeled Pizza Size, and Toppings).
I just need to know what they are called so I can look up some documentation on them. Prof is horribly unorganized, so of course no mention in the notes. Also having a tough time figuring out what they are by Google search due to not having the right keyword.
I just need the name of those sections, then I can find documentation for how to create them.
These are TitledBorders (a class implementing the Border interface.
You can put a Border around any JComponent.
In your example screenshot there are 2 JPanels, each with a TitledBorder.
See the tutorial How to Use Borders for more info.
Is there a way to render graphical objects in console using standard jdk API?
For instance I want to render moving image in console (not via awt/swing).
The console itself can only render characters..
But if you mean you want to render an image from a command line app. (that is later displayed in other apps.) then yes, though the 'moving' part does not make much sense unless you mean an animated GIF.
No you cannot. The console renders characters so ASCII-art is your best choice.
Also this has been answered before: displaying-images-in-a-console-application
I found this post on the site:
Blackberry Clickable BitmapField
explaining a class where you can draw a clickable bitmap. This is exactly what I want to do but the issue for me is that I'm quite new to Java and I don't know how to properly call this statement. What are the commands to create this bitmap? So far all I have is:
CustomMenuButtonField buttonInstance = new CustomMenuButtonField("img1.png", "img2.png");
aside from that I don't know how to make the drawing appear. If I try:
buttonInstance.paint(graphics);
I need to declare graphics which I am not sure how to do. I've checked the API but its still a bit confusing to me. Also where should these call statements be used? In the userInterface constructor?
Once you create your custom button field, you just need to add it to your screen:
add(buttonInstance);
It will then be displayed by the framework automatically. For more info, see the Getting Started Guide for the SDK version you are using in the Development Guides.
I have a pretty complex Java (JDK 6) code that needs to be converted so it works on Android. That Java code is intended to work with graphics: thus i have a class that extends JLabel (Swing component), "paintComponent" method reshapes that extended JLabel ("cuts" it to look like a circle) and draws it on the screen (i know, i know - i might use come "drawCircle" method but i need to extend JLabel because it has some popup menu attached to it).
Now, i have a problem - Android don't seem to have "Graphics" type, "Dimension" type, "Rectangle" type, "paintComponent" method and after all, i have no idea what control should i use to draw those customized JLabels on (in JDK 6, i have used JPanel that was container for those customized JLabels).
Please help! I need some advice on what would be the most painless method for converting given Java logic to Android logic?
Android provides Graphics and 2D Graphics, used for drawing.
Have a look at Shape Drawable which should assist you in drawing rectangles. Instead of JLabel use TextView. You will have to spend some time in getting to know Android and redrawing your GUI, but I hope I provided some good starting points.
Also note that depending on complexity of your code, you may not be able to use all your Java code, becase Android doesn't provide full Java version.
AFAIK Android doesn't support Swing, so you're going to have to use equivalent Android UI classes. The android UI classes are not a 1-to-1 match with Swing classes, so sometimes an Android port means you need to do a pretty heavy UI rewrite.
Android do not have JLabel, so you can not use this code.
Instead use TextView . You can declare TextView in xml or in java code
I am developing a small desktop application in Netbeans. The application is complete and working fine. A small description of application is as follow:
The application is basically an object manager, where user add new object, remove old objects and connect object with each other. What i did is that i simply add 3 panel and change its type to titled border. One for Add object one for remove and one for connect.
Status:
Every thing is working fine as expected.
What Left:
In order to make UI more appealing i added a new panel at the end and called it "Object Viewer". I am planing to visualize the steps which user performs e.g
If user add an object then i that pannel i will daraw a little
circle and fill it with green color
Similarly if user remove some object then again i will draw another
cricle and fill that with red
And when user connects two object then i will draw two circle and
connect them with a dotted line
This is my first java application, i only want to know how do i acheive this task. Some links or experience are highly appreciated
As for custom painting in swing, have a look here: http://download.oracle.com/javase/tutorial/uiswing/painting/
However, I'd suggest using a graph visualization library like JUNG etc. Using this you'd basically only have to define your object graph.
You can either do that manually with Java 2D, which I don't recommend, or, since you are using Netbeans (and I assume the Netbeans Platform, but this is not required), I would strongly suggest looking at the Netbeans Visual Library. It can do exactly what you want.
As Nico Huysamen said you can do that with Java 2D. But because it's your first Java application I strongly recommend to do it manually with this lybrary in order to understand how higer level lybraries work.