javax.swing.JFrame.setTitle()方法的使用及代码示例

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

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

JFrame.setTitle介绍

暂无

代码示例

代码示例来源:origin: libgdx/packr

public static void main (String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setTitle("My Test App");
    frame.setSize(480, 320);
    frame.setVisible(true);
    JOptionPane.showConfirmDialog(null, "Working dir: " + new File(".").getAbsolutePath());
  }
}

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

protected void updateGraph(FunctionGraph someGraph, String title) {
    if (someGraph.getParent() == null) {
      JFrame jf = someGraph.showInJFrame(title, 400, 250, false, false);
      setDependentWindowLocation(jf);
    } else {
      JFrame jf = (JFrame) SwingUtilities.getWindowAncestor(someGraph);
      jf.setTitle(title);
      jf.setVisible(true); // just to be sure
      someGraph.repaint();
    }
  }
}

代码示例来源:origin: igniterealtime/Openfire

frame.setTitle(appName);
frame.pack();
frame.setSize(400, 300);
frame.setResizable(true);
frame.setVisible(true);

代码示例来源:origin: net.sf.taverna.t2.workbench/contextual-views-api

/**
 * @param args
 */
public static void main(String[] args) {
  // TODO Auto-generated method stub
  JFrame mimeFrame = new JFrame();
  MimeTypeConfig mimeConf = new MimeTypeConfig();
  mimeFrame.add(mimeConf);
  mimeFrame.setTitle("mime");
  mimeFrame.setVisible(true);
}

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

// Display a frame with HTML code
public JFrame displayHTMLJFrame(String HTML, String title){
    JFrame fen = new JFrame();
  fen.setSize(1000, 800);
  fen.setTitle(title);

  JEditorPane pan = new JEditorPane();
  pan.setEditorKit(new HTMLEditorKit());
  pan.setEditable(false);

  pan.setText(HTML);
  fen.add(pan);
  return fen;
}

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

public static void main(String[] args) {
  SwingUtilities.invokeLater(new Runnable() {
     public void run() {
       JFrame win = new HelloWorldSwing();
       win.setTitle("TextAreaDemo");
       win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       win.setVisible(true);
     }
  });
}

代码示例来源:origin: codeka/wwmmo

/** Initialize the contents of the frame. */
 private void initialize() {
  frame = new JFrame();
  frame.setTitle("Planet Render");
  frame.setBounds(100, 100, 1200, 700);
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  frame.getContentPane().add(new AppContent());
 }
}

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

public static void main(String args[]) {
    JFrame frame = new JFrame();
    frame.setTitle("Title");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton button = new JButton();
    button.setText("Hello, World!");
    frame.getContentPane().add(button, BorderLayout.CENTER);
    frame.setSize(200, 100);
    frame.pack();
    frame.setVisible(true);
    frame.show();
  }
}

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

private void launchEventPanel(final String title) { 
 EventQueue.invokeLater(new Runnable() { 
   public void run() { 
   JFrame myFrame = new JFrame(); 
   myFrame.setTitle("Conference Call");  
   myFrame.setIconImage(CallConference.this.myCore.myPanel.myIconManager.getPromptIcon(CallEMart.class.toString())); 
   myFrame.getContentPane().add(CallConference.this.myEventPanel, "Center"); 
   myFrame.pack(); 
   myFrame.setVisible(true); } }); }

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

JFrame t = new JFrame();
t.setSize(600,300);
t.setFont(new Font("System", Font.PLAIN, 14));
Font f = t.getFont();
FontMetrics fm = t.getFontMetrics(f);
int x = fm.stringWidth("Hello Center");
int y = fm.stringWidth(" ");
int z = t.getWidth()/2 - (x/2);
int w = z/y;
String pad ="";
//for (int i=0; i!=w; i++) pad +=" "; 
pad = String.format("%"+w+"s", pad);
t.setTitle(pad+"Hello Center");

代码示例来源:origin: com.itextpdf/itext-rups

static void initApplication(JFrame frame, RupsController controller, final int onCloseOperation) {
  // title bar
  frame.setTitle("iText RUPS " + Version.getInstance().getVersion());
  frame.setIconImage(Toolkit.getDefaultToolkit().getImage(Rups.class.getResource("logo.png")));
  frame.setDefaultCloseOperation(onCloseOperation);
  // the content
  frame.setJMenuBar(controller.getMenuBar());
  frame.getContentPane().add(controller.getMasterComponent(), java.awt.BorderLayout.CENTER);
  frame.setVisible(true);
}

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

protected void updateGraph(FunctionGraph someGraph, String title) {
    if (someGraph.getParent() == null) {
      JFrame jf = someGraph.showInJFrame(title, 400, 250, false, false);
      setDependentWindowLocation(jf);
    } else {
      JFrame jf = (JFrame) SwingUtilities.getWindowAncestor(someGraph);
      jf.setTitle(title);
      jf.setVisible(true); // just to be sure
      someGraph.repaint();
    }
  }
}

代码示例来源:origin: cmusphinx/sphinx4

public static void main(String args[]) {
    JFrame frame = new JFrame();
    frame.setTitle("Debug");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(false);

    FilenameDialog dialog = new FilenameDialog(frame, true, "Save as...");

    System.out.println("Showing dialog...");
    dialog.setVisible(true);

    String filename = dialog.getFilename();
    System.out.println("Filename: " + filename
        + " (length = " + filename.length() + ')');
    System.exit(0);
  }
}

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

private void launchEventPanel(final String title) {
  EventQueue.invokeLater(new Runnable() {
    public void run() {
      JFrame myFrame = new JFrame();
      myFrame.setTitle(title);
      myFrame.setIconImage(CrConference.this.mainCore.myPanel.myIconManager.getPromptIcon(Mart.class.toString()));
      myFrame.getContentPane().add(Conference.this.myEventPanel, "Center");
      myFrame.pack();
      myFrame.setVisible(true);
    }
  });
}

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

JFrame t = new JFrame();
t.setSize(600,300);
t.setFont(new Font("System", Font.PLAIN, 14));
Font f = t.getFont();
FontMetrics fm = t.getFontMetrics(f);
int x = fm.stringWidth("Hello Center");
int y = fm.stringWidth(" ");
int z = t.getWidth()/2 - (x/2);
int w = z/y;
String pad ="";
//for (int i=0; i!=w; i++) pad +=" "; 
pad = String.format("%"+w+"s", pad);
t.setTitle(pad+"Hello Center");

代码示例来源:origin: winder/Universal-G-Code-Sender

public VisualizerWindow(WindowSettings ws) {
  this.setPreferredSize(new Dimension(ws.width, ws.height));
  this.setLocation(ws.xLocation, ws.yLocation);
  // Create the OpenGL rendering canvas
  this.canvas = new VisualizerCanvas();
  canvas.setPreferredSize(new Dimension(ws.width, ws.height));
  canvas.setLocation(ws.xLocation, ws.yLocation);
  // Create a animator that drives canvas' display() at the specified FPS.
  this.animator = new FPSAnimator(canvas, FPS, true);
  // Create the top-level container
  final JFrame frame = this; // Swing's JFrame or AWT's Frame
  frame.getContentPane().add(canvas);
  
  // Manage pausing and resuming the animator when it doesn't need to run.
  frame.addWindowListener(this);
  
  frame.setTitle(TITLE);
  frame.pack();
  frame.setVisible(true);
  animator.start(); // start the animation loop
}

代码示例来源:origin: kevin-wayne/algs4

/**
 * Displays the picture in a window on the screen.
 */
public void show() {
  // create the GUI for viewing the image if needed
  if (frame == null) {
    frame = new JFrame();
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menuBar.add(menu);
    JMenuItem menuItem1 = new JMenuItem(" Save...   ");
    menuItem1.addActionListener(this);
    // use getMenuShortcutKeyMaskEx() in Java 10 (getMenuShortcutKeyMask() deprecated)           
    menuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
                 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu.add(menuItem1);
    frame.setJMenuBar(menuBar);
    frame.setContentPane(getJLabel());
    // f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    if (filename == null) frame.setTitle(width + "-by-" + height);
    else                  frame.setTitle(filename);
    frame.setResizable(false);
    frame.pack();
    frame.setVisible(true);
  }
  // draw
  frame.repaint();
}

代码示例来源:origin: kevin-wayne/algs4

/**
 * Displays the picture in a window on the screen.
 */
public void show() {
  // create the GUI for viewing the image if needed
  if (frame == null) {
    frame = new JFrame();
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menuBar.add(menu);
    JMenuItem menuItem1 = new JMenuItem(" Save...   ");
    menuItem1.addActionListener(this);
    // use getMenuShortcutKeyMaskEx() in Java 10 (getMenuShortcutKeyMask() deprecated)
    menuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
                 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu.add(menuItem1);
    frame.setJMenuBar(menuBar);
    frame.setContentPane(getJLabel());
    // f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    if (filename == null) frame.setTitle(width + "-by-" + height);
    else                  frame.setTitle(filename);
    frame.setResizable(false);
    frame.pack();
    frame.setVisible(true);
  }
  // draw
  frame.repaint();
}

代码示例来源:origin: kevin-wayne/algs4

private void init() {
  if (frame != null) frame.setVisible(false);
  frame = new JFrame();
  offscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  onscreenImage  = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  frame.setResizable(false);
  frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);      // closes only current window
  frame.setFocusTraversalKeysEnabled(false);  // to recognize VK_TAB with isKeyPressed()
  frame.setTitle(name);
  frame.setJMenuBar(createMenuBar());
  frame.pack();
  frame.requestFocusInWindow();
  frame.setVisible(true);

代码示例来源:origin: kevin-wayne/algs4

private static void init() {
  if (frame != null) frame.setVisible(false);
  frame = new JFrame();
  offscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  onscreenImage  = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);            // closes all windows
  frame.setTitle("Standard Draw");
  frame.setJMenuBar(createMenuBar());
  frame.pack();
  frame.requestFocusInWindow();
  frame.setVisible(true);

相关文章

JFrame类方法