Java Code Examples for javax.swing.JFrame#setTitle()

The following examples show how to use javax.swing.JFrame#setTitle() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
private void showGraph(JComponent j, String str) {
	JFrame f = new JFrame();

	ActionListener escListener = (ActionEvent e) -> {
		env = null;
		f.dispose();
	};
	f.getRootPane().registerKeyboardAction(escListener, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
			JComponent.WHEN_IN_FOCUSED_WINDOW);
	KeyStroke ctrlW = KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK);
	KeyStroke commandW = KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.META_DOWN_MASK);
	f.getRootPane().registerKeyboardAction(escListener, ctrlW, JComponent.WHEN_IN_FOCUSED_WINDOW);
	f.getRootPane().registerKeyboardAction(escListener, commandW, JComponent.WHEN_IN_FOCUSED_WINDOW);

	f.add(j);

	f.setSize(600, 540);
	f.setTitle(str + " for " + title);
	f.setLocationRelativeTo(null);
	f.setVisible(true);
}
 
Example 2
Source Project: blog-codes   File: BasicGraphEditor.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 */
public void updateTitle()
{
	JFrame frame = (JFrame) SwingUtilities.windowForComponent(this);

	if (frame != null)
	{
		String title = (currentFile != null) ? currentFile
				.getAbsolutePath() : mxResources.get("newDiagram");

		if (modified)
		{
			title += "*";
		}

		frame.setTitle(title + " - " + appTitle);
	}
}
 
Example 3
Source Project: Spark   File: FlashWindow.java    License: Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
	final JFrame frame = new JFrame();
	frame.setTitle("Test");
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().setLayout(new FlowLayout());
	JButton button = new JButton("Temp Flashing");
	frame.getContentPane().add(button);
	final FlashWindow winutil = new FlashWindow();
	button.addActionListener( evt -> winutil.flash(frame, 750, 5) );

	JButton startButton = new JButton("Start Flashing");
	frame.getContentPane().add(startButton);
	startButton.addActionListener( evt -> winutil.startFlashing(frame) );

	JButton stopButton = new JButton("Stop Flashing");
	frame.getContentPane().add(stopButton);
	stopButton.addActionListener( evt -> {
           // winutil.flash(frame,750,1500,5);
           winutil.stopFlashing(frame);
       } );
	frame.pack();
	frame.setVisible(true);
}
 
Example 4
/**
 * Contructs the layout with a container for displaying chart and a control
 * panel for selecting interactivity.
 * 
 * @param args
 */
public static void main( String[] args )
{
	final Regression_116630_swing siv = new Regression_116630_swing( );

	JFrame jf = new JFrame( );
	jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
	jf.addComponentListener( siv );

	Container co = jf.getContentPane( );
	co.setLayout( new BorderLayout( ) );
	co.add( siv, BorderLayout.CENTER );

	Dimension dScreen = Toolkit.getDefaultToolkit( ).getScreenSize( );
	Dimension dApp = new Dimension( 600, 400 );
	jf.setSize( dApp );
	jf.setLocation(
			( dScreen.width - dApp.width ) / 2,
			( dScreen.height - dApp.height ) / 2 );

	jf.setTitle( siv.getClass( ).getName( ) + " [device=" //$NON-NLS-1$
			+ siv.idr.getClass( ).getName( ) + "]" );//$NON-NLS-1$

	ControlPanel cp = siv.new ControlPanel( siv );
	co.add( cp, BorderLayout.SOUTH );

	siv.idr.setProperty( IDeviceRenderer.UPDATE_NOTIFIER, siv );

	jf.addWindowListener( new WindowAdapter( ) {

		public void windowClosing( WindowEvent e )
		{
			siv.idr.dispose( );
		}

	} );

	jf.setVisible( true );
}
 
Example 5
Source Project: jt808   File: ServerApplication.java    License: Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	//初始化spring容器
       appCtx = new ClassPathXmlApplicationContext("applicationContext.xml");
       
       //初始化netty
	new ServerApplication(6666).startServer();
	
	//初始化窗口,这个窗口只是用来展示服务端是否启动
	JFrame frame = new JFrame();  
       frame.setTitle("终端通讯服务端(这个窗口只是用来展示服务端是否启动)");
       frame.setSize(618, 381);
       frame.setVisible(true);
       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
 
Example 6
public static void main(String[] args) {
	JFrame f = new JFrame();
	f.getContentPane().add(new ShortKeyManagerUI());
	f.setTitle("test");
	f.pack();
	f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	f.setVisible(true);
}
 
Example 7
/**
 * Contructs the layout with a container for displaying chart and a control
 * panel for selecting chart attributes.
 * 
 * @param args
 */
public static void main( String[] args )
{
	SwingChartViewerSelector scv = new SwingChartViewerSelector( );

	JFrame jf = new JFrame( );
	jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
	jf.addComponentListener( scv );

	Container co = jf.getContentPane( );
	co.setLayout( new BorderLayout( ) );
	co.add( scv, BorderLayout.CENTER );

	Dimension dScreen = Toolkit.getDefaultToolkit( ).getScreenSize( );
	Dimension dApp = new Dimension( 800, 600 );
	jf.setSize( dApp );
	jf.setLocation( ( dScreen.width - dApp.width ) / 2,
			( dScreen.height - dApp.height ) / 2 );

	jf.setTitle( scv.getClass( ).getName( ) + " [device=" //$NON-NLS-1$
			+ scv.idr.getClass( ).getName( )
			+ "]" );//$NON-NLS-1$

	ControlPanel cp = scv.new ControlPanel( scv );
	co.add( cp, BorderLayout.SOUTH );

	jf.setVisible( true );
}
 
Example 8
private void btnModifyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModifyActionPerformed
    JFrame form = new JFrame();
    form.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    form.setTitle("Alterar");
    form.setResizable(false);
    form.setSize(new Dimension(347, 296));
    form.add(new PokemonPanelData(form));
    form.setVisible(true);
}
 
Example 9
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();
}
 
Example 10
Source Project: netbeans   File: DummyWindowManager.java    License: Apache License 2.0 5 votes vote down vote up
protected void topComponentDisplayNameChanged(TopComponent tc, String displayName) {
    JFrame f = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, tc);

    if (f != null) {
        f.setTitle(displayName);
    }
}
 
Example 11
/**
 * Contructs the layout with a container for displaying chart and a control
 * panel for selecting interactivity.
 * 
 * @param args
 */
public static void main( String[] args )
{
	final Regression_117880_swing siv = new Regression_117880_swing( );

	JFrame jf = new JFrame( );
	jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
	jf.addComponentListener( siv );

	Container co = jf.getContentPane( );
	co.setLayout( new BorderLayout( ) );
	co.add( siv, BorderLayout.CENTER );

	Dimension dScreen = Toolkit.getDefaultToolkit( ).getScreenSize( );
	Dimension dApp = new Dimension( 600, 400 );
	jf.setSize( dApp );
	jf.setLocation(
			( dScreen.width - dApp.width ) / 2,
			( dScreen.height - dApp.height ) / 2 );

	jf.setTitle( siv.getClass( ).getName( ) + " [device=" //$NON-NLS-1$
			+ siv.idr.getClass( ).getName( ) + "]" );//$NON-NLS-1$

	ControlPanel cp = siv.new ControlPanel( siv );
	co.add( cp, BorderLayout.SOUTH );

	siv.idr.setProperty( IDeviceRenderer.UPDATE_NOTIFIER, siv );

	jf.addWindowListener( new WindowAdapter( ) {

		public void windowClosing( WindowEvent e )
		{
			siv.idr.dispose( );
		}

	} );

	jf.setVisible( true );
}
 
Example 12
Source Project: OptimizedImageEnhance   File: ImShow.java    License: MIT License 5 votes vote down vote up
public ImShow(String title) {
	Window = new JFrame();
	image = new ImageIcon();
	label = new JLabel();
	// matOfByte = new MatOfByte();
	label.setIcon(image);
	Window.getContentPane().add(label);
	Window.setResizable(false);
	Window.setTitle(title);
	SizeCustom = false;
	setCloseOption(0);
}
 
Example 13
/**
 * Contructs the layout with a container for displaying chart and a control
 * panel for selecting interactivity.
 * 
 * @param args
 */
public static void main( String[] args )
{
	final Regression_116627_swing siv = new Regression_116627_swing( );

	JFrame jf = new JFrame( );
	jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
	jf.addComponentListener( siv );

	Container co = jf.getContentPane( );
	co.setLayout( new BorderLayout( ) );
	co.add( siv, BorderLayout.CENTER );

	Dimension dScreen = Toolkit.getDefaultToolkit( ).getScreenSize( );
	Dimension dApp = new Dimension( 600, 400 );
	jf.setSize( dApp );
	jf.setLocation(
			( dScreen.width - dApp.width ) / 2,
			( dScreen.height - dApp.height ) / 2 );

	jf.setTitle( siv.getClass( ).getName( ) + " [device=" //$NON-NLS-1$
			+ siv.idr.getClass( ).getName( ) + "]" );//$NON-NLS-1$

	ControlPanel cp = siv.new ControlPanel( siv );
	co.add( cp, BorderLayout.SOUTH );

	siv.idr.setProperty( IDeviceRenderer.UPDATE_NOTIFIER, siv );

	jf.addWindowListener( new WindowAdapter( ) {

		public void windowClosing( WindowEvent e )
		{
			siv.idr.dispose( );
		}

	} );

	jf.setVisible( true );
}
 
Example 14
Source Project: BART   File: ComputeInstanceSimilarityBlock.java    License: MIT License 5 votes vote down vote up
private void saveGraph(UndirectedGraph<TupleWithTable, DefaultEdge> instancesGraph) {
        JGraphXAdapter<TupleWithTable, DefaultEdge> jgxAdapterContext = new JGraphXAdapter<TupleWithTable, DefaultEdge>(instancesGraph);
        jgxAdapterContext.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_NOLABEL, "1");
        jgxAdapterContext.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_ENDARROW, "0");
        jgxAdapterContext.setCellsEditable(false);
        jgxAdapterContext.setCellsMovable(false);
        jgxAdapterContext.setEdgeLabelsMovable(false);
        jgxAdapterContext.setCellsDeletable(false);
        jgxAdapterContext.setCellsDisconnectable(false);
        jgxAdapterContext.setCellsResizable(false);
        jgxAdapterContext.setCellsBendable(false);
        JFrame frame = new JFrame();
        mxGraphComponent mxGraphComponent = new mxGraphComponent(jgxAdapterContext);
        frame.getContentPane().add(mxGraphComponent, BorderLayout.CENTER);
        mxHierarchicalLayout layout = new mxHierarchicalLayout(jgxAdapterContext);
        layout.execute(jgxAdapterContext.getDefaultParent());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setTitle("Graph");
        frame.pack();
        frame.setLocationRelativeTo(null);
//        frame.setVisible(true);
//        try {
//            while (true) {
//                Thread.sleep(500);
//            }
//        } catch (InterruptedException ex) {
//            java.util.logging.Logger.getLogger(ComputeInstanceSimilarityBlock.class.getName()).log(Level.SEVERE, null, ex);
//        }
        try {
            BufferedImage image = mxCellRenderer.createBufferedImage(jgxAdapterContext, null, 1, Color.WHITE, true, null);
            File file = new File("/Users/Shared/Temp/bart/similarity/instances-graph.png");
            file.getParentFile().mkdirs();
            ImageIO.write(image, "PNG", file);
        } catch (IOException ex) {
            logger.error("Unable to save graph image: " + ex.getLocalizedMessage());
        }
    }
 
Example 15
Source Project: packr   File: TestApp.java    License: Apache License 2.0 5 votes vote down vote up
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());
}
 
Example 16
Source Project: A-Pathfinding-Visualization   File: Frame.java    License: MIT License 5 votes vote down vote up
public Frame() {
	ch = new ControlHandler(this);
	size = 25;
	mode = "Map Creation";
	showSteps = true;
	btnHover = false;
	setLayout(null);
	addMouseListener(this);
	addMouseMotionListener(this);
	addMouseWheelListener(this);
	addKeyListener(this);
	setFocusable(true);
	setFocusTraversalKeysEnabled(false);

	// Set up pathfinding
	pathfinding = new APathfinding(this, size);
	pathfinding.setDiagonal(true);
	
	// Calculating value of a in speed function 1
	a1 = (5000.0000 / (Math.pow(25.0000/5000, 1/49)));
	a2 = 625.0000;
	
	// Set up window
	window = new JFrame();
	window.setContentPane(this);
	window.setTitle("A* Pathfinding Visualization");
	window.getContentPane().setPreferredSize(new Dimension(700, 600));
	window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	window.pack();
	window.setLocationRelativeTo(null);
	window.setVisible(true);
	
	// Add all controls
	ch.addAll();
	
	this.revalidate();
	this.repaint();
}
 
Example 17
/**
 * Constructs the layout with a container for displaying chart and a control
 * panel for selecting interactivity.
 * 
 * @param args
 */
public static void main( String[] args )
{
	final SwingShowTooltipViewer siv = new SwingShowTooltipViewer( );

	JFrame jf = new JFrame( );
	jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
	jf.addComponentListener( siv );

	Container co = jf.getContentPane( );
	co.setLayout( new BorderLayout( ) );
	co.add( siv, BorderLayout.CENTER );

	Dimension dScreen = Toolkit.getDefaultToolkit( ).getScreenSize( );
	Dimension dApp = new Dimension( 600, 400 );
	jf.setSize( dApp );
	jf.setLocation(
			( dScreen.width - dApp.width ) / 2,
			( dScreen.height - dApp.height ) / 2 );

	jf.setTitle( siv.getClass( ).getName( ) + " [device=" //$NON-NLS-1$
			+ siv.idr.getClass( ).getName( ) + "]" );//$NON-NLS-1$

	ControlPanel cp = siv.new ControlPanel( siv );
	co.add( cp, BorderLayout.SOUTH );

	siv.idr.setProperty( IDeviceRenderer.UPDATE_NOTIFIER, siv );

	jf.addWindowListener( new WindowAdapter( ) {

		@Override
		public void windowClosing( WindowEvent e )
		{
			siv.idr.dispose( );
		}

	} );

	jf.setVisible( true );
}
 
Example 18
Source Project: Spark   File: PhoneDialog.java    License: Apache License 2.0 4 votes vote down vote up
public static JFrame invoke(JComponent comp, String title, String description, ImageIcon icon) {
    final JFrame frame = new JFrame();

    frame.setIconImage(SparkRes.getImageIcon(SparkRes.TELEPHONE_24x24).getImage());
    frame.setTitle(title);

    frame.getContentPane().setLayout(new BorderLayout());

    frame.getContentPane().add(comp, BorderLayout.CENTER);
    frame.pack();
    frame.setSize(300, 200);

    // Center panel on screen
    GraphicUtils.centerWindowOnScreen(frame);

    frame.setVisible(true);

    return frame;
}
 
Example 19
Source Project: snowblossom   File: IceLeaf.java    License: Apache License 2.0 4 votes vote down vote up
public void run()
{

  JFrame f=new JFrame();
  f.setVisible(true);
  f.setDefaultCloseOperation( f.EXIT_ON_CLOSE);
  f.setBackground(getBGColor());

  try
  {
    InputStream is = IceLeaf.class.getResourceAsStream(getResourceBasePath() +"/iceleaf-ui/resources/flower-with-ink-256.png");
    f.setIconImage(ImageIO.read(is));

  }
  catch(Exception e)
  {
    e.printStackTrace();
  }


  String title = getTitle();
  if (!params.getNetworkName().equals("snowblossom"))
  {
    title = title + " - " + params.getNetworkName();
  }
  f.setTitle(title);
  f.setSize(950, 600);

  JTabbedPane tab_pane = new JTabbedPane();

  f.setContentPane(tab_pane);

  // should be first to initialize settings to default
  settings_panel.setup();

  node_panel.setup();
  node_select_panel.setup();
  wallet_panel.setup();
  make_wallet_panel.setup();
  send_panel.setup();
  address_panel.setup();
  history_panel.setup();
  receive_panel.setup();

  tab_pane.add("Wallets", wallet_panel.getPanel());
  tab_pane.add("Send", send_panel.getPanel());
  tab_pane.add("Receive", receive_panel.getPanel());
  tab_pane.add("Addresses", address_panel.getPanel());
  tab_pane.add("History", history_panel.getPanel());
  tab_pane.add("Make Wallet", make_wallet_panel.getPanel());
  tab_pane.add("Node Selection", node_select_panel.getPanel());
  tab_pane.add("Node", node_panel.getPanel());
  tab_pane.add("Settings", settings_panel.getPanel());

  setupMorePanels(tab_pane, f);

  UIUtil.applyLook(f, ice_leaf);
  
}
 
Example 20
public static void main(String[] args) {
//    try {
//      UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
//    } catch (Exception e) {
//      // log.warn("Could not set the look and feel to nimbus.  "
//      // + "Hopefully you're on a mac so the window isn't ugly as crap.");
//    }
    TestbedModel model = new TestbedModel();
    final TestbedController controller =
        new TestbedController(model, UpdateBehavior.UPDATE_IGNORED, MouseBehavior.FORCE_Y_FLIP,
            new TestbedErrorHandler() {
              @Override
              public void serializationError(Exception e, String message) {
                JOptionPane.showMessageDialog(null, message, "Serialization Error",
                    JOptionPane.ERROR_MESSAGE);
              }
            });
    JoglPanel panel = new JoglPanel(model, controller);
    model.setDebugDraw(new JoglDebugDraw(panel));
    model.setPanel(panel);
    TestList.populateModel(model);
    model.getSettings().getSetting(TestbedSettings.DrawWireframe).enabled = false;

    JFrame testbed = new JFrame();
    testbed.setTitle("JBox2D Testbed");
    testbed.setLayout(new BorderLayout());
    TestbedSidePanel side = new TestbedSidePanel(model, controller);
    testbed.add((Component) panel, "Center");
    testbed.add(new JScrollPane(side), "East");
    testbed.pack();
    testbed.setVisible(true);
    testbed.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        controller.playTest(0);
        controller.start();
      }
    });
  }