Creating a Symbol palette in Swing
Suppose I want to create a control in Java that is like the Symbol control in Microsoft Word that allows you to choose and i开发者_Python百科nsert symbols from a grid into a text area. Are there any Swing controls that would get me half-way there? If not, any ideas on how to create one from scratch?
Just create a JPanel with a GridLayout. Then you can add JButtons to the grid with the text of the button representing the symbol you want to add to the text area. You can then share a common ActionLIstener between all the buttons that simply takes the text of the button and inserts it into the text area.
精彩评论