public HttpServerExample(QWidget parent) {
    server = new HttpServer(this);
    if (!server.start()) {
      QMessageBox.critical(
          this, tr("HTTP Server"), tr("Unable to start the server: ") + server.errorString());
      close();
    }

    QPushButton publishButton = new QPushButton(this);
    publishButton.setText("Publish");
    editor = new QTextEdit(this);

    editor.setPlainText(
        "<h1>Server is up and running!</h1>"
            + "You should be able to view it in a normal web browser."
            + " Try this address: http://localhost:"
            + server.serverPort());

    QGridLayout layout = new QGridLayout(this);
    setLayout(layout);
    layout.addWidget(publishButton);
    layout.addWidget(editor);

    publishButton.clicked.connect(this, "publish()");

    setWindowTitle(tr("Simple HTTP Server"));
    setWindowIcon(new QIcon("classpath:com/trolltech/images/qt-logo.png"));
  }
 void retranslateUi(QDialog AboutTextRecognition) {
   textEdit.setHtml(
       com.trolltech.qt.core.QCoreApplication.translate(
           "AboutTextRecognition",
           "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
               + "<html><head><meta name=\"qrichtext\" content=\"1\" /><title>Image Viewer</title><style type=\"text/css\">\n"
               + "p, li { white-space: pre-wrap; }\n"
               + "</style></head><body style=\" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
               + "<p align=\"center\" style=\" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt; font-weight:600;\"><span style=\" font-size:x-large;\">TextRecognition</span></p>\n"
               + "<p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;\">This application was written to show the various aspects of TextRecognition library.</p></body></html>"));
   okButton.setText(
       com.trolltech.qt.core.QCoreApplication.translate("AboutTextRecognition", "OK"));
 } // retranslateUi
  public void setupUi(QDialog AboutTextRecognition) {
    AboutTextRecognition.setObjectName("AboutTextRecognition");
    AboutTextRecognition.resize(
        new QSize(622, 412).expandedTo(AboutTextRecognition.minimumSizeHint()));
    AboutTextRecognition.setAutoFillBackground(false);
    gridLayout = new QGridLayout(AboutTextRecognition);
    gridLayout.setObjectName("gridLayout");
    gridLayout1 = new QGridLayout();
    gridLayout1.setObjectName("gridLayout1");
    textEdit = new QTextEdit(AboutTextRecognition);
    textEdit.setObjectName("textEdit");
    QPalette palette = new QPalette();
    palette.setColor(
        QPalette.ColorGroup.Active, QPalette.ColorRole.Base, new QColor(224, 223, 227));
    palette.setColor(
        QPalette.ColorGroup.Inactive, QPalette.ColorRole.Base, new QColor(224, 223, 227));
    palette.setColor(
        QPalette.ColorGroup.Disabled, QPalette.ColorRole.Base, new QColor(224, 223, 227));
    textEdit.setPalette(palette);
    textEdit.setAcceptDrops(true);
    textEdit.setFrameShape(com.trolltech.qt.gui.QFrame.Shape.Box);
    textEdit.setUndoRedoEnabled(false);
    textEdit.setReadOnly(true);

    gridLayout1.addWidget(textEdit, 0, 1, 2, 1);

    spacerItem =
        new QSpacerItem(
            20,
            221,
            com.trolltech.qt.gui.QSizePolicy.Policy.Minimum,
            com.trolltech.qt.gui.QSizePolicy.Policy.Expanding);

    gridLayout1.addItem(spacerItem, 1, 0, 1, 1);

    gridLayout.addLayout(gridLayout1, 0, 0, 1, 3);

    spacerItem1 =
        new QSpacerItem(
            40,
            20,
            com.trolltech.qt.gui.QSizePolicy.Policy.Expanding,
            com.trolltech.qt.gui.QSizePolicy.Policy.Minimum);

    gridLayout.addItem(spacerItem1, 1, 0, 1, 1);

    okButton = new QPushButton(AboutTextRecognition);
    okButton.setObjectName("okButton");

    gridLayout.addWidget(okButton, 1, 1, 1, 1);

    spacerItem2 =
        new QSpacerItem(
            40,
            20,
            com.trolltech.qt.gui.QSizePolicy.Policy.Expanding,
            com.trolltech.qt.gui.QSizePolicy.Policy.Minimum);

    gridLayout.addItem(spacerItem2, 1, 2, 1, 1);

    retranslateUi(AboutTextRecognition);
    okButton.clicked.connect(AboutTextRecognition, "accept()");

    AboutTextRecognition.connectSlotsByName();
  } // setupUi
 protected void publish() {
   server.publish(editor.toPlainText());
 }