Example usage for javax.swing SwingConstants HORIZONTAL

List of usage examples for javax.swing SwingConstants HORIZONTAL

Introduction

In this page you can find the example usage for javax.swing SwingConstants HORIZONTAL.

Prototype

int HORIZONTAL

To view the source code for javax.swing SwingConstants HORIZONTAL.

Click Source Link

Document

Horizontal orientation.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int minimum = 0;
    int maximum = 100;
    JProgressBar progress = new JProgressBar(minimum, maximum);
    progress.setOrientation(SwingConstants.HORIZONTAL);
    int newValue = 33;
    progress.setValue(newValue);/*from  ww  w.  jav a2s.c o  m*/

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int minimum = 0;
    int maximum = 100;
    JProgressBar progress = new JProgressBar(minimum, maximum);
    progress.setOrientation(SwingConstants.HORIZONTAL);
    int newValue = 33;
    progress.setValue(newValue);//from   w ww.  j a  v  a 2  s  .  co m
    progress.setString("value");
    System.out.println(progress.getString());
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int minimum = 0;
    int maximum = 100;
    JProgressBar progress = new JProgressBar(minimum, maximum);
    progress.setOrientation(SwingConstants.HORIZONTAL);
    int newValue = 33;
    progress.setValue(newValue);/*  ww  w. j  av  a  2 s  .  c o  m*/

    System.out.println(progress.isStringPainted());
}

From source file:Main.java

public static void setTickMarkers(JSlider slider) {
    final int min = slider.getMinimum();
    final int max = slider.getMaximum();
    final int delta = max - min;

    if (delta > 0) {
        final int sliderSize;
        if (slider.getOrientation() == SwingConstants.HORIZONTAL)
            sliderSize = slider.getPreferredSize().width;
        else//from w ww .  j  a  va 2  s .  c o  m
            sliderSize = slider.getPreferredSize().height;

        // adjust ticks space on slider
        final int majTick = findBestMajTickSpace(sliderSize, delta);

        slider.setMinorTickSpacing(Math.max(1, majTick / 5));
        slider.setMajorTickSpacing(majTick);
        slider.setLabelTable(slider.createStandardLabels(slider.getMajorTickSpacing(), majTick));
    }
}

From source file:Main.java

public static void synchronizeView(final JViewport masterViewport, final JViewport slaveViewport,
        final int orientation) {
    final ChangeListener c1 = new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (masterViewport.getView() == null || slaveViewport.getView() == null) {
                return;
            }//w w  w.  j a  va 2s.  c o m
            if (orientation == SwingConstants.HORIZONTAL) {
                Point v1 = masterViewport.getViewPosition();
                Point v2 = slaveViewport.getViewPosition();
                if (v1.x != v2.x) {
                    slaveViewport.setViewPosition(new Point(v1.x, v2.y));
                }
            } else if (orientation == SwingConstants.VERTICAL) {
                Point v1 = masterViewport.getViewPosition();
                Point v2 = slaveViewport.getViewPosition();
                if (v1.y != v2.y) {
                    slaveViewport.setViewPosition(new Point(v2.x, v1.y));
                }
            }
        }
    };

    masterViewport.addChangeListener(c1);
}

From source file:Main.java

public Main() {
    JPanel sliderPanel = new JPanel();
    sliderPanel.setLayout(new GridLayout(0, 1));
    for (int i = 0; i < slider.length; i++) {
        labels[i] = new Label(colorNames[i] + 255);
        sliderPanel.add(labels[i]);//  www .  j  a  v  a2s  . co  m
        slider[i] = new JSlider(SwingConstants.HORIZONTAL, 0, 255, 255);
        slider[i].setMinorTickSpacing(10);
        slider[i].setMajorTickSpacing(50);
        slider[i].setPaintTicks(true);
        slider[i].setPaintLabels(true);
        sliderPanel.add(slider[i]);
    }
    lb = new Label("Colour");
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setModal(true);
    dialog.add(sliderPanel, BorderLayout.CENTER);
    dialog.add(lb, BorderLayout.SOUTH);
    dialog.pack();
    dialog.setLocation(200, 200);
    dialog.setTitle("Colour Dialog");
    dialog.setVisible(true);
}

From source file:Main.java

protected void createComponents() {
    if (orientation == SwingConstants.VERTICAL) {
        setLayout(new GridLayout(2, 1));
        incrementButton = new BasicArrowButton(SwingConstants.NORTH);
        decrementButton = new BasicArrowButton(SwingConstants.SOUTH);
        add(incrementButton);/*w w  w  .j a  va 2s  .com*/
        add(decrementButton);
    } else if (orientation == SwingConstants.HORIZONTAL) {
        setLayout(new GridLayout(1, 2));
        incrementButton = new BasicArrowButton(SwingConstants.EAST);
        decrementButton = new BasicArrowButton(SwingConstants.WEST);
        add(decrementButton);
        add(incrementButton);
    }
}

From source file:Utils.java

public static BufferedImage createGradientMask(int width, int height, int orientation) {
    // algorithm derived from Romain Guy's blog
    BufferedImage gradient = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = gradient.createGraphics();
    GradientPaint paint = new GradientPaint(0.0f, 0.0f, new Color(1.0f, 1.0f, 1.0f, 1.0f),
            orientation == SwingConstants.HORIZONTAL ? width : 0.0f,
            orientation == SwingConstants.VERTICAL ? height : 0.0f, new Color(1.0f, 1.0f, 1.0f, 0.0f));
    g.setPaint(paint);/*  w  w  w.j  a  v  a2s  .  com*/
    g.fill(new Rectangle2D.Double(0, 0, width, height));

    g.dispose();
    gradient.flush();

    return gradient;
}

From source file:Main.java

private JPanel create() {
    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);/*from w  ww.j  a  va2s. c  om*/
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);
    GroupLayout.ParallelGroup parallel = layout.createParallelGroup();
    layout.setHorizontalGroup(layout.createSequentialGroup().addGroup(parallel));
    GroupLayout.SequentialGroup sequential = layout.createSequentialGroup();
    layout.setVerticalGroup(sequential);
    for (int i = 0; i < NUM; i++) {
        labels[i] = new JLabel(String.valueOf(i + 1), JLabel.RIGHT);
        fields[i] = new JTextField(String.valueOf("" + (i + 1)));
        labels[i].setLabelFor(fields[i]);
        parallel.addGroup(layout.createSequentialGroup().addComponent(labels[i]).addComponent(fields[i]));
        sequential.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(labels[i])
                .addComponent(fields[i]));
        layout.linkSize(SwingConstants.HORIZONTAL, labels[i], labels[0]);
    }
    return panel;
}

From source file:com.mirth.connect.client.ui.attachments.IdentityAttachmentDialog.java

private void initComponents() {
    setBackground(UIConstants.BACKGROUND_COLOR);
    getContentPane().setBackground(getBackground());

    propertiesPanel = new JPanel();
    propertiesPanel.setBackground(getBackground());
    propertiesPanel.setBorder(BorderFactory.createTitledBorder("Properties"));

    mimeTypeLabel = new JLabel("MIME Type:");
    mimeTypeField = new JTextField();

    separator = new JSeparator(SwingConstants.HORIZONTAL);

    closeButton = new JButton("Close");
    closeButton.addActionListener(new ActionListener() {
        @Override//from w ww. ja v a2s  .c o  m
        public void actionPerformed(ActionEvent evt) {
            close();
        }
    });
}