javax.swing.JDialog.setPreferredSize()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中javax.swing.JDialog.setPreferredSize()方法的一些代码示例,展示了JDialog.setPreferredSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JDialog.setPreferredSize()方法的具体详情如下:
包路径:javax.swing.JDialog
类名称:JDialog
方法名:setPreferredSize

JDialog.setPreferredSize介绍

暂无

代码示例

代码示例来源:origin: MegaMek/mekhq

/**
 * Set preferred size for the drop-down that will appear.
 *
 * @param size
 *            Preferred size of the drop-down list
 */
public void setPreferredSuggestSize(Dimension size) {
  d.setPreferredSize(size);
}

代码示例来源:origin: cytoscape/application

/**
 * @param args
 */
public static void main(String[] args) {
  JDialog theDialog = new BookmarkDialog();
  theDialog.setPreferredSize(new Dimension(350, 400));
  theDialog.pack();
  theDialog.setVisible(true);
}

代码示例来源:origin: Killerardvark/CryodexSource

public static void showSwapPanel() {
  JDialog manualModificationPanel = new JDialog(Main.getInstance(), "Swap Players", true);
  JPanel panel = new JPanel(new BorderLayout());
  manualModificationPanel.getContentPane().add(panel);
  panel.add(new SwapPanel(manualModificationPanel), BorderLayout.CENTER);
  manualModificationPanel.setPreferredSize(new Dimension(450, 600));
  manualModificationPanel.pack();
  manualModificationPanel.setVisible(true);
}

代码示例来源:origin: Killerardvark/CryodexSource

public static void showActivePanel() {
  JDialog manualModificationPanel = new JDialog(Main.getInstance(), "Active Players", true);
  JPanel panel = new JPanel(new BorderLayout());
  manualModificationPanel.getContentPane().add(panel);
  panel.add(new ActivePlayerPanel(manualModificationPanel), BorderLayout.CENTER);
  manualModificationPanel.setPreferredSize(new Dimension(450, 600));
  manualModificationPanel.pack();
  manualModificationPanel.setVisible(true);
}

代码示例来源:origin: org.cytoscape/vizmap-gui-impl

private void initComponents(final JDialog dialog) {
    dialog.setLayout(new BorderLayout());
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.getContentPane().add(editorPanel, BorderLayout.CENTER);
    dialog.setPreferredSize(DEF_SIZE);
    dialog.setMinimumSize(MIN_SIZE);
    dialog.pack();
  }
});

代码示例来源:origin: MrCrayfish/ModelCreator

private static JDialog getWelcomeDialog(JFrame parent, JPanel dialogContent)
{
  JDialog dialog = new JDialog(parent, "Welcome", Dialog.ModalityType.APPLICATION_MODAL);
  dialog.setResizable(false);
  dialog.setPreferredSize(new Dimension(500, 290));
  dialog.add(dialogContent);
  dialog.pack();
  return dialog;
}

代码示例来源:origin: com.googlecode.jannocessor/jannocessor-common

private static void showDialog() {
    JDialog dlg = new JDialog();

    dlg.setTitle("JAnnocessor - Java Annotation Processor");
    dlg.setPreferredSize(new Dimension(500, 100));

    JLabel text = new JLabel(INFO);
    dlg.add(text);

    dlg.pack();
    dlg.setModal(true);
    dlg.setLocationRelativeTo(null);
    dlg.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dlg.setVisible(true);
  }
}

代码示例来源:origin: matsim-org/matsim

public static void showDialog(JFreeChart chart, String title, int width, int height, boolean modal) {
  JDialog dialog = newChartDialog(chart, title, modal);
  dialog.setPreferredSize(new Dimension(width, height));
  SwingUtils.showWindow(dialog, modal);
}

代码示例来源:origin: stackoverflow.com

public static void adjustWidthForTitle(JDialog dialog)
{
  // make sure that the dialog is not smaller than its title
  // this is not an ideal method, but I can't figure out a better one
  Font defaultFont = UIManager.getDefaults().getFont("Label.font");
  int titleStringWidth = SwingUtilities.computeStringWidth(new JLabel().getFontMetrics(defaultFont),
      dialog.getTitle());

  // account for titlebar button widths. (estimated)
  titleStringWidth += 110;

  // set minimum width
  Dimension currentPreferred = dialog.getPreferredSize();

  // +10 accounts for the three dots that are appended when the title is too long
  if(currentPreferred.getWidth() + 10 <= titleStringWidth)
  {
    dialog.setPreferredSize(new Dimension(titleStringWidth, (int) currentPreferred.getHeight()));

  }
}

代码示例来源:origin: net.sf.taverna.t2.workbench/helper

/**
 * Initialize the current JDialog with the current JHelp. Attempt to set its
 * size.
 * 
 * @param d
 */
private static void initializeDialog(JDialog d) {
  d.add(jhelp);
  d.setPreferredSize(oldSize);
  d.setSize(oldSize);
}

代码示例来源:origin: org.cytoscape/log-swing-impl

public UserMessagesDialog(final CySwingApplication app, final Map<String,String> logViewerConfig) {
  dialog = new JDialog(app.getJFrame(), "User Messages");
  dialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
  dialog.setPreferredSize(new Dimension(850, 400));
  logViewer = new LogViewer(logViewerConfig);
  dialog.add(logViewer.getComponent(), BorderLayout.CENTER);
  JButton clearBtn = new JButton("Clear");
  clearBtn.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      logViewer.clear();
    }
  });
  JPanel bottomBtns = new JPanel(new FlowLayout(FlowLayout.RIGHT));
  bottomBtns.add(clearBtn);
  dialog.add(bottomBtns, BorderLayout.SOUTH);
  dialog.pack();
}

代码示例来源:origin: edu.stanford.protege/ca.uvic.cs.chisel.cajun

public static void main(String[] args) {
  JDialog dlg = new JDialog();
  dlg.setTitle("Test");
  dlg.setModal(true);
  dlg.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
  dlg.getContentPane().setLayout(new BorderLayout());
  
  final StatusProgressBar spb = new StatusProgressBar();
  
  JPanel pnl = new JPanel();
  pnl.add(new JButton(new AbstractAction("Start/Stop") {
    public void actionPerformed(ActionEvent e) {
      if (spb.isInProgress()) {
        spb.stopProgress();
      } else {
        spb.startProgress();
      }
    }
  }));
  dlg.getContentPane().add(pnl, BorderLayout.CENTER);
  dlg.getContentPane().add(spb, BorderLayout.SOUTH);
  dlg.pack();
  dlg.setLocation(100, 50);
  dlg.setPreferredSize(new Dimension(400, 200));
  dlg.setVisible(true);
  
  System.exit(0);
}

代码示例来源:origin: monster860/FastDMM

dialog.setPreferredSize(dialog.getSize());
dialog.setVisible(true);

代码示例来源:origin: hltfbk/Excitement-Open-Platform

Dimension frameDimension = cpe.getMainFrame().getSize();
Dimension originalPreferredSize = selectDialog.getPreferredSize();
selectDialog.setPreferredSize(new Dimension((int)(frameDimension.getWidth()*0.5), (int)(originalPreferredSize.getHeight())));
selectDialog.pack();
selectDialog.setVisible(true);

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

@Override
public void actionPerformed(ActionEvent e) {
  JDialog f = new JDialog(MedSavantFrame.getInstance(), "Pedigree Viewer", true);
  PedigreeCanvas pc = new PedigreeCanvas();
  pc.setFamilyName(patient.getFamilyID());
  pc.showPedigreeFor(patient.getID());
  f.setPreferredSize(new Dimension(650, 500));
  f.setLayout(new BorderLayout());
  f.add(pc, BorderLayout.CENTER);
  f.pack();
  f.setLocationRelativeTo(MedSavantFrame.getInstance());
  f.setVisible(true);
}

代码示例来源:origin: AliView/AliView

public void show(){
  dialog.setPreferredSize(this.preferredSize);
  dialog.pack();
  // center
  if(parentFrame != null){
    int newX = parentFrame.getX() + parentFrame.getWidth()/2 - dialog.getPreferredSize().width/2;
    int newY = parentFrame.getY() + parentFrame.getHeight()/2 - dialog.getPreferredSize().height/2;
    dialog.setLocation(newX, newY);
  }
  dialog.setVisible(true);
}

代码示例来源:origin: bcdev/beam

@Override
  public void actionPerformed(CommandEvent event) {
    super.actionPerformed(event);
    final OpendapAccessPanel opendapAccessPanel = new OpendapAccessPanel(getAppContext(), event.getCommand().getHelpId());
    final JDialog jDialog = new JDialog(getAppContext().getApplicationWindow(), "OPeNDAP Access");
    jDialog.setContentPane(opendapAccessPanel);
    jDialog.pack();
    final Dimension size = jDialog.getSize();
    jDialog.setPreferredSize(size);
    jDialog.setVisible(true);
  }
}

代码示例来源:origin: org.cytoscape/swing-application-impl

public void showCredits() {
  dialog = new JDialog(parent,true);
  dialog.setUndecorated(true);
  final ScrollingLinesPanel panel = new ScrollingLinesPanel(image, lines);
  dialog.add(panel);
  dialog.pack();
  dialog.validate();
  dialog.setPreferredSize(panel.getPreferredSize());
  centerDialogLocation(dialog);
  Action scrollText = new AbstractAction() {
    private final static long serialVersionUID = 1202340446391603L;
    public void actionPerformed(ActionEvent e) {
      panel.incrementYPos();
      dialog.repaint();
    }
  };
  timer = new Timer(100, scrollText);
  dialog.addMouseListener(new MouseListener() {
      public void mouseClicked(MouseEvent e) {
        hideCredits();
      }
      public void mouseEntered(MouseEvent e) { }
      public void mouseExited(MouseEvent e) { }
      public void mousePressed(MouseEvent e) { }
      public void mouseReleased(MouseEvent e) { }
    });
  timer.start();
  dialog.setVisible(true);
}

代码示例来源:origin: zitmen/thunderstorm

/**
 * shows the url in the static window, sizes and positions the window
 * accordingly
 */
private void showInTextWindow() throws IOException {
  window.setVisible(false);
  // same height as parent window of the button, positioned next to it on left or right side
  Window ancestor = SwingUtilities.getWindowAncestor(this);
  window.setPreferredSize(new Dimension(WINDOW_WIDTH, Math.max(ancestor.getHeight(), WINDOW_HEIGHT)));
  int screenEnd = ancestor.getGraphicsConfiguration().getBounds().width + ancestor.getGraphicsConfiguration().getBounds().x;
  Point ancestorLocation = ancestor.getLocationOnScreen();
  if(ancestorLocation.x + ancestor.getWidth() + window.getPreferredSize().width < screenEnd) {
    window.setLocation(ancestorLocation.x + ancestor.getWidth(), ancestorLocation.y);
  } else {
    window.setLocation(ancestorLocation.x - window.getPreferredSize().width, ancestorLocation.y);
  }
  //set page shown in browser
  if(url != null && !url.equals(htmlBrowser.getPage())) {
    try {
      htmlBrowser.setPage(url);
    } catch(Exception e) {
      htmlBrowser.setText("Could not load help file");
    }
  }
  window.pack();
  window.setVisible(true);
}

代码示例来源:origin: org.cytoscape/work-swing-impl

dialog.setPreferredSize(new Dimension(500, 400));

相关文章

JDialog类方法