List of usage examples for javax.swing BoxLayout BoxLayout
@ConstructorProperties({ "target", "axis" }) public BoxLayout(Container target, int axis)
From source file:JFormattedTextFieldDateInputSampleDateFormatSHORT.java
public static void main(String args[]) { JFrame frame = new JFrame("Date/Time Input"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label;/* w w w . java2 s . com*/ JFormattedTextField input; JPanel panel; BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS); frame.setLayout(layout); Format shortDate = DateFormat.getDateInstance(DateFormat.SHORT); label = new JLabel("Short date:"); input = new JFormattedTextField(shortDate); input.setValue(new Date()); input.setColumns(20); panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panel.add(label); panel.add(input); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) { JFrame frame = new JFrame("Sharing Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = frame.getContentPane(); JTextArea textarea1 = new JTextArea(); Document document = textarea1.getDocument(); JTextArea textarea2 = new JTextArea(document); JTextArea textarea3 = new JTextArea(document); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); content.add(new JScrollPane(textarea1)); content.add(new JScrollPane(textarea2)); content.add(new JScrollPane(textarea3)); frame.setSize(300, 400);/*from w w w . j ava 2s . c om*/ frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("Number Input"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Font font = new Font("SansSerif", Font.BOLD, 16); JLabel label;//from w w w. j a v a2 s . c o m JFormattedTextField input; JPanel panel; BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS); frame.setLayout(layout); Format number = NumberFormat.getNumberInstance(Locale.FRENCH); label = new JLabel("French Number:"); input = new JFormattedTextField(number); input.setValue(2424.50); input.setColumns(20); input.setFont(font); panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panel.add(label); panel.add(input); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("Number Input"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Font font = new Font("SansSerif", Font.BOLD, 16); JLabel label;/*from ww w. j av a 2s .c o m*/ JFormattedTextField input; JPanel panel; BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS); frame.setLayout(layout); Format integer = NumberFormat.getIntegerInstance(Locale.ITALIAN); label = new JLabel("Italian integer:"); input = new JFormattedTextField(integer); input.setValue(2424.50); input.setColumns(20); input.setFont(font); panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panel.add(label); panel.add(input); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:JFormattedTextFieldDateInputSampleELocaleFRENCH.java
public static void main(String args[]) { JFrame frame = new JFrame("Date/Time Input"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label;/*from w ww .j a v a 2 s. c om*/ JFormattedTextField input; JPanel panel; BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS); frame.setLayout(layout); Format dayOfWeek = new SimpleDateFormat("E", Locale.FRENCH); label = new JLabel("French day of week:"); input = new JFormattedTextField(dayOfWeek); input.setValue(new Date()); input.setColumns(20); panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panel.add(label); panel.add(input); frame.add(panel); frame.add(new JTextField()); frame.pack(); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("Number Input"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Font font = new Font("SansSerif", Font.BOLD, 16); JLabel label;//from w w w . j ava 2 s.co m JFormattedTextField input; JPanel panel; BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS); frame.setLayout(layout); Format currency = NumberFormat.getCurrencyInstance(Locale.UK); label = new JLabel("UK Currency:"); input = new JFormattedTextField(currency); input.setValue(2424.50); input.setColumns(20); input.setFont(font); panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panel.add(label); panel.add(input); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:JFormattedTextFieldDateInputSampleDateFormatFULLLocaleUS.java
public static void main(String args[]) { JFrame frame = new JFrame("Date/Time Input"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label;/*from w ww.java 2 s . co m*/ JFormattedTextField input; JPanel panel; BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS); frame.setLayout(layout); Format fullUSDate = DateFormat.getDateInstance(DateFormat.FULL, Locale.US); label = new JLabel("Full US date:"); input = new JFormattedTextField(fullUSDate); input.setValue(new Date()); input.setColumns(20); panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panel.add(label); panel.add(input); frame.add(panel); frame.add(new JTextField()); frame.pack(); frame.setVisible(true); }
From source file:TextSlider.java
public static void main(String args[]) { JFrame frame = new JFrame("Text Slider"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JTextField textField = new JTextField(); JScrollBar scrollBar = new JScrollBar(JScrollBar.HORIZONTAL); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); BoundedRangeModel brm = textField.getHorizontalVisibility(); scrollBar.setModel(brm);//from w ww . j av a 2 s .c o m panel.add(textField); panel.add(scrollBar); final TextSlider ts = new TextSlider(); textField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Text: " + textField.getText()); } }); frame.add(panel, BorderLayout.NORTH); frame.setSize(300, 100); frame.setVisible(true); }
From source file:PassiveTextField1.java
public static void main(String[] args) { JFrame f = new JFrame("Passive Text Field"); f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS)); final JTextField ptf = new JTextField(32); JTextField tf = new JTextField(32); JPanel p = new JPanel(); JButton b = new JButton("OK"); p.add(b);// w w w.j av a 2 s .c o m f.getContentPane().add(ptf); f.getContentPane().add(tf); f.getContentPane().add(p); Keymap map = ptf.getKeymap(); // Gets the shared map KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); map.removeKeyStrokeBinding(key); ActionListener l = new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.println("Action event from a text field"); } }; ptf.addActionListener(l); tf.addActionListener(l); // Make the button the default button f.getRootPane().setDefaultButton(b); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.println("Content of text field: <" + ptf.getText() + ">"); } }); f.pack(); f.setVisible(true); }
From source file:NumberInputSampleLocaleUK.java
public static void main(String args[]) { JFrame frame = new JFrame("Number Input"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Font font = new Font("SansSerif", Font.BOLD, 16); JLabel label;//from ww w.j av a 2 s . c om JFormattedTextField input; JPanel panel; BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS); frame.setLayout(layout); Format currency = NumberFormat.getCurrencyInstance(Locale.UK); label = new JLabel("UK Currency:"); input = new JFormattedTextField(currency); input.setValue(2424.50); input.setColumns(20); input.setFont(font); panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panel.add(label); panel.add(input); frame.add(panel); frame.add(new JTextField()); frame.pack(); frame.setVisible(true); }