Mercurial Hosting > junotu
view src/junotu/TabSimpleSearch.java @ 5:81608928a9db
Separated window functionality off from the Main class into a Window class
In preparation for multiple windows support.
author | Fox |
---|---|
date | Tue, 05 Apr 2022 00:45:42 +0200 |
parents | 1b754922d6af |
children | 9d3256f86803 |
line wrap: on
line source
package junotu; import java.awt.Dimension; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JPanel; import javax.swing.Box; import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JTextField; import javax.swing.JScrollPane; import junotu.Main; import junotu.Window.Tab; import junotu.CardWidget; public class TabSimpleSearch extends JPanel { public TabSimpleSearch() { this.setLayout( new BorderLayout() ); JPanel top = new JPanel( new BorderLayout() ); JTextField field = new JTextField(); JButton create = new JButton("+"); Box results = Box.createVerticalBox(); JScrollPane scroll = new JScrollPane( results ); field.setFont( new Font( "Monospaced", Font.PLAIN, 16 ) ); create.setFont( new Font( "Monospaced", Font.BOLD, 16 ) ); scroll.getVerticalScrollBar().setUnitIncrement(128); field.setPreferredSize( new Dimension(32, 32) ); this.add( top, BorderLayout.NORTH ); top.add( field, BorderLayout.CENTER ); top.add( create, BorderLayout.EAST ); this.add( scroll, BorderLayout.CENTER ); for( int i = 0; i < 100; i++ ) { CardWidget card = new CardWidget( "Placeholder #"+Integer.toString(i+1) ); results.add( card ); } scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); create.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent e ) { buttonClickedCreate(); } } ); } private void buttonClickedCreate() { Main.activeWindowTabSwitch( Tab.EDIT ); } }