title: component must be showing on the screen to determine its location when changing JCOMBOX
body: <p>I am receiving this error when i change items in the Jcombobox, nothing breaks it just shows this error, is there anyway to just throw it so it doesn't show up. everything still works fine, but if you wish to have a look at the code. i will post below.<br>
  <br>
  Error message:<br></p>
  
  <pre><code>java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
  at java.awt.Component.getLocationOnScreen_NoTreeLock(Component.java:2056)
  at java.awt.Component.getLocationOnScreen(Component.java:2030)
  at sun.lwawt.macosx.CAccessibility$23.call(CAccessibility.java:395)
  at sun.lwawt.macosx.CAccessibility$23.call(CAccessibility.java:393)
  at sun.lwawt.macosx.LWCToolkit$CallableWrapper.run(LWCToolkit.java:538)
  at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
  </code></pre>
  
  <p>And my code which i don't know which section to show so its all their. <br></p>
  
  <pre><code>import javax.swing.*;
  
  import java.awt.Dialog.ModalityType;
  import java.awt.event.*;
  import java.awt.*;
  import java.io.BufferedReader;
  import java.io.File;
  import java.io.FileReader;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Date;
  
  public class TouchOn extends JDialog {
  private JPanel mainPanel;
  
  
  public ArrayList Reader(String Txtfile) {
      try {
  
      ArrayList&lt;String&gt; Trains = new ArrayList&lt;String&gt;();
      int count = 0;
      String testing = "";
      File file = new File(Txtfile);
      FileReader fileReader = new FileReader(file);
      BufferedReader bufferedReader = new BufferedReader(fileReader);
      StringBuffer stringBuffer = new StringBuffer();
      String line;
      while ((line = bufferedReader.readLine()) != null) 
      {
          stringBuffer.append(line);
          count += count;
          if(!line.contains("*")){
              Trains.add(line + "\n");
          }
          stringBuffer.append("\n");
  
  
  
      }
      fileReader.close();
      //Arrays.asList(Trains).stream().forEach(s -&gt; System.out.println(s));
      return Trains;
  } catch (IOException e) {
      e.printStackTrace();
  }
  //return toString();
  return null;
  
  
  }
  
  
  public TouchOn()
  {
      setPanels();
  
      setModalityType(ModalityType.APPLICATION_MODAL);
      setSize(400, 300);
      setVisible(true);
  }
  public void setPanels()
  {
      mainPanel = new JPanel(new GridLayout(0, 2));
      JPanel containerPanel = new JPanel(new GridLayout(0, 1));
      JLabel startDay = new JLabel("Day:");
      JTextField sDay = new JTextField();
  
      JLabel startMonth = new JLabel("Month:");
      JTextField sMonth = new JTextField();
  
      JLabel startYear = new JLabel("Year:");
      JTextField sYear = new JTextField("2015");
      String trainline = "";
  
      JLabel touchOnTimehr = new JLabel("Time Hour: ");
      JLabel touchOnTimem = new JLabel("Time Minute:");
      JLabel station = new JLabel("Station: ");
  
  
      JTextField touchOnTimeFieldhour = new JTextField();
      JTextField touchOnTimeFieldminute = new JTextField();
  
      JPanel lowerPanel = new JPanel(new FlowLayout());
      ArrayList&lt;String&gt; stations = Reader("TrainLines.txt");
      JComboBox&lt;String&gt; cb = new JComboBox&lt;&gt;(stations.toArray(new String[stations.size()]));
      JRadioButton belgrave = new JRadioButton("Belgrave Line");
      belgrave.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e){
  
              }
      });
      JRadioButton glenwaverly = new JRadioButton("Glen Waverly Line");
      glenwaverly.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e){
  
          }
      });
      ButtonGroup bG = new ButtonGroup();
      JButton apply = new JButton("Touch on");
      JButton cancel = new JButton("Cancel");
      cancel.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e){
              dispose();
          }
      });
      apply.addActionListener(new ActionListener()
      {
          public void actionPerformed(ActionEvent e)
          {
  
  
  String timestamp = new java.text.SimpleDateFormat("dd/MM/yyyy").format(new Date());
              String day = sDay.getText();
              String month = sMonth.getText();
              String year = sYear.getText();
              String hour = touchOnTimeFieldhour.getText();
              String minute = touchOnTimeFieldminute.getText();
              if(belgrave.isSelected()){
                  String trainline = belgrave.getText();
              }
              if(glenwaverly.isSelected()){
                  String trainline = glenwaverly.getText();
              }
              System.out.println(trainline);
          }
      });
  
  
  
      cb.setVisible(true);
      bG.add(belgrave);
      bG.add(glenwaverly);
      mainPanel.add(startDay);
      mainPanel.add(sDay);
      mainPanel.add(startMonth);
      mainPanel.add(sMonth);
      mainPanel.add(startYear);
      mainPanel.add(sYear);
      mainPanel.add(touchOnTimehr);
      mainPanel.add(touchOnTimeFieldhour);
      mainPanel.add(touchOnTimem);
      mainPanel.add(touchOnTimeFieldminute);
      mainPanel.add(belgrave);
      mainPanel.add(glenwaverly);
      mainPanel.add(station);
      mainPanel.add(new JLabel());
      mainPanel.add(cb);
      lowerPanel.add(apply);
      lowerPanel.add(cancel);
      touchOnTimeFieldhour.setSize(10,10);
      containerPanel.add(mainPanel);
      containerPanel.add(lowerPanel);
  
      add(containerPanel);
  }
  
  }
  </code></pre>