java.awt.FileDialog.setSize()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(164)

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

FileDialog.setSize介绍

暂无

代码示例

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

FileDialog fd=new FileDialog(f1,"Save Your File",FileDialog.SAVE);
fd.setSize(400,200);
fd.setVisible(true);
try 
{
FileWriter fw=new FileWriter(fd.getDirectory()+fd.getFile());
fw.write(t1.getText()); // t1 is the name of your textarea
fw.close();
}
catch(Exception e)
{
}

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

fdial.setSize(300,300);
fdial.setVisible(true);
String str=fdial.getDirectory();

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

private void testFileDialog(){
  Frame f = new Frame();
  FileDialog fd = new FileDialog(f, "Hej", FileDialog.LOAD);
  fd.setDirectory("/home/anders/_ormbunkar");
  fd.setLocation(100,100);
  fd.setSize(600, 600);
  fd.setFile("");
  fd.setVisible(true);
  File selectedFile = new File(fd.getFile());
}

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

final FileDialog fileDialog = new FileDialog(applicationFrame, 
     "Choose a file", FileDialog.LOAD);
 /* Lots of code to be able to center an awt.FileDialog on screen... */
 Rectangle rect = applicationFrame.getContentPane().getBounds();
 /* 
  * Making sure FileDialog has a size before setVisible, otherwise
  * left corner's distance from contentPane center cannot be found.
  */
 fileDialog.pack();
 fileDialog.setSize(800, 600);
 fileDialog.validate();
 double width = fileDialog.getBounds().getWidth();
 double height = fileDialog.getBounds().getHeight();
 double x = rect.getCenterX() - (width / 2);
 double y = rect.getCenterY() - (height/ 2);
 /* Could be new Point(x, y) */
 Point leftCorner = new Point();
 leftCorner.setLocation(x, y);
 fileDialog.setLocation(leftCorner);
 fileDialog.setVisible(true);

相关文章