All pastes #401051 Raw Edit

Plouj

public java v1 · immutable
·published 2007-03-19 02:13 UTC
rendered paste body
import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;import javax.swing.text.*;import java.beans.PropertyChangeListener;import java.beans.PropertyChangeEvent;import java.text.*;public class a22broken implements ActionListener {	private final static String title = "a22broken - Various Queries";	// lables	private final static String bidLbl = "bid:";	private final static String typeLbl = "type:";	private final static String fromDateLbl = "from date:";	private final static String toDateLbl = "to date:";	private final static String cityLbl = "city:";	private final static String txtPanelTitle = "Query output";	private JFrame appframe;	private JPanel apppanel;	private JPanel buttonpanel;	private JPanel textpanel;	private JTextArea resulttext;	private JScrollPane resultpane;	private JComboBox bidSelector;	private JComboBox typeSelector;	private JComboBox citySelector;	private JFormattedTextField fromDateInput, toDateInput;	private SimpleDateFormat dateInputFormat;	private final static String datePattern = "yyyy/mm/dd";	private final static int buttoncount = 4;	private JButton[] querybuttons = new JButton[buttoncount];	private Integer[] bids;	private String[] types;	private String[] cities;	public a22broken() {		//Create and set up the window.		appframe = new JFrame(title);		appframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);		//appframe.setSize(new Dimension(320, 240));		//Create and set up the panel.		apppanel = new JPanel(new GridBagLayout());		//apppanel.setLayout(new BoxLayout(apppanel, BoxLayout.Y_AXIS));		//Add the widgets.		addWidgets();		//Add the panel to the window.		appframe.getContentPane().add(apppanel, BorderLayout.CENTER);		//Display the window.		appframe.pack();		appframe.setVisible(true);	}	private void addWidgets() {		GridBagConstraints c = new GridBagConstraints();		c.gridx=0; c.gridy=0;		apppanel.add(new JLabel(bidLbl), c);		bids = new Integer[4];		bids[0] = 123;		bids[1] = 3645;		bids[2] = 345;		bids[3] = 67;		bidSelector = new JComboBox(bids);		c.gridx=1; c.gridy=0;		apppanel.add(bidSelector, c);		c.gridx=0; c.gridy=1;		apppanel.add(new JLabel(typeLbl), c);		types = new String [] { "creditLine", "creditCard", "personalLoan" };		typeSelector = new JComboBox(types);		c.gridx=1; c.gridy=1;		apppanel.add(typeSelector, c);		c.gridx=0; c.gridy=2;		apppanel.add(new JLabel(fromDateLbl), c);			dateInputFormat = new SimpleDateFormat(datePattern);		fromDateInput = new JFormattedTextField(dateInputFormat);		//fromDateInput.setColumns(10);		fromDateInput.setPreferredSize(new Dimension(100, 40));		c.gridx=1; c.gridy=2;		apppanel.add(fromDateInput, c);				c.gridx=2; c.gridy=2;		apppanel.add(new JLabel(datePattern), c);		c.gridx=0; c.gridy=3;		apppanel.add(new JLabel(toDateLbl), c);		fromDateInput = new JFormattedTextField(dateInputFormat);		fromDateInput.setPreferredSize(new Dimension(100, 40));		c.gridx=1; c.gridy=3;		apppanel.add(fromDateInput, c);				c.gridx=2; c.gridy=3;		apppanel.add(new JLabel(datePattern), c);		cities = new String[3];		cities[0] = "Toronto";		cities[1] = "Moscow";		cities[2] = "New York";		citySelector = new JComboBox(cities);		c.gridx=0; c.gridy=4;		apppanel.add(new JLabel(cityLbl), c);		c.gridx=1; c.gridy=4;		apppanel.add(citySelector, c);				buttonpanel = setupButtonPanel();		c.gridx=0; c.gridy=5;		c.fill=GridBagConstraints.HORIZONTAL;		c.gridwidth=GridBagConstraints.REMAINDER;		c.weightx=1.0; c.weighty=0.0;		apppanel.add(buttonpanel, c);			textpanel = setupTextPanel();		c.fill=GridBagConstraints.BOTH;		c.gridwidth=GridBagConstraints.REMAINDER;		c.weightx=1.0; c.weighty=1.0;		c.gridx=0; c.gridy=6;		apppanel.add(textpanel, c);	}	private JPanel setupTextPanel() {		JPanel panel = new JPanel();		panel.setBorder(BorderFactory.createTitledBorder(txtPanelTitle));		resulttext = new JTextArea(30,40);		resultpane = new JScrollPane(resulttext);		resulttext.setEditable(false);		panel.add(resultpane);		return panel;	}	private JPanel setupButtonPanel() {		JPanel panel = new JPanel();		panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));		for (int i = 0; i < buttoncount; i++ ) {			querybuttons[i] = new JButton("Q" + (i + 1));			panel.add(querybuttons[i]);		}		return panel;	}	private static void createAndShowGUI() {		//Make sure we have nice window decorations.		JFrame.setDefaultLookAndFeelDecorated(true);		a22broken application = new a22broken();	}	public void actionPerformed(ActionEvent event) {		;	}	public static void main(String[] args) {		//Schedule a job for the event-dispatching thread:		//creating and showing this application's GUI.		javax.swing.SwingUtilities.invokeLater(new Runnable() {			public void run() {				createAndShowGUI();			}		});	}}