public static void main(String[] args) {
   System.gc();
   // Schedule a job for the event-dispatching thread:
   // creating and showing this application's GUI.
   javax.swing.SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           createAndShowGUI();
         }
       });
 } // end of main
Пример #2
0
 /** * 设置视频信息 */
 public static void SetVideoDetail(
     String s_title, String s_time, String s_addTime, String s_url, final String s_imgUrl) {
   title.setText(s_title);
   time.setText(s_time);
   addTime.setText(s_addTime);
   pageUrl.setText(s_url);
   crackVideo.setText("");
   fileSize.setText("");
   /** 此处进行图片渲染操作 */
   javax.swing.SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           image.setVisible(false);
           CrawlerUtil crawlerUtil = new CrawlerUtil();
           try {
             crawlerUtil.clientCreate("http", "img2.t6k.co", "http://ch.u6p.co/v.php?next=watch");
             image.loadImage(s_imgUrl, crawlerUtil);
             image.setVisible(true);
           } catch (Exception e) {
             e.printStackTrace();
             /** 加载图片失败用默认的图片代替 */
           }
         }
       });
   /** 进行下载地址破解 */
 }
Пример #3
0
 /** *********************************************************************** */
 public static void main(String[] args) { // called when the program starts
   javax.swing.SwingUtilities.invokeLater(
       new Runnable() { // Start the createAndShowGUI method in a separate thread
         public void run() {
           createAndShowGUI();
         }
       });
 }
Пример #4
0
 public static void main(String[] args) {
   javax.swing.SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           createAndShowGUI();
         }
       });
 }
Пример #5
0
 public static void main(String[] args) {
   javax.swing.SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           frame = new JFrame("Progra III");
           components();
           show();
         }
       });
 }
Пример #6
0
 public static void main(String[] args) {
   // Schedule a job for the event-dispatching thread:
   // creating and showing this application's GUI.
   javax.swing.SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           new DefaultDnDSupport();
         }
       });
 }
 public SwingApp(String name) {
   super(name);
   setResizable(false);
   setPreferredSize(new Dimension(300, 400));
   javax.swing.SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           createAndShowGUI();
         }
       });
 }
Пример #8
0
  public static void main(String[] args) {
    EpubUtils.EPUB = new File(args[0]);
    EpubUtils.EPUB_FOLDER = args[1];
    EpubUtils.prepare("splitter", "split");

    javax.swing.SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            createAndShowGUI();
          }
        });
  }
Пример #9
0
  @Override
  public void mouseDragged(MouseEvent e) {
    if (javax.swing.SwingUtilities.isRightMouseButton(e)) {
      transX += (double) (e.getX() - preMousePoint.getX()) / scale;
      transY += (double) (e.getY() - preMousePoint.getY()) / scale;

      preMousePoint = e.getPoint();
      updateAffineTransform();
      repaint();
    } else if (javax.swing.SwingUtilities.isLeftMouseButton(e)) {
      rotateAngle += ((double) e.getX() - preMousePoint.getX()) / 100.0;
      preMousePoint = e.getPoint();
      updateAffineTransform();
      repaint();
    }

    // Gets the value of the current logical coordinates of the mouse
    try {
      affineTransform.inverseTransform(e.getPoint(), currentMousePointLogic);
    } catch (Exception ex) {
    }
  }
Пример #10
0
  public static void main(String[] args) {
    // Schedule a job for the event-dispatching thread:
    // creating and showing this application's GUI.

    javax.swing.SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            BearSweeper frame = new BearSweeper();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
          }
        });
  }
Пример #11
0
  public YarharMain() {
    super("YarHar!");
    int screenX = 1024;
    int screenY = 800;
    this.setSize(screenX, screenY);
    this.setJMenuBar(new YarharMenuBar(this));

    this.addWindowListener(this);
    this.addWindowFocusListener(this);

    this.add(borderPanel);

    toolsPanel = new ToolsPanel(this);
    //    borderPanel.add(toolsPanel, BorderLayout.NORTH);

    spriteLibPanel = new SpriteLibraryPanel(this);
    layersPanel = new LayersPanel(this);
    editorPanel = new EditorPanel(this);
    sidePane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, layersPanel, spriteLibPanel);
    sidePane.setContinuousLayout(true);
    sidePane.setResizeWeight(0.5);

    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sidePane, editorPanel);
    splitPane.setContinuousLayout(true);
    splitPane.setResizeWeight(0.0);

    borderPanel.add(splitPane, BorderLayout.CENTER);

    footer = new StatusFooterPanel(this);
    borderPanel.add(footer, BorderLayout.SOUTH);

    // finishing touches on Game window
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setVisible(true);

    config = YarharConfig.load();

    System.err.println("Game Window successfully created!!!");

    editorPanel.start();

    // Swing can't correctly place divider locations on startup. So we must
    // set their locations later when everything else is initialized.
    javax.swing.SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            setDividerLocations();
          }
        });
  }
Пример #12
0
 private static void javabughack() throws InterruptedException {
   /* Work around a stupid deadlock bug in AWT. */
   try {
     javax.swing.SwingUtilities.invokeAndWait(
         new Runnable() {
           public void run() {
             PrintStream bitbucket = new PrintStream(new ByteArrayOutputStream());
             bitbucket.print(LoginScreen.textf);
             bitbucket.print(LoginScreen.textfs);
           }
         });
   } catch (java.lang.reflect.InvocationTargetException e) {
     /* Oh, how I love Swing! */
     throw (new Error(e));
   }
   /* Work around another deadl bug in Sun's JNLP client. */
   javax.imageio.spi.IIORegistry.getDefaultInstance();
   try {
     netxsurgery();
   } catch (Exception e) {
   }
 }
Пример #13
0
  public static void main(String[] arguments) {
    // Schedule a job for the event dispatch thread:
    // creating and showing this application's GUI.

    try {
      UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (UnsupportedLookAndFeelException ex) {
      ex.printStackTrace();
    } catch (IllegalAccessException ex) {
      ex.printStackTrace();
    } catch (InstantiationException ex) {
      ex.printStackTrace();
    } catch (ClassNotFoundException ex) {
      ex.printStackTrace();
    }

    javax.swing.SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            createAndShowGUI();
          }
        });
  }
  public static void main(String[] args) {
    String clientSettingFile = "";
    GetOpt getopt = new GetOpt(args, "f:");
    try {
      int c;
      while ((c = getopt.getNextOption()) != -1) {
        switch (c) {
          case 'f':
            clientSettingFile = getopt.getOptionArg();
            break;
        }
      }
    } catch (Exception e1) {
      e1.printStackTrace();
    }
    final DHTInteractiveClient dhtClient = new DHTInteractiveClient(clientSettingFile);

    javax.swing.SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            dhtClient.createAndShowGUI();
          }
        });
  }
Пример #15
0
  /** Main function for building the merge entry JPanel */
  private void initialize() {

    joint = new TreeSet<>(one.getFieldNames());
    joint.addAll(two.getFieldNames());

    // Remove field starting with __
    TreeSet<String> toberemoved = new TreeSet<>();
    for (String field : joint) {
      if (field.startsWith("__")) {
        toberemoved.add(field);
      }
    }

    for (String field : toberemoved) {
      joint.remove(field);
    }

    // Create storage arrays
    rb = new JRadioButton[3][joint.size() + 1];
    ButtonGroup[] rbg = new ButtonGroup[joint.size() + 1];
    identical = new Boolean[joint.size() + 1];
    jointStrings = new String[joint.size()];

    // Create main layout
    String colSpecMain =
        "left:pref, 5px, center:3cm:grow, 5px, center:pref, 3px, center:pref, 3px, center:pref, 5px, center:3cm:grow";
    String colSpecMerge =
        "left:pref, 5px, fill:3cm:grow, 5px, center:pref, 3px, center:pref, 3px, center:pref, 5px, fill:3cm:grow";
    String rowSpec = "pref, pref, 10px, fill:5cm:grow, 10px, pref, 10px, fill:3cm:grow";
    StringBuilder rowBuilder = new StringBuilder("");
    for (int i = 0; i < joint.size(); i++) {
      rowBuilder.append("pref, ");
    }
    rowBuilder.append("pref");

    FormLayout mainLayout = new FormLayout(colSpecMain, rowSpec);
    FormLayout mergeLayout = new FormLayout(colSpecMerge, rowBuilder.toString());
    mainPanel.setLayout(mainLayout);
    mergePanel.setLayout(mergeLayout);

    JLabel label = new JLabel(Localization.lang("Use"));
    Font font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));

    mainPanel.add(label, cc.xyw(4, 1, 7, "center, bottom"));

    // Set headings
    JLabel headingLabels[] = new JLabel[6];
    for (int i = 0; i < 6; i++) {
      headingLabels[i] = new JLabel(columnHeadings[i]);
      font = headingLabels[i].getFont();
      headingLabels[i].setFont(font.deriveFont(font.getStyle() | Font.BOLD));
      mainPanel.add(headingLabels[i], cc.xy(1 + (i * 2), 2));
    }

    mainPanel.add(new JSeparator(), cc.xyw(1, 3, 11));

    // Start with entry type
    EntryType type1 = one.getType();
    EntryType type2 = two.getType();

    mergedEntry.setType(type1);
    label = new JLabel(Localization.lang("Entry type"));
    font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
    mergePanel.add(label, cc.xy(1, 1));

    JTextArea type1ta = new JTextArea(type1.getName());
    type1ta.setEditable(false);
    mergePanel.add(type1ta, cc.xy(3, 1));
    if (type1.compareTo(type2) != 0) {
      identical[0] = false;
      rbg[0] = new ButtonGroup();
      for (int k = 0; k < 3; k += 2) {
        rb[k][0] = new JRadioButton();
        rbg[0].add(rb[k][0]);
        mergePanel.add(rb[k][0], cc.xy(5 + (k * 2), 1));
        rb[k][0].addChangeListener(
            new ChangeListener() {

              @Override
              public void stateChanged(ChangeEvent e) {
                updateAll();
              }
            });
      }
      rb[0][0].setSelected(true);
    } else {
      identical[0] = true;
    }
    JTextArea type2ta = new JTextArea(type2.getName());
    type2ta.setEditable(false);
    mergePanel.add(type2ta, cc.xy(11, 1));

    // For all fields in joint add a row and possibly radio buttons
    int row = 2;
    int maxLabelWidth = -1;
    int tmpLabelWidth = 0;
    for (String field : joint) {
      jointStrings[row - 2] = field;
      label = new JLabel(CaseChangers.UPPER_FIRST.format(field));
      font = label.getFont();
      label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
      mergePanel.add(label, cc.xy(1, row));
      String string1 = one.getField(field);
      String string2 = two.getField(field);
      identical[row - 1] = false;
      if ((string1 != null) && (string2 != null)) {
        if (string1.equals(string2)) {
          identical[row - 1] = true;
        }
      }

      tmpLabelWidth = label.getPreferredSize().width;
      if (tmpLabelWidth > maxLabelWidth) {
        maxLabelWidth = tmpLabelWidth;
      }

      if ("abstract".equals(field) || "review".equals(field)) {
        // Treat the abstract and review fields special
        JTextArea tf = new JTextArea();
        tf.setLineWrap(true);
        tf.setEditable(false);
        JScrollPane jsptf = new JScrollPane(tf);

        mergeLayout.setRowSpec(row, RowSpec.decode("center:2cm:grow"));
        mergePanel.add(jsptf, cc.xy(3, row, "f, f"));
        tf.setText(string1);
        tf.setCaretPosition(0);

      } else {
        JTextArea tf = new JTextArea(string1);
        mergePanel.add(tf, cc.xy(3, row));
        tf.setCaretPosition(0);
        tf.setEditable(false);
      }

      // Add radio buttons if the two entries do not have identical fields
      if (!identical[row - 1]) {
        rbg[row - 1] = new ButtonGroup();
        for (int k = 0; k < 3; k++) {
          rb[k][row - 1] = new JRadioButton();
          rbg[row - 1].add(rb[k][row - 1]);
          mergePanel.add(rb[k][row - 1], cc.xy(5 + (k * 2), row));
          rb[k][row - 1].addChangeListener(
              new ChangeListener() {

                @Override
                public void stateChanged(ChangeEvent e) {
                  updateAll();
                }
              });
        }
        if (string1 != null) {
          mergedEntry.setField(field, string1);
          rb[0][row - 1].setSelected(true);
          if (string2 == null) {
            rb[2][row - 1].setEnabled(false);
          }
        } else {
          rb[0][row - 1].setEnabled(false);
          mergedEntry.setField(field, string2);
          rb[2][row - 1].setSelected(true);
        }
      } else {
        mergedEntry.setField(field, string1);
      }
      if ("abstract".equals(field) || "review".equals(field)) {
        // Again, treat abstract and review special
        JTextArea tf = new JTextArea();
        tf.setLineWrap(true);
        tf.setEditable(false);
        JScrollPane jsptf = new JScrollPane(tf);

        mergePanel.add(jsptf, cc.xy(11, row, "f, f"));
        tf.setText(string2);
        tf.setCaretPosition(0);

      } else {
        JTextArea tf = new JTextArea(string2);
        mergePanel.add(tf, cc.xy(11, row));
        tf.setCaretPosition(0);
        tf.setEditable(false);
      }

      row++;
    }

    JScrollPane scrollPane =
        new JScrollPane(
            mergePanel,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    mainPanel.add(scrollPane, cc.xyw(1, 4, 11));
    mainPanel.add(new JSeparator(), cc.xyw(1, 5, 11));

    // Synchronize column widths
    String rbAlign[] = {"right", "center", "left"};
    mainLayout.setColumnSpec(1, ColumnSpec.decode(Integer.toString(maxLabelWidth) + "px"));
    Integer maxRBWidth = -1;
    Integer tmpRBWidth;
    for (int k = 0; k < 3; k++) {
      tmpRBWidth = headingLabels[k + 2].getPreferredSize().width;
      if (tmpRBWidth > maxRBWidth) {
        maxRBWidth = tmpRBWidth;
      }
    }
    for (int k = 0; k < 3; k++) {
      mergeLayout.setColumnSpec(
          5 + (k * 2), ColumnSpec.decode(rbAlign[k] + ":" + maxRBWidth + "px"));
    }

    // Setup a PreviewPanel and a Bibtex source box for the merged entry
    label = new JLabel(Localization.lang("Merged entry"));
    font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
    mainPanel.add(label, cc.xyw(1, 6, 6));

    String layoutString = Globals.prefs.get(JabRefPreferences.PREVIEW_0);
    pp = new PreviewPanel(null, mergedEntry, null, new MetaData(), layoutString);
    // JScrollPane jsppp = new JScrollPane(pp, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
    // JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    mainPanel.add(pp, cc.xyw(1, 8, 6));

    label = new JLabel(Localization.lang("Merged BibTeX source code"));
    font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
    mainPanel.add(label, cc.xyw(8, 6, 4));

    jta = new JTextArea();
    jta.setLineWrap(true);
    JScrollPane jspta = new JScrollPane(jta);
    mainPanel.add(jspta, cc.xyw(8, 8, 4));
    jta.setEditable(false);
    StringWriter sw = new StringWriter();
    try {
      new BibtexEntryWriter(new LatexFieldFormatter(), false).write(mergedEntry, sw);
    } catch (IOException ex) {
      LOGGER.error("Error in entry" + ": " + ex.getMessage(), ex);
    }
    jta.setText(sw.getBuffer().toString());
    jta.setCaretPosition(0);

    // Add some margin around the layout
    mainLayout.appendRow(RowSpec.decode("10px"));
    mainLayout.appendColumn(ColumnSpec.decode("10px"));
    mainLayout.insertRow(1, RowSpec.decode("10px"));
    mainLayout.insertColumn(1, ColumnSpec.decode("10px"));

    if (mainPanel.getHeight() > DIM.height) {
      mainPanel.setSize(new Dimension(mergePanel.getWidth(), DIM.height));
    }
    if (mainPanel.getWidth() > DIM.width) {
      mainPanel.setSize(new Dimension(DIM.width, mergePanel.getHeight()));
    }

    // Everything done, allow any action to actually update the merged entry
    doneBuilding = true;

    // Show what we've got
    mainPanel.setVisible(true);
    javax.swing.SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            scrollPane.getVerticalScrollBar().setValue(0);
          }
        });
  }
Пример #16
0
 /**
  * Method used to grab the Frame which is above this component in the hierarchy. This allows
  * programmers to make any component the parent of any window or dialog easier.
  *
  * @param comp the component to get the Frame for
  * @return the Frame above this component in the hierarchy
  */
 public static java.awt.Frame frameFromComponent(java.awt.Component parent) {
   java.awt.Frame f =
       (java.awt.Frame)
           javax.swing.SwingUtilities.getAncestorOfClass(java.awt.Frame.class, parent);
   return f;
 } // end frameFromComponent