I'm trying to develop an application to sort photos, based on the tinder principle.
The picture below is a screenshot of my current GUI, I want to combine the 2 middle columns on the first row so that the label for the photo to be placed in is nicely in the center.
This GUI has been developed in intellij using the gridlayoutmanager. Could someone happen to help me solve this problem?
Kind regards
Current GUI:
This GUI has been developed in intellij
Don't use the IDE to generate your GUI code. Write the code yourself so you are in full control
using the gridlayoutmanager
You are never forced to use a single layout manager. You can create multiple panels each using a different layout manager to achieve your desired layout.
I want to combine the 2 middle columns on the first row
Create a panel. Add the "Dislike" and "Like" buttons to the panel. Add the panel to the parent panel.
Related
I am curious if it possible to center a JButton in two X grids of a GridBagLayout? I've done some searching through the API but haven't found much. I have also drawn up a small picture to clarify what I am trying to do.
Thank you!
Example Image:
I've done some searching through the API but haven't found much.
Read the section from the Swing tutorial on How to Use GridBagLayout.
You would need to concentrate on the Specifying Constraints section:
the gridwidth constraint will allow the button to span multiple columns
the anchor constraint will allow the button to be centered within the two columns.
the fill constraint will need to be turned off.
The above assumes that you actually have other components on the panel in each of the columns. You can't just randomly say a single component takes up two columns.
So start with the demo code in the tutorial an modify it to have the button on the bottom centered.
I need to place few buttons one under another and few textboxes in the same way using SWT.
When I'm doing that, they are next to each other and I cannot change it even using
button1.setLocation(new Point(100,20));
button2.setLocation(new Point(400,10));
Can I add those things to something similiar to SWING's JPanel and move/position it freely as I need? Or maybe another solution? As to let You know - I cannot use SWING here. It has to be SWT. The reason is that I have already a chart made with SWT. The buttons and textboxes should be placed so they won't be covering my chart.
You can dynamically add a new control to the existing layout, but make sure you call the layout() on the parent Composite, where you have set the layout.
If you want to place a SWT control relative to another control, you can use org.eclipse.swt.layout.FormLayout.
I had started working on a java based tool that my friend has developed. Now we are working on it together. He has used custom made jpanels and used them in jtabed pane like fashion. Its something like this,(check the link for the screen shot,since i am new user,i cannot post images here)
https://www.dropbox.com/s/5wnrmxiraywlg7p/tab2.png
The problem is that,we want to implement a browser like display of tabs,when the number of tabs opened is more that the panels widths,it gets hided.so the idea is to develop a left and right brows tab buttons tats similar to web broswer .how this could b achieved?
More info about the current layout and design:
The canvas panels are created and tab panels are created and finally called in the main display panel. The stagetab panel holds the tab panels(which mimics appearances of the tabbed pane). Also there already functions to display various canvas panel(different tabs) based on user pressing the tab panels.so all those are working well. have been looking on various solutions for this problem.one sch is developing an custom view port like method similar to jscroll pane which could be used here.
What would be the better way to do this?
A good possibility would be to use SCROLL_TAB_LAYOUT as tabLayoutPolicy. This will show two arrows at the corner of the JTabbedPane. Of course you could redesign the component to show it as you want.
You can find an image of a table using it here.
I am creating an RAP application in JAVA.
i want to have a GUI like master detail. in which left side has panel that has a tree (like in windows 7) and on the right side there will be text fields which will be changing when different TreeItem is selected.
So i have to add two panels, but i don't know how to add panels into composite.
Please help
use frame.getContentPane() to the the master contentpane. Set its layout as new GridLayout(1,2).
Now create two panels and add them to the frame. http://docs.oracle.com/javase/tutorial/uiswing/components/panel.html
There are also more complex solutions depending on what you want to do. For example if you want to make the division of the space between left and right side cosumizable use jsplitpanes (http://docs.oracle.com/javase/tutorial/uiswing/components/splitpane.html).
SWT is one thing, Swing is another. If you already have something written in SWT and want to add Swing components, then you have to use the SWT/AWT Bridge. You can find a tutorial on how to do this here.
I'm trying to write a scorekeeping app in Java that allows a server application to send scores to client applications. The clients will then display a list of teams, team IDs and their scores, sorted by score. Of course I could just use a swing JTable to display everything, but I want to achieve a unique effect: I want the text dynamically reorder itself every time a team moves up in the list. That is, it want to animate the text around the screen. I would also need to be able to update the contents of the labels after being added. What would be the best way to achieve this? Is there any component that allows you to add other components to it and place/move them freely?
JTable is a JComponent so you can set desired LayoutManager and add JLabels above the JTable. Then move/reorder them to achieve desired effect. See SwingWorker as well.
You could use a JTable and change the contents of the rows as teams move up. Or you could arrange a series of labels and change the text whenever you want. To change the value displayed for a JLabel you simply use the JLabel.setText("new value"); method.
I've never done this but I think you need to use a panel with a 'null' layout manager. Meaning you are responsible for absolutely positioning your elements
http://docs.oracle.com/javase/tutorial/uiswing/layout/none.html
You would need some kind of SwingWorker or Timer running to update the gui layout. Make sure you actually make the GUI changes on the EventThread, which you can do by using SwingUtilities.invokeLater();
As alternatives to a null layout, consider letting the layout work for you using
one of the marquee effects discussed here, or
shuffling labels in a suitable layout, shown here and here.