public void run() {
      try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      } catch (Exception e) {
        e.printStackTrace();
      }

      String l = JOptionPane.showInputDialog(null, "What upper bound will we use?");
      limitCheck(l);

      while (!l.matches("\\d+")) {
        l = JOptionPane.showInputDialog(null, "What upper bound will we use?");

        limitCheck(l);
      }

      limit = Integer.parseInt(l);

      Toolkit tk = Toolkit.getDefaultToolkit();
      Dimension screenSize = tk.getScreenSize();

      EncodingFrame = new MyFrame(screenSize.width / 2, screenSize.height / 2);
      EncodingFrame.setTitle("Number Encoder");
      Container EncodingFramePane = EncodingFrame.getContentPane();
      EncodingFramePane.setLayout(new BoxLayout(EncodingFramePane, BoxLayout.Y_AXIS));

      EncoderVisualizer = new LinearVisualizer(limit);

      JPanel ControlPanel = new JPanel();
      ControlPanel.setLayout(new BoxLayout(ControlPanel, BoxLayout.X_AXIS));
      ControlPanel.setMaximumSize(new Dimension(screenSize.width, 100));
      JLabel InputLabel = new JLabel("Enter number: ");
      InputField = new JTextField(EncoderVisualizer.getEncoderLimit());
      JButton DrawCumulativeButton = new JButton("Cumulative Draw");
      DrawCumulativeButton.addActionListener(new DrawActionListener(DrawCumulativeButton, true));
      JButton OverdrawButton = new JButton("Overdraw");
      OverdrawButton.addActionListener(new DrawActionListener(OverdrawButton, false));
      ControlPanel.add(InputLabel);
      ControlPanel.add(InputField);
      ControlPanel.add(DrawCumulativeButton);
      ControlPanel.add(OverdrawButton);

      EncodingFramePane.add(ControlPanel);
      EncodingFramePane.add(EncoderVisualizer);
      EncodingFramePane.doLayout();
    }
    void validate() {
      Container parent =
          SwingUtilities.getAncestorOfClass(CollapsiblePaneContainer.class, JXCollapsiblePane.this);
      if (parent != null) {
        parent = ((CollapsiblePaneContainer) parent).getValidatingContainer();
      } else {
        parent = getParent();
      }

      if (parent != null) {
        if (parent instanceof JComponent) {
          ((JComponent) parent).revalidate();
        } else {
          parent.invalidate();
        }
        parent.doLayout();
        parent.repaint();
      }
    }
  private void init(EditorPatternButton imgBtn, boolean exact, float similarity, int numMatches) {
    setTitle(_I("winPatternSettings"));
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    _imgBtn = imgBtn;
    Point pos = imgBtn.getLocationOnScreen();
    Debug.log(4, "pattern window: " + pos);
    setLocation(pos.x + imgBtn.getWidth(), pos.y);

    takeScreenshot();
    Container c = getContentPane();
    c.setLayout(new BorderLayout());

    tabPane = new JTabbedPane();
    tabPane.setPreferredSize(new Dimension(790, 700));
    msgApplied = new JLabel[tabMax];

    msgApplied[tabSequence] = new JLabel("...");
    paneNaming = new PatternPaneNaming(_imgBtn, msgApplied[tabSequence++]);
    tabPane.addTab(_I("tabNaming"), paneNaming);

    msgApplied[tabSequence] = new JLabel("...");
    panePreview = createPreviewPanel();
    tabSequence++;
    tabPane.addTab(_I("tabMatchingPreview"), panePreview);

    msgApplied[tabSequence] = new JLabel("...");
    paneTarget = createTargetPanel();
    tabSequence++;
    tabPane.addTab(_I("tabTargetOffset"), paneTarget);

    c.add(tabPane, BorderLayout.CENTER);
    c.add(createButtons(), BorderLayout.SOUTH);
    c.doLayout();
    pack();
    try {
      _screenshot.setParameters(_imgBtn.getFilename(), exact, similarity, numMatches);
    } catch (Exception e) {
      Debug.error(me + "Problem while setting up pattern pane\n%s", e.getMessage());
    }
    setDirty(false);
    setVisible(true);
  }
  public CKSyntaxPaneTest() {
    JFrame f = new JFrame("Party"); // CKSytaxPaneTest.class.getName());
    final Container c = f.getContentPane();
    c.setLayout(new BorderLayout());

    // DefaultSyntaxKit.initKit();

    final JEditorPane codeEditor = new JEditorPane();
    JScrollPane scrPane = new JScrollPane(codeEditor);
    // codeEditor.setContentType("text/python");
    codeEditor.setEditorKit(new PythonSyntaxKit());
    // codeEditor.setText("public static void main(String[] args) {\n}");

    // toolbar is part of the editor kit--ausome!
    JToolBar jToolBar1 = new javax.swing.JToolBar();
    jToolBar1.setRollover(true);
    jToolBar1.setFocusable(false);

    EditorKit kit = codeEditor.getEditorKit();
    if (kit instanceof DefaultSyntaxKit) {
      DefaultSyntaxKit defaultSyntaxKit = (DefaultSyntaxKit) kit;
      defaultSyntaxKit.addToolBarActions(codeEditor, jToolBar1);
    }
    jToolBar1.validate();
    c.add(jToolBar1, BorderLayout.PAGE_START);

    c.add(scrPane, BorderLayout.CENTER);
    // c.add(codeEditor, BorderLayout.CENTER);

    // create console for output?
    JTextPane tpane = new JTextPane();
    c.add(tpane, BorderLayout.LINE_START);
    c.doLayout();

    f.setSize(800, 600);
    f.setVisible(true);
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  }
  protected void validateTree() {
    doLayout();

    for (int i = 0; i < nChildren; i++) children[i].validate();
  }
 @Override
 public void layoutEnd() {
   container.doLayout();
   redraw();
 }
  /**
   * This method is used at the end of a drag session to place the frame in either its original
   * parent as a docked JToolBar or in its floating frame.
   *
   * @param position The position of the mouse cursor relative to the JToolBar.
   * @param origin The screen position of the JToolBar before the drag session started.
   */
  protected void floatAt(Point position, Point origin) {
    Point p = new Point(position);
    int aoc = areaOfClick(origParent, SwingUtilities.convertPoint(toolBar, p, origParent));

    Container oldParent = toolBar.getParent();

    oldParent.remove(toolBar);
    oldParent.doLayout();
    oldParent.repaint();

    Container newParent;

    if (aoc == -1) newParent = ((RootPaneContainer) floatFrame).getContentPane();
    else {
      floatFrame.hide();
      newParent = origParent;
    }

    String constraint;
    switch (aoc) {
      case SwingConstants.EAST:
        constraint = BorderLayout.EAST;
        break;
      case SwingConstants.NORTH:
        constraint = BorderLayout.NORTH;
        break;
      case SwingConstants.SOUTH:
        constraint = BorderLayout.SOUTH;
        break;
      case SwingConstants.WEST:
        constraint = BorderLayout.WEST;
        break;
      default:
        constraint = BorderLayout.CENTER;
        break;
    }

    int newOrientation = SwingConstants.HORIZONTAL;
    if ((aoc != -1) && ((aoc == SwingConstants.EAST) || (aoc == SwingConstants.WEST)))
      newOrientation = SwingConstants.VERTICAL;

    if (aoc != -1) {
      constraintBeforeFloating = constraint;
      lastGoodOrientation = newOrientation;
    }

    newParent.add(toolBar, constraint);

    setFloating(aoc == -1, null);
    toolBar.setOrientation(newOrientation);

    Insets insets = floatFrame.getInsets();
    Dimension dims = toolBar.getPreferredSize();
    p = dragWindow.getOffset();
    setFloatingLocation(
        (position.x + origin.x) - p.x - ((insets.left + insets.right) / 2),
        (position.y + origin.y) - p.y - ((insets.top + insets.bottom) / 2));

    if (aoc == -1) {
      floatFrame.pack();
      floatFrame.setSize(
          dims.width + insets.left + insets.right, dims.height + insets.top + insets.bottom);
      floatFrame.show();
    }

    newParent.invalidate();
    newParent.validate();
    newParent.repaint();
  }