javax.swing.JDialog#pack ( )源码实例Demo

下面列出了javax.swing.JDialog#pack ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: ProgressUI.java
/** Display the modal progress dialog. This method should be called from the
    AWT Event Dispatch thread. */
public void showProgressDialog() {
    if (finished) {
        return; // do not display the dialog if we are done
    }
    dialog = new JDialog(WindowManager.getDefault().getMainWindow(), title, true);
    dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    String lastMessageTmp;
    synchronized (this) {
        lastMessageTmp = lastMessage;
    }
    dialog.getContentPane().add(createProgressDialog(
                                    handle, 
                                    lastMessageTmp != null ? lastMessageTmp : title));
    dialog.pack();
    dialog.setBounds(Utilities.findCenterBounds(dialog.getSize()));
    dialog.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
    dialog.setVisible(true);
}
 
源代码2 项目: MtgDesktopCompanion   文件: MTGUIComponent.java
public static JDialog createJDialog(MTGUIComponent c, boolean resizable,boolean modal)
{
	JDialog j = new JDialog();
	
	
	j.getContentPane().setLayout(new BorderLayout());
	j.getContentPane().add(c, BorderLayout.CENTER);
	j.setTitle(c.getTitle());
	j.setLocationRelativeTo(null);
	if(c.getIcon()!=null)
		j.setIconImage(c.getIcon().getImage());
	
	j.pack();
	j.setModal(modal);
	j.setResizable(resizable);
	j.addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			c.onDestroy();
		}
	});
	
	return j;
}
 
源代码3 项目: pgptool   文件: EncryptBackMultipleView.java
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
	ret.setLayout(new BorderLayout());
	ret.setResizable(false);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("encrypBackMany.action"));
	ret.add(pnl, BorderLayout.CENTER);
	ret.pack();
	UiUtils.centerWindow(ret, owner);
	{
		// DIRTY-HACK: YES, FOLLOWING 2 LINES ARE REPEATED BY INTENTION,
		// OTHERWISE JXlABEL IS NOT
		// RETURNING CORRECT PREFERRED SIZE AND WHOLE LAYOUT IS SCREWED UP
		// THE ONLY WAY TO FORCE IT IS TO CENTER WINDOW. SO ONCE WE DID
		// FIRST TIME NOW WE CAN PACK AND CENTER AGAIN
		ret.pack();
		UiUtils.centerWindow(ret, owner);
	}
	return ret;
}
 
源代码4 项目: RipplePower   文件: VerifyDialog.java
public static void showDialog(JDialog parent) {
	try {
		JDialog dialog = new VerifyDialog(parent);
		dialog.pack();
		dialog.setLocationRelativeTo(parent);
		dialog.setVisible(true);
	} catch (Exception exc) {
		ErrorLog.get().logException("Exception while displaying dialog", exc);
	}
}
 
源代码5 项目: triplea   文件: ForgotPasswordPanel.java
/**
 * Shows this panel in a modal dialog.
 *
 * @param parent The dialog parent window.
 * @return {@link ReturnValue#OK} if the user clicks 'okay' button, otherwise {@link
 *     ReturnValue#CANCEL}.
 */
ReturnValue show(final Window parent) {
  dialog = new JDialog(JOptionPane.getFrameForComponent(parent), title, true);
  dialog.getContentPane().add(this);
  SwingKeyBinding.addKeyBinding(dialog, KeyCode.ESCAPE, this::close);
  dialog.pack();
  dialog.setLocationRelativeTo(parent);
  dialog.setVisible(true);
  dialog.dispose();
  dialog = null;
  return returnValue;
}
 
源代码6 项目: Shuffle-Move   文件: EditRosterService.java
@Override
public void onSetupGUI() {
   d = new JDialog(getOwner(), getString(KEY_TITLE));
   d.setTitle(getString(KEY_TITLE));
   d.setLayout(new GridBagLayout());
   GridBagConstraints c = new GridBagConstraints();
   c.fill = GridBagConstraints.HORIZONTAL;
   c.weightx = 1.0;
   c.weighty = 0.0;
   c.gridx = 1;
   c.gridy = 1;
   c.gridwidth = 1;
   c.gridheight = 1;
   d.add(makeUpperPanel(), c);
   
   c.gridy += 1;
   c.fill = GridBagConstraints.BOTH;
   c.weighty = 1.0;
   d.add(makeCenterPanel(), c);
   
   c.gridy += 1;
   c.fill = GridBagConstraints.HORIZONTAL;
   c.weighty = 0.0;
   d.add(makeBottomPanel(), c);
   
   ConfigManager preferencesManager = getUser().getPreferencesManager();
   int defaultWidth = preferencesManager.getIntegerValue(KEY_POPUP_WIDTH, DEFAULT_POPUP_WIDTH);
   int defaultHeight = preferencesManager.getIntegerValue(KEY_POPUP_HEIGHT, DEFAULT_POPUP_HEIGHT);
   int width = preferencesManager.getIntegerValue(KEY_EDIT_ROSTER_WIDTH, defaultWidth);
   int height = preferencesManager.getIntegerValue(KEY_EDIT_ROSTER_HEIGHT, defaultHeight);
   d.repaint();
   d.pack();
   d.setMinimumSize(new Dimension(getMinimumWidth(), DEFAULT_POPUP_HEIGHT));
   d.setSize(new Dimension(width, height));
   d.setLocationRelativeTo(null);
   d.setResizable(true);
   addActionListeners();
   setDialog(d);
   getUser().addObserver(this);
}
 
源代码7 项目: sc2gears   文件: FileBasedCache.java
/**
 * Empties the cache: deletes all files in the cache.<br>
 * Displays a modal info dialog about the fact that the cache is being emptied.
 * @param owner optional owner of the info dialog
 */
protected static void emptyCache_( final String cacheEntity, final Dialog owner, final String infoTextKey, final String cacheFolder ) {
	System.out.println( "Clearing " + cacheEntity + " cache..." );
	
	final JDialog infoDialog = owner == null ? new JDialog() : new JDialog( owner );
	infoDialog.setModal( true );
	infoDialog.setTitle( Language.getText( "general.infoTitle" ) );
	final JLabel infoLabel = new JLabel( Language.getText( infoTextKey ) );
	infoLabel.setFont( infoLabel.getFont().deriveFont( Font.ITALIC ) );
	infoLabel.setBorder( BorderFactory.createEmptyBorder( 25, 35, 25, 35 ) );
	infoDialog.getContentPane().add( infoLabel );
	infoDialog.pack();
	if ( owner == null )
		infoDialog.setLocationRelativeTo( null );
	else
		GuiUtils.centerWindowToWindow( infoDialog, owner );
	
	new NormalThread( cacheEntity + " cache emptier" ) {
		@Override
		public void run() {
			final File[] cacheFiles = new File( cacheFolder ).listFiles();
			if ( cacheFiles != null )
				for ( final File cacheFile : cacheFiles )
					deleteFile( cacheFile );
			
			infoDialog.dispose();
		}
	}.start();
	
	infoDialog.setVisible( true );
}
 
源代码8 项目: jdk8u60   文件: ImageableAreaTest.java
private static void createAndShowTestDialog(String description,
        String failMessage, Runnable action) {
    final JDialog dialog = new JDialog();
    dialog.setTitle("Test: " + (++testCount));
    dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);
    final JButton testButton = new JButton("Print Table");
    final JButton passButton = new JButton("PASS");
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        dialog.dispose();
    });
    final JButton failButton = new JButton("FAIL");
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        throw new RuntimeException(failMessage);
    });
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        action.run();
        passButton.setEnabled(true);
        failButton.setEnabled(true);
    });
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    buttonPanel.add(passButton);
    buttonPanel.add(failButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);
    dialog.pack();
    dialog.setVisible(true);
}
 
源代码9 项目: pgptool   文件: AboutView.java
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
	ret.setLayout(new BorderLayout());
	ret.setResizable(false);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("term.aboutApp"));
	ret.add(pnl, BorderLayout.CENTER);
	ret.pack();
	return ret;
}
 
源代码10 项目: openjdk-jdk9   文件: ImageableAreaTest.java
private static void createAndShowTestDialog(String description,
        String failMessage, Runnable action) {
    final JDialog dialog = new JDialog();
    dialog.setTitle("Test: " + (++testCount));
    dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);
    final JButton testButton = new JButton("Print Table");
    final JButton passButton = new JButton("PASS");
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        dialog.dispose();
    });
    final JButton failButton = new JButton("FAIL");
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        throw new RuntimeException(failMessage);
    });
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        action.run();
        passButton.setEnabled(true);
        failButton.setEnabled(true);
    });
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    buttonPanel.add(passButton);
    buttonPanel.add(failButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);
    dialog.pack();
    dialog.setVisible(true);
}
 
源代码11 项目: triplea   文件: ProductionPanel.java
/** Shows the production panel, and returns a map of selected rules. */
IntegerMap<ProductionRule> show(
    final GamePlayer gamePlayer,
    final JFrame parent,
    final GameData data,
    final boolean bid,
    final IntegerMap<ProductionRule> initialPurchase) {
  dialog = new JDialog(parent, "Produce", true);
  dialog.getContentPane().add(this);

  SwingKeyBinding.addKeyBinding(
      dialog,
      KeyCombination.of(KeyCode.ENTER, ButtonDownMask.CTRL),
      () -> dialog.setVisible(false));
  SwingKeyBinding.addKeyBinding(dialog, KeyCode.ESCAPE, () -> dialog.setVisible(false));

  this.bid = bid;
  this.data = data;
  this.initRules(gamePlayer, initialPurchase);
  this.initLayout();
  this.calculateLimits();
  dialog.pack();
  dialog.setLocationRelativeTo(parent);
  SwingUtilities.invokeLater(() -> done.requestFocusInWindow());
  // making the dialog visible will block until it is closed
  dialog.setVisible(true);
  dialog.dispose();
  return getProduction();
}
 
源代码12 项目: ontopia   文件: VizController.java
private TopicMapIF importTopicMap(TopicMapReaderIF reader, String name) {
  final JOptionPane pane = new JOptionPane(new Object[] { Messages
      .getString("Viz.LoadingTopicMap") + name },
      JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null,
      new String[] {}, null);

  Frame frame = JOptionPane.getFrameForComponent(vpanel);
  final JDialog dialog = new JDialog(frame, Messages
      .getString("Viz.Information"), true);

  dialog.setContentPane(pane);
  dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
  dialog.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosing(WindowEvent we) {
      JOptionPane
          .showMessageDialog(pane,
              Messages.getString("Viz.CannotCancelOperation"), 
              Messages.getString("Viz.Information"),
              JOptionPane.INFORMATION_MESSAGE);
    }
  });

  dialog.pack();
  dialog.setLocationRelativeTo(frame);

  TopicMapIF tm;
  final TopicMapReaderIF r = reader;

  final SwingWorker worker = new SwingWorker() {
    @Override
    public Object construct() {
      TopicMapIF result = null;
      try {
        result = r.read();
      } catch (IOException e) {
        dialog.setVisible(false);
        ErrorDialog.showError(vpanel, e.getMessage());
      }
      return result;
    }

    @Override
    public void finished() {
      dialog.setVisible(false);
    }
  };

  worker.start();
  dialog.setVisible(true);
  tm = (TopicMapIF) worker.getValue();
  return tm;
}
 
源代码13 项目: jdk8u_jdk   文件: TestTextPosInPrint.java
private static void createAndShowTestDialog() {
    String description =
        " 1. Click on \"Start Test\" button.\r\n" +
        " 2. Multiple strings will be displayed on console.\r\n" +
        " 3. A print dialog will be shown. Select any printer to print. " +
        "\r\n" +
        " If the printed output of the strings are same without any alignment issue, click on \"PASS\"\r\n" +
        " button, otherwise click on \"FAIL\" button.";

    final JDialog dialog = new JDialog();
    dialog.setTitle("SaveFileWithoutPrinter");
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            dialog.dispose();
            fail("Main dialog was closed.");
        }
    });

    final JLabel testTimeoutLabel = new JLabel(String.format(
        "Test timeout: %s", convertMillisToTimeStr(testTimeout)));
    final long startTime = System.currentTimeMillis();
    final Timer timer = new Timer(0, null);
    timer.setDelay(1000);
    timer.addActionListener((e) -> {
        int leftTime = testTimeout - (int) (System.currentTimeMillis() - startTime);
        if ((leftTime < 0) || testFinished) {
            timer.stop();
            dialog.dispose();
        }
        testTimeoutLabel.setText(String.format(
            "Test timeout: %s", convertMillisToTimeStr(leftTime)));
    });
    timer.start();

    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);

    final JButton testButton = new JButton("Start Test");
    final JButton passButton = new JButton("PASS");
    final JButton failButton = new JButton("FAIL");
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        new Thread(() -> {
            try {
                doTest();

                SwingUtilities.invokeLater(() -> {
                    passButton.setEnabled(true);
                    failButton.setEnabled(true);
                });
            } catch (Throwable t) {
                t.printStackTrace();
                dialog.dispose();
                fail("Exception occurred in a thread executing the test.");
            }
        }).start();
    });
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        dialog.dispose();
        pass();
    });
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        dialog.dispose();
        fail("Printed texts are not aligned as shown in console");
    });

    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel labelPanel = new JPanel(new FlowLayout());
    labelPanel.add(testTimeoutLabel);
    mainPanel.add(labelPanel, BorderLayout.NORTH);
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    buttonPanel.add(passButton);
    buttonPanel.add(failButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);

    dialog.pack();
    dialog.setVisible(true);
}
 
源代码14 项目: amidst   文件: BiomeExporterDialog.java
private JDialog createDialog() {
	JPanel panel = new JPanel(new GridBagLayout());

	setConstraints(40, 0, 0, 0, NONE, 1, 1, 1, 1, 0.0, 0.0, SOUTH);
	panel.add(createLabeledPanel("Top:", topSpinner, NONE), constraints);

	setConstraints(20, 20, 0, 0, NONE, 0, 2, 1, 1, 0.0, 0.0, SOUTH);
	panel.add(createLabeledPanel("Left:", leftSpinner, NONE), constraints);

	setConstraints(20, 0, 0, 0, NONE, 1, 3, 1, 1, 0.0, 0.0, SOUTH);
	panel.add(createLabeledPanel("Bottom:", bottomSpinner, NONE), constraints);

	setConstraints(20, 0, 0, 0, NONE, 2, 2, 1, 1, 0.0, 0.0, SOUTH);
	panel.add(createLabeledPanel("Right:", rightSpinner, NONE), constraints);

	setConstraints(10, 20, 0, 0, NONE, 0, 5, 2, 1, 0.0, 0.0, SOUTHWEST);
	panel.add(fullResCheckBox, constraints);

	setConstraints(0, 15, 0, 15, BOTH, 3, 0, 1, 6, 1.0, 0.0, CENTER);
	panel.add(Box.createGlue(), constraints);

	setConstraints(0, 0, 0, 0, BOTH, 0, 4, 4, 1, 0.0, 1.0, CENTER);
	panel.add(Box.createGlue(), constraints);

	JPanel pathPanel = new JPanel(new GridBagLayout());

	setConstraints(0, 0, 0, 0, HORIZONTAL, 0, 0, 1, 1, 0.0, 0.0, SOUTH);
	pathPanel.add(createLabeledPanel("Path:", pathField, HORIZONTAL), constraints);

	setConstraints(0, 10, 0, 0, HORIZONTAL, 1, 0, 1, 1, 0.0, 0.0, SOUTH);
	pathPanel.add(browseButton, constraints);

	setConstraints(10, 20, 20, 10, BOTH, 0, 6, 4, 2, 0.0, 0.0, SOUTHWEST);
	panel.add(pathPanel, constraints);

	setConstraints(15, 10, 10, 20, BOTH, 4, 0, 1, 7, 0.0, 0.0, EAST);
	panel.add(createLabeledPanel("Preview:", previewLabel, NONE), constraints);

	setConstraints(10, 10, 20, 20, NONE, 4, 7, 1, 1, 0.0, 0.0, SOUTHEAST);
	panel.add(exportButton, constraints);

	JDialog newDialog = new JDialog(parentFrame, "Export Biome Image");
	newDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
	newDialog.addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			/*
			 * This executes only when it's closed with the x button, alt f4, etc.
			 * When this happens we know that the user did not press the ok button
			 * to continue, so we re enable the export biomes menu button.
			 */
			menuBarSupplier.get().setMenuItemsEnabled(new String[] { "Export Biomes to Image ...", "Biome Profile" }, true);
			newDialog.dispose();
		}
	});
	newDialog.add(panel);
	newDialog.pack();
	newDialog.setResizable(false);
	return newDialog;
}
 
源代码15 项目: jdk8u_jdk   文件: WrongPaperForBookPrintingTest.java
private static void createAndShowTestDialog() {
    String description =
        " To run this test it is required to have a virtual PDF\r\n" +
        " printer or any other printer supporting A5 paper size.\r\n" +
        "\r\n" +
        " 1. Verify that NOT A5 paper size is set as default for the\r\n" +
        " printer to be used.\r\n" +
        " 2. Click on \"Start Test\" button.\r\n" +
        " 3. In the shown print dialog select the printer and click\r\n" +
        " on \"Print\" button.\r\n" +
        " 4. Verify that a page with a drawn rectangle is printed on\r\n" +
        " a paper of A5 size which is (5.8 x 8.3 in) or\r\n" +
        " (148 x 210 mm).\r\n" +
        "\r\n" +
        " If the printed page size is correct, click on \"PASS\"\r\n" +
        " button, otherwise click on \"FAIL\" button.";

    final JDialog dialog = new JDialog();
    dialog.setTitle("WrongPaperForBookPrintingTest");
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            dialog.dispose();
            fail("Main dialog was closed.");
        }
    });

    final JLabel testTimeoutLabel = new JLabel(String.format(
        "Test timeout: %s", convertMillisToTimeStr(testTimeout)));
    final long startTime = System.currentTimeMillis();
    final Timer timer = new Timer(0, null);
    timer.setDelay(1000);
    timer.addActionListener((e) -> {
        int leftTime = testTimeout - (int) (System.currentTimeMillis() - startTime);
        if ((leftTime < 0) || testFinished) {
            timer.stop();
            dialog.dispose();
        }
        testTimeoutLabel.setText(String.format(
            "Test timeout: %s", convertMillisToTimeStr(leftTime)));
    });
    timer.start();

    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);

    final JButton testButton = new JButton("Start Test");
    final JButton passButton = new JButton("PASS");
    final JButton failButton = new JButton("FAIL");
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        new Thread(() -> {
            try {
                doTest();

                SwingUtilities.invokeLater(() -> {
                    passButton.setEnabled(true);
                    failButton.setEnabled(true);
                });
            } catch (Throwable t) {
                t.printStackTrace();
                dialog.dispose();
                fail("Exception occurred in a thread executing the test.");
            }
        }).start();
    });
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        dialog.dispose();
        pass();
    });
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        dialog.dispose();
        fail("Size of a printed page is wrong.");
    });

    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel labelPanel = new JPanel(new FlowLayout());
    labelPanel.add(testTimeoutLabel);
    mainPanel.add(labelPanel, BorderLayout.NORTH);
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    buttonPanel.add(passButton);
    buttonPanel.add(failButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);

    dialog.pack();
    dialog.setVisible(true);
}
 
源代码16 项目: uima-uimaj   文件: AnnotationViewerDialog.java
/**
 * Launch that viewer.
 *
 * @param inputDirPath the input dir path
 * @param fileName the file name
 * @param typeSystem the type system
 * @param aTypesToDisplay the a types to display
 * @param javaViewerRBisSelected the java viewer R bis selected
 * @param javaViewerUCRBisSelected the java viewer UCR bis selected
 * @param xmlRBisSelected the xml R bis selected
 * @param styleMapFile the style map file
 * @param viewerDirectory the viewer directory
 */
public void launchThatViewer(String inputDirPath, String fileName, TypeSystem typeSystem,
        final String[] aTypesToDisplay, boolean javaViewerRBisSelected,
        boolean javaViewerUCRBisSelected, boolean xmlRBisSelected, File styleMapFile,
        File viewerDirectory) {
  try {

    File xcasFile = new File(inputDirPath, fileName);
    // create a new CAS
    CAS cas = CasCreationUtils.createCas(Collections.EMPTY_LIST, typeSystem, UIMAFramework
            .getDefaultPerformanceTuningProperties());
    // deserialize XCAS into CAS
    try (InputStream xcasInStream = new FileInputStream(xcasFile)) {
      XmlCasDeserializer.deserialize(xcasInStream, cas, true);
    }
    
    //get the specified view
    cas = cas.getView(this.defaultCasViewName);

    // launch appropriate viewer
    if (javaViewerRBisSelected || javaViewerUCRBisSelected) { // JMP
      // record preference for next time
      med1.setViewType(javaViewerRBisSelected ? "Java Viewer" : "JV User Colors");

      // create tree viewer component
      CasAnnotationViewer viewer = new CasAnnotationViewer();
      viewer.setDisplayedTypes(aTypesToDisplay);
      if (javaViewerUCRBisSelected)
        getColorsForTypesFromFile(viewer, styleMapFile);
      else
        viewer.setHiddenTypes(new String[] { "uima.cpm.FileLocation" });
      // launch viewer in a new dialog
      viewer.setCAS(cas);
      JDialog dialog = new JDialog(AnnotationViewerDialog.this, "Annotation Results for "
              + fileName + " in " + inputDirPath); // JMP
      dialog.getContentPane().add(viewer);
      dialog.setSize(850, 630);
      dialog.pack();
      dialog.show();
    } else {
      CAS defaultView = cas.getView(CAS.NAME_DEFAULT_SOFA);
      if (defaultView.getDocumentText() == null) {
        displayError("The HTML and XML Viewers can only view the default text document, which was not found in this CAS.");
        return;
      }
      // generate inline XML
      File inlineXmlFile = new File(viewerDirectory, "inline.xml");
      CasToInlineXml casToInlineXml = new CasToInlineXml();
      casToInlineXml.setFormattedOutput(false);
      String xmlAnnotations = casToInlineXml.generateXML(defaultView);
      FileOutputStream outStream = new FileOutputStream(inlineXmlFile);
      outStream.write(xmlAnnotations.getBytes(StandardCharsets.UTF_8));
      outStream.close();

      if (xmlRBisSelected) // JMP passed in
      {
        // record preference for next time
        med1.setViewType("XML");

        BrowserUtil.openUrlInDefaultBrowser(inlineXmlFile.getAbsolutePath());
      } else
      // HTML view
      {
        med1.setViewType("HTML");
        // generate HTML view
        // first process style map if not done already
        if (!processedStyleMap) {
          if (!styleMapFile.exists()) {
            annotationViewGenerator.autoGenerateStyleMapFile(
                    promptForAE().getAnalysisEngineMetaData(), styleMapFile);
          }
          annotationViewGenerator.processStyleMap(styleMapFile);
          processedStyleMap = true;
        }
        annotationViewGenerator.processDocument(inlineXmlFile);
        File genFile = new File(viewerDirectory, "index.html");
        // open in browser
        BrowserUtil.openUrlInDefaultBrowser(genFile.getAbsolutePath());
      }
    }

    // end LTV here

  } catch (Exception ex) {
    displayError(ex);
  }
}
 
源代码17 项目: Shuffle-Move   文件: MoveChooserService.java
@Override
public void onSetupGUI() {
   d = new JDialog(getOwner());
   d.setLayout(new GridBagLayout());
   d.setTitle(getString(KEY_TITLE));
   shuffleMenuBar = new ShuffleMenuBar(getUser(), getOwner());
   d.setJMenuBar(shuffleMenuBar);
   
   GridBagConstraints c = new GridBagConstraints();
   c.fill = GridBagConstraints.BOTH;
   c.anchor = GridBagConstraints.CENTER;
   c.weightx = 1.0;
   c.weighty = 1.0;
   c.gridy = 1;
   
   // Display row
   c.weighty = 1.0;
   c.gridwidth = 4;
   c.gridx = 1;
   c.gridy++;
   
   c.gridx++;
   results = new ArrayList<SimulationResult>();
   resultsMap = new HashMap<SimulationResult, Integer>();
   model2 = new DefaultTableModel(getColumnNames(), 0) {
      private static final long serialVersionUID = 5180830497930828902L;
      
      @Override
      public boolean isCellEditable(int row, int col) {
         return false;
      }
   };
   table = new JTable(model2);
   loadOrderFor(table, getUser().getPreferencesManager().getStringValue(KEY_COLUMN_ORDER));
   resizeColumnWidth(table);
   table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   listener2 = new ListSelectionListener() {
      
      @Override
      public void valueChanged(ListSelectionEvent e) {
         pushSelectionToUser2();
      }
   };
   table.getSelectionModel().addListSelectionListener(listener2);
   JScrollPane jsp = new JScrollPane(table);
   d.add(jsp, c);
   
   // Control row
   c.weighty = 0.0;
   c.gridwidth = 1;
   c.gridx = 1;
   c.gridy++;
   
   c.gridx++;
   metricLabel = new JLabel(getString(KEY_METRIC_LABEL));
   metricLabel.setHorizontalAlignment(SwingConstants.CENTER);
   metricLabel.setHorizontalTextPosition(SwingConstants.CENTER);
   metricLabel.setToolTipText(getString(KEY_METRIC_TOOLTIP));
   d.add(metricLabel, c);
   
   c.gridx++;
   ind = new GradingModeIndicator(getUser());
   ind.setToolTipText(getString(KEY_METRIC_TOOLTIP));
   d.add(ind, c);
   
   c.gridx++;
   doMoveButton = new JButton(new AbstractAction(getString(KEY_DO_NOW)) {
      private static final long serialVersionUID = -8952138130413953491L;
      
      @Override
      public void actionPerformed(ActionEvent arg0) {
         doMovePressed();
      }
   });
   doMoveButton.setToolTipText(getString(KEY_DO_TOOLTIP));
   d.add(doMoveButton, c);
   setDefaultButton(doMoveButton);
   
   c.gridx++;
   closeButton = new JButton(new DisposeAction(getString(KEY_CLOSE), this));
   closeButton.setToolTipText(getString(KEY_CLOSE_TOOLTIP));
   d.add(closeButton, c);
   d.pack();
   
   ConfigManager preferencesManager = getUser().getPreferencesManager();
   final int width = preferencesManager.getIntegerValue(KEY_CHOOSER_WIDTH, DEFAULT_CHOOSER_WIDTH);
   final int height = preferencesManager.getIntegerValue(KEY_CHOOSER_HEIGHT, DEFAULT_CHOOSER_HEIGHT);
   d.setSize(width, height);
   d.repaint();
   Integer x = preferencesManager.getIntegerValue(KEY_CHOOSER_X);
   Integer y = preferencesManager.getIntegerValue(KEY_CHOOSER_Y);
   if (x != null && y != null) {
      d.setLocation(x, y);
   } else {
      d.setLocationRelativeTo(null);
   }
   d.setMinimumSize(MIN_SIZE);
   d.setResizable(preferencesManager.getBooleanValue(KEY_CHOOSER_RESIZE, DEFAULT_RESIZE));
   getUser().addObserver(this);
   setDialog(d);
}
 
源代码18 项目: openjdk-jdk9   文件: PageDialogMarginValidation.java
private static void doTest(Runnable action) {
    String description
            = " Initially, a page dialog will be shown.\n "
            + " The left, right, bottom, right margin will have value 1.0.\n"
            + " Modify right margin from 1.0 to 0.0 and press tab.\n"
            + " Please verify the right margin changes back to 1.0. \n"
            + " Please do the same for bottom margin.\n"
            + " If right and bottom margin changes back to 1.0, press PASS else press fail";

    final JDialog dialog = new JDialog();
    dialog.setTitle("printSelectionTest");
    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);
    final JButton testButton = new JButton("Start Test");
    final JButton passButton = new JButton("PASS");
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        dialog.dispose();
        pass();
    });
    final JButton failButton = new JButton("FAIL");
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        dialog.dispose();
        fail();
    });
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        action.run();
        passButton.setEnabled(true);
        failButton.setEnabled(true);
    });
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    buttonPanel.add(passButton);
    buttonPanel.add(failButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);
    dialog.pack();
    dialog.setVisible(true);
}
 
源代码19 项目: TencentKona-8   文件: DlgAttrsBug.java
private static void doTest(Runnable action) {
    String description
            = " Visual inspection of print dialog is required.\n"
            + " A print dialog will be shown.\n "
            + " Please verify Copies 5 is selected.\n"
            + " Also verify, Page Range is selected with "
            + " from page 3 and to Page 4.\n"
            + " If ok, press PASS else press FAIL";

    final JDialog dialog = new JDialog();
    dialog.setTitle("printSelectionTest");
    JTextArea textArea = new JTextArea(description);
    textArea.setEditable(false);
    final JButton testButton = new JButton("Start Test");
    final JButton passButton = new JButton("PASS");
    passButton.setEnabled(false);
    passButton.addActionListener((e) -> {
        dialog.dispose();
        pass();
    });
    final JButton failButton = new JButton("FAIL");
    failButton.setEnabled(false);
    failButton.addActionListener((e) -> {
        dialog.dispose();
        fail();
    });
    testButton.addActionListener((e) -> {
        testButton.setEnabled(false);
        action.run();
        passButton.setEnabled(true);
        failButton.setEnabled(true);
    });
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textArea, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel(new FlowLayout());
    buttonPanel.add(testButton);
    buttonPanel.add(passButton);
    buttonPanel.add(failButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.add(mainPanel);
    dialog.pack();
    dialog.setVisible(true);
}
 
源代码20 项目: Openfire   文件: Launcher.java
private void installPlugin(final File plugin) {
    final JDialog dialog = new JDialog(frame, "Installing Plugin", true);
    dialog.getContentPane().setLayout(new BorderLayout());
    JProgressBar bar = new JProgressBar();
    bar.setIndeterminate(true);
    bar.setString("Installing Plugin.  Please wait...");
    bar.setStringPainted(true);
    dialog.getContentPane().add(bar, BorderLayout.CENTER);
    dialog.pack();
    dialog.setSize(225, 55);

    final SwingWorker<File, Void> installerThread = new SwingWorker<File, Void>() {
        @Override
        public File doInBackground() {
            File pluginsDir = new File(binDir.getParentFile(), "plugins");
            String tempName = plugin.getName() + ".part";
            File tempPluginsFile = new File(pluginsDir, tempName);

            File realPluginsFile = new File(pluginsDir, plugin.getName());

            // Copy Plugin into Dir.
            try {
                // Just for fun. Show no matter what for two seconds.
                Thread.sleep(2000);

                copy(plugin.toURI().toURL(), tempPluginsFile);

                // If successfull, rename to real plugin name.
                tempPluginsFile.renameTo(realPluginsFile);
            }
            catch (Exception e) {
                e.printStackTrace();
            }
            return realPluginsFile;
        }

        @Override
        public void done() {
            dialog.setVisible(false);
        }
    };

    // Start installation
    installerThread.execute();

    dialog.setLocationRelativeTo(frame);
    dialog.setVisible(true);
}