What are these blocked sections in java GUI - java

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.

Related

Make a borderless JFrame

Any parameter to set A JFrame's border/frame thickness or existence and still keep the title bar intact? I want an almost borderless frame with a thin blue line like this one and not like the default border.
If JFrame isn't the way to go, what is a good way to achieve that? (preferably that is compatible with WindowBuilder but that's probably asking for too much).
A search barely yields any mention and related questions on SOF don't seem to have answers so I thought I'd try to get a good answer once and for all.
JFrame#setUndecorated
Disables or enables decorations for this frame.
This method can only be called while the frame is not displayable. To make this frame decorated, it must be opaque and have the default shape, otherwise the IllegalComponentStateException will be thrown. Refer to Window.setShape(java.awt.Shape), Window.setOpacity(float) and Window.setBackground(java.awt.Color) for details
Please, consult the available documentation
Please note, you will become responsible for providing the title bar yourself, should you want it
A search barely yields any mention and related questions on SOF don't seem to have answers
Google provides a number of promising hits
I ended up switching to NetBeans and learning some Photoshop basics which you'll need thanks to a comment by #MadProgrammer
writing your own look and feel delegate
and ended up exactly with what you mentioned #theProgrammer101
You can make a JButton, and when it is clicked, call System.exit(0) , which will terminate the program
You can create a similar button for minimize action as well as your own drop down menus that are totally custom made and you won't need to rely on the default JFrmae window in case that bothers you too (I found it horrid).
check out this link for a good NetBeans tutorial with an nice example of writing your own look and feel delegate and this link for a great tutorial on getting started with Photoshop which is critical to GUI creation.
Thought i'd round up some of my research for anyone else who's just getting into GUI's.

Looking for slide bar with two knobs in Java

I am looking for slide bars with two knobs for a user to move them separately or both together, similar to the one in the picture to use in Java. Any sidebar with two knobs (two indicators) would do. Does it exist?
That's called a range slider. Here it is discussed in another thread:
Range Slider in Java
Also, here's an API which provides a JRangeSlider swing object:
http://prefuse.org/doc/api/prefuse/util/ui/JRangeSlider.html
I've never used it, but it looks like just what you want.
i would suggest checking out JIDE (open source components), i know for a fact there is a range slider with two knobs
Sorry for late answer:)
I recently implemented JRangeSlider without custom painting code, thus it will always look like normal JSlider, but with two knobs.
https://github.com/andronix3/SwingHacks/blob/master/com/smartg/swing/JRangeSlider.java

Creating a Grid in Java

As a way of learning Java, I'm writing this little application for grade schoolers to practice basic math. The idea is that the kid does any number of math problems, as long as they are in the app, it just continues to throw problems at them until they click a 'Done' button. When they decide to be done, I want a new JFrame to come up that will show them all of the problems they attempted, along with their answer, and whether they got the problem right or wrong.
The advice that I am looking for is what is the best way for me present these results. I looked into the GridLayout and the GroupLayout, but I don't think that these are exactly right. I did something similar in VBA for Excel, and there I just ran a for loop with one iteration for every problem they attempted. Each iteration would add a row of labels to the frame with the elements of the problem displayed in the various labels. I tried this in Java, but I'm not even able to get the labels to even display.
So before I get all specific and start posting my code, I want to ask a bigger question, which is "what is the best method to create a view like this?" Often, I go off in one direction only to waste time before somebody suggests a totally different (and better) approach.
Thanks!
(edit: here's an image of how I did this in Excel. I'm trying to repeat basically the same thing in Java)
One simple way to make that design would be to use a mix of components. You could have a bunch of JLabels and JPanels stacked in a vertical FlowLayout. The grid you have described would be best designed in a JTable, something like the below:
If you like tables like Excel then, Java provides JTable class to create tables, if you want.
Tutorial : http://docs.oracle.com/javase/tutorial/uiswing/components/table.html

Java: Interface with squares (to drag), lines (to link the squares) and animation (square follows the line)

I'm starting to create a Industrial Simulation (IS) interface, using Java.
The problem I'm pointing here is the interface.
A IS interface will have some big squares (geometrical figure) (unfilled, instead of it they will have their "names" inside it), one or more lines linking the squares, and while time will be going, some "mini-squares" will get out of one big square to another, following the line that links both.
I have to construct a interface that is able to have either the geometric (square) figures and the animation with the "minisquares" following the link (that will be the line).
Is there any API, or tool, whatever, in java, that could help me starting this part of the project?
If you can use javafx... runs on the JVM... that might be easiest way. Here's a link to a tutorial for animating along a path
Otherwise I guess you'll be looking at Swing, but I suspect it's a lot trickier. Here's a similar link.
Visual editors like Matisse can help you get started with layout etc., but I don't know of anything that will let you point-and-click your way round animation.

Can I use two different look and feels in the same Swing application?

I'm using the Flamingo ribbon and the Substance Office 2007 look and feel.
Of course now every control has this look and feel, even those on dialog boxes.
What I want is something like in Office 2007, where the ribbons have their Office 2007 look, but other controls keep their native Vista/XP look.
Is it possible to assign certain controls a different look and feel? Perhaps using some kind of chaining or a proxy look and feel?
I just discovered: Since Substance 5.0 the SKIN_PROPERTY is available.
It allows assigning different skins to different JRootPanes (i.e. JDialog, JFrame, JInternalFrame)
A little trick: I override JInternalFrame to remove the extra border and the title pane so that it looks just like a borderless panel. That way it is possible to create the impression, that different parts of a form/dialog have different looks.
Here is a library which will automaticaly change the look and feel. I am not sure it this will done for every component in a different way, but you should take a look at it. pbjar.org
This book should be useful if you want to go deep into look and feel /java-look-and-feel-design-guidelines-second-edition
I would be glad to see some code example, if someone can write it, feel free to get starting.
EDIT:
In this forum thread Thread i found the following description
Swing uses a Look & Feel (a PLAF).
PLAFs aren't attached on a per-JFrame
level. They are attached on a per-VM
level. It is almost impossible to mix
PLAFs within one application. I have
seen a few attempts, all failed.
Swing unfortunately does lots of "psuedo-global" things behind the scenes. AFAIK, the only way to do it consistently is to use the private AppContext API. Each AppContext has its own event dispatch thread and other "psuedo-globals".

Categories

Resources