Mercurial Hosting > junotu
changeset 51:da84f5a332f0
TabColumns: Now able to add columns via a button
author | Fox |
---|---|
date | Thu, 24 Nov 2022 21:17:30 +0100 |
parents | 3431ab41f067 |
children | 7cf2788649a7 |
files | src/junotu/TabColumns.java |
diffstat | 1 files changed, 23 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/junotu/TabColumns.java Tue Nov 08 13:58:42 2022 +0100 +++ b/src/junotu/TabColumns.java Thu Nov 24 21:17:30 2022 +0100 @@ -42,7 +42,7 @@ import junotu.Window.Tab; import junotu.Card; -public class TabColumns extends JPanel implements MouseListener { +public class TabColumns extends JPanel implements ActionListener, MouseListener { final static int COLUMN_CONTENT_WIDTH = 256; final static int COLUMN_WIDTH = COLUMN_CONTENT_WIDTH+16; @@ -199,19 +199,30 @@ Box columns; JScrollPane scroll; + JButton addColumn; + public TabColumns() { this.setLayout( new BorderLayout() ); title = new JLabel(""); + addColumn = new JButton("+"); + JPanel top = new JPanel(); columns = Box.createHorizontalBox(); scroll = new JScrollPane( columns ); + + top.setLayout( new BorderLayout() ); title.setFont( new Font( "Monospaced", Font.PLAIN, 32 ) ); + addColumn.setFont( new Font( "Monospaced", Font.BOLD, 32 ) ); - this.add( title, BorderLayout.NORTH ); + top.add( title, BorderLayout.CENTER ); + top.add( addColumn, BorderLayout.EAST ); + this.add( top, BorderLayout.NORTH ); this.add( scroll, BorderLayout.CENTER ); + addColumn.addActionListener(this); + /* TODO: DEBUG */ columnsNew(); @@ -221,9 +232,9 @@ { title.setText("New board"); columns.removeAll(); - for( int i = 0; i < 5; i++ ) { + /*for( int i = 0; i < 5; i++ ) { insertColumn(); - } + }*/ } public void columnsEdit( Card columnsCard ) @@ -241,8 +252,15 @@ ColumnWidget column = new ColumnWidget(); column.titleSet("New column"); column.addMouseListener(this); - //columns.add( Box.createHorizontalStrut(16) ); columns.add(column); + columns.revalidate(); + } + + public void actionPerformed( ActionEvent e ) + { + if( e.getSource() == addColumn ) { + insertColumn(); + } } public void mouseClicked( MouseEvent e )