Re: Creating a component by putting together others



CK escribió:
But I'm not sure how to do that. I've thought of putting both
components (JTextField and JButton) inside a JPanel, and thus I would
write my custom component by extending a JPanel with two private
properties holding the text field and the button. Would that be
sensible or should I extend JComponent (which I think is more complex)?

Your custom component does not offer funtionality on its own, right?


Just the coupling between the text field and the button, so if you
press the button, a select file dialog appears. If you select a file
there, on closing the select file dialog, the pathname is
automatically copied in the text field.

So, it probably doesn't.


So it isnt really a component but more like a wrapper pane(l).

I would subclass JPanel, since what your component tries to do has
more to do with a JPanel than any other JComponent.


OK, thank you very much for your promptly response.


Computers are stupid, but they create work

(...just like some users...) ;-)


--
If it's true that we are here to help others,
then what exactly are the OTHERS here for?
.



Relevant Pages

  • Re: Always two custom components drawn
    ... > create a custom component and I trap the mouse events in my JPanel to call ... > pressed, the rectangle is drawn. ... > component to draw a JLabel at the top of the filled rectangle, ...
    (comp.lang.java.gui)
  • Re: How many warnings is too many?
    ... >> there is no point extending JPanel. ... >> JComponent is absurd. ... in extending if you're implementing a true custom component. ...
    (comp.lang.java.programmer)
  • Creating a component by putting together others
    ... and a JButton next to it to launch a Choose File Dialog. ... create a custom component to tie both fields together. ... components inside a JPanel, ... sensible or should I extend JComponent? ...
    (comp.lang.java.gui)
  • Re: Creating a component by putting together others
    ... components inside a JPanel, ... write my custom component by extending a JPanel with two private ... sensible or should I extend JComponent? ... Your custom component does not offer funtionality on its own, ...
    (comp.lang.java.gui)
  • JTable, custom components and event handling
    ... I have a JTable in which one of the columns will be custom component ... which is a subclass of JPanel. ... Added a MouseListener via addMouseListener ... a molecular structure and clicking and dragging the mouse should rotate ...
    (comp.lang.java.gui)