List of usage examples for javax.swing JTextField getHorizontalVisibility
@BeanProperty(bound = false)
public BoundedRangeModel getHorizontalVisibility()
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); 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);//ww w.j ava 2 s . c o m panel.add(textField); panel.add(scrollBar); frame.add(panel, BorderLayout.NORTH); frame.setSize(300, 100); 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);/* w w w . jav a 2s . 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:Main.java
public static void main(String args[]) { 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 w w . j a v a 2 s . c om panel.add(textField); panel.add(scrollBar); textField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Text: " + textField.getText()); } }); JFrame frame = new JFrame("Text Slider"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(panel, BorderLayout.NORTH); frame.setSize(300, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Label Focus Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); JTextField textField = new JTextField(); label.setLabelFor(textField);/*from www.ja va 2 s. co m*/ panel.add(label, BorderLayout.WEST); panel.add(textField, BorderLayout.CENTER); frame.add(panel, BorderLayout.NORTH); frame.setSize(250, 150); frame.setVisible(true); textField.setText("Loooooooooooooooooooooooooooooooooooooooooooooooooooooooong"); BoundedRangeModel model = textField.getHorizontalVisibility(); int extent = model.getExtent(); textField.setScrollOffset(extent); System.out.println("extent:" + extent); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Offset Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new BorderLayout()); final JTextField textField = new JTextField(); panel.add(textField, BorderLayout.CENTER); frame.add(panel, BorderLayout.NORTH); JButton button = new JButton("Get Offset"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("Offset: " + textField.getScrollOffset()); System.out.println("Visibility: " + textField.getHorizontalVisibility()); BoundedRangeModel model = textField.getHorizontalVisibility(); int extent = model.getExtent(); textField.setScrollOffset(extent); }// w ww .j a v a 2 s. c o m }; button.addActionListener(actionListener); frame.add(button, BorderLayout.SOUTH); frame.setSize(250, 150); frame.setVisible(true); }
From source file:OffsetSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Offset Example"); Container content = frame.getContentPane(); JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); final JTextField textField = new JTextField(); label.setLabelFor(textField);/*from w w w . j av a 2 s. c o m*/ panel.add(label, BorderLayout.WEST); panel.add(textField, BorderLayout.CENTER); content.add(panel, BorderLayout.NORTH); JButton button = new JButton("Get Offset"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("Offset: " + textField.getScrollOffset()); System.out.println("Visibility: " + textField.getHorizontalVisibility()); BoundedRangeModel model = textField.getHorizontalVisibility(); int extent = model.getExtent(); textField.setScrollOffset(extent); } }; button.addActionListener(actionListener); content.add(button, BorderLayout.SOUTH); frame.setSize(250, 150); frame.setVisible(true); }