Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The short answer to your question is, no. There are no ready made components. You're going to have to roll up your selves and get your hands dirty.</p> <p>Break your problem down.</p> <p>You need the entity to be floatable. The only two (decent) choices you have are <code>JLayeredPane</code> and <code>JDesktopPane</code>. Which you choice will depend on the features you want to implement. I'd probably start with <code>JLayeredPane</code>. This will allow you to position components where you want them and also provides the ability to more easily control the Z-level.</p> <p>The problem with this, is you will become responsible for not only positioning the components, but also resizing them.</p> <p>Next, you need an entity component.</p> <p>This would be, to my mind, a series of compound components. You'd need a "header" or "title" component, which would provide the name of the table, the expand control and a means by which you can drag it.</p> <p>I'd start with a simple <code>JPanel</code>. Onto which I would add a <code>JLabel</code>, a <code>JTextField</code> and either a <code>JButton</code> or <code>JLabel</code> to act as the expand control, depending on what look I was after.</p> <p>The <code>JLabel</code> will act as the title for the header. The <code>JTextField</code> would as as the editor. Start by making the text field hidden. With a little bit of clever use of a layout manager, you can place two components in the space place. When the text field is made visible, it will be able to lay over the label.</p> <p>You will need to add a mouse listener and mouse motion listener this component. When clicked, the editor should be shown. Use an <code>ActionListener</code> and <code>FocusListener</code> to determine when the user has finished editing and update the label and hide the editor. You'll probably also want to bind a <kbd>Esc</kbd> to the field to allow the user to cancel the edit, key bindings are best for this.</p> <p>You will also need to track the mouse drag events so you can reposition the "entity"</p> <p>This header component would then be added to the entity component.</p> <p>You would need either a <code>JList</code> or <code>JTable</code> to hold the field information. To my mind, a <code>JTable</code> would provide the most functionality, allowing you to more easily edit the field information.</p> <p>You will also need to perform some custom painting to provide links from one table to another. This is a non-trival problem and is going to need some seriously good design on your part.</p> <p>Every thing you need to get started can be found at <a href="http://docs.oracle.com/javase/tutorial/uiswing/" rel="nofollow">Creating a GUI With JFC/Swing</a>, but you're also going to need to read through and understand <a href="http://docs.oracle.com/javase/tutorial/uiswing/painting/" rel="nofollow">Performing Custom Painting</a> and <a href="http://docs.oracle.com/javase/tutorial/2d/" rel="nofollow">2D Graphics</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload