Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BorderLayout;
- import java.awt.EventQueue;
- import java.awt.event.AdjustmentEvent;
- import java.awt.event.AdjustmentListener;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JScrollBar;
- import javax.swing.border.EmptyBorder;
- @SuppressWarnings("serial")
- public class Posuvnik extends JFrame {
- private JPanel contentPane;
- private JLabel text;
- private JScrollBar posuvnik;
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- Posuvnik frame = new Posuvnik();
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- public Posuvnik() {
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 450, 300);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- contentPane.setLayout(new BorderLayout(0, 0));
- setContentPane(contentPane);
- posuvnik = new JScrollBar();
- /* ------------------------------------------------------------------------------------- */
- posuvnik.addAdjustmentListener(new AdjustmentListener() {
- public void adjustmentValueChanged(AdjustmentEvent arg0) {
- text.setText( String.valueOf( posuvnik.getValue() ) );
- }
- });
- /* ------------------------------------------------------------------------------------- */
- posuvnik.setOrientation(JScrollBar.HORIZONTAL);
- contentPane.add(posuvnik, BorderLayout.NORTH);
- text = new JLabel("New label");
- contentPane.add(text, BorderLayout.SOUTH);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment