title: How to set JLabel in a specific area in JFrame?
body: <p><img src="https://i.stack.imgur.com/Bt4qq.jpg" alt="enter image description here"></p>
  
  <p>I am trying to make a desktop application in Java Swing. I am trying to create image slider in frame and I got it. Now problem in  that I want to set the specific area for <code>imagelabel</code> in that frame. How can I do this?  I want to set <code>imagelabel</code> in left side. I am posting my snapshot which I am getting after running my program.</p>
  
  <p>Here is my code</p>
  
  <p><img src="https://i.stack.imgur.com/BbA4v.jpg" alt="here i  am getting like this"></p>
  
  <pre><code>public class ImageSlider extends JPanel implements ActionListener {
  
      private static final int MAX = 20;
      private static final Font sans = new Font("SansSerif", Font.PLAIN, 16);
      private static final Border border =
          BorderFactory.createMatteBorder(4, 16, 4, 16, Color.BLUE);
  
      private List&lt;String&gt; list = new ArrayList&lt;String&gt;(MAX);
      private List&lt;ImageIcon&gt; cache = new ArrayList&lt;ImageIcon&gt;(MAX);
      private JLabel imageLabel = new JLabel();
       //label = new JLabel( image, SwingConstants.CENTER);
      private JButton prevButton = new JButton();
      private JButton nextButton = new JButton();
      private JComboBox favorites;
  
      public ImageSlider() {
          this.setLayout(new BorderLayout());
  
          list.add("c.jpg");
          list.add("a0.png");
          list.add("yellow.png");
           list.add("a0.png");
           list.add("c.jpg");
  
          for (int i = 0; i &lt; list.size(); i++) cache.add(i, null);
   ImageIcon image = new ImageIcon("E:\\SOFTWARE\\TrainPIS\\res\\drawable\\a0.png");
          JLabel titleLabel = new JLabel(image, SwingConstants.CENTER);
         // titleLabel.setText("ImageSlider");
          titleLabel.setHorizontalAlignment(JLabel.CENTER);
          titleLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 24));
          titleLabel.setBorder(border);
          this.add(titleLabel, BorderLayout.NORTH);
  
          imageLabel.setIcon(getImage(0));
          imageLabel.setAlignmentX(LEFT_ALIGNMENT);
          imageLabel.setHorizontalAlignment(JLabel.CENTER);
          imageLabel.setBorder(border);
          this.add(imageLabel, BorderLayout.CENTER);
  
          favorites = new JComboBox(
              list.toArray(new String[list.size()]));
          favorites.setActionCommand("favs");
          favorites.addActionListener(this);
  
          prevButton.setText("\u22b2Prev");
          prevButton.setFont(sans);
          prevButton.setActionCommand("prev");
          prevButton.addActionListener(this);
  
          nextButton.setText("Next\u22b3");
          nextButton.setFont(sans);
          nextButton.setActionCommand("next");
          nextButton.addActionListener(this);
  
          JPanel controlPanel = new JPanel();
          controlPanel.add(prevButton);
          controlPanel.add(favorites);
          controlPanel.add(nextButton);
          controlPanel.setBorder(border);
          this.add(controlPanel, BorderLayout.SOUTH);
      }
  
      public void actionPerformed(ActionEvent ae) {
          String cmd = ae.getActionCommand();
          if ("favs".equals(cmd)) {
              int index = favorites.getSelectedIndex();
              ImageIcon image = getImage(index);
              imageLabel.setIcon(image);
              if (image != null) imageLabel.setText("");
              else imageLabel.setText("Image not available.");
          }
          if ("prev".equals(cmd)) {
              int index = favorites.getSelectedIndex() - 1;
              if (index &lt; 0) index = list.size() - 1;
              favorites.setSelectedIndex(index);
          }
          if ("next".equals(cmd)) {
              int index = favorites.getSelectedIndex() + 1;
              if (index &gt; list.size() - 1) index = 0;
              favorites.setSelectedIndex(index);
          }
      }
  
      public JButton getDefault() { return nextButton; }
  
      // Return the (possibly cached) image having the given index.
      private ImageIcon getImage(int index) {
          ImageIcon image = cache.get(index);
          if (image != null) return image;
          String name = "/images/" + list.get(index);
          URL url = ImageSlider.class.getResource(name);
          if (url != null) {
              image = new ImageIcon(url);
          }
          cache.set(index, image);
          return image;
      }
  
      public static void main(String[] args) {
          EventQueue.invokeLater(new Runnable() {
              public void run() {
                  JFrame frame = new JFrame();
                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  ImageSlider go = new ImageSlider();
                  frame.add(go);
                  frame.setTitle("ImageSlider");
                //  frame.setSize(400, 300);
                        frame.setExtendedState(JFrame.MAXIMIZED_BOTH); 
                        frame.setUndecorated(true);
                  frame.setVisible(true);
                  go.getDefault().requestFocusInWindow();
              }
          });
      }
  }
  </code></pre>
  
  <p>How can I achieve my goal?</p>