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

The following examples show how to use javax.swing.JFrame#setTitle() . 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 check out the related API usage on the sidebar.
Example 1
Source File: FlashWindow.java    From Spark with 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 2
Source File: BasicGraphEditor.java    From blog-codes with 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 File: AqlDisplay.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
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 4
Source File: DummyWindowManager.java    From netbeans with 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 5
Source File: SwingShowTooltipViewer.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 6
Source File: Frame.java    From A-Pathfinding-Visualization with 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 7
Source File: TestApp.java    From packr with 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 8
Source File: ComputeInstanceSimilarityBlock.java    From BART with 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 9
Source File: Regression_116627_swing.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 10
Source File: ImShow.java    From OptimizedImageEnhance with 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 11
Source File: Regression_117880_swing.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 File: Swing1.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 13
Source File: PokemonPanelForm.java    From dctb-utfpr-2018-1 with Apache License 2.0 5 votes vote down vote up
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 14
Source File: SwingChartViewerSelector.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 15
Source File: ShortKeyManagerUI.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
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 16
Source File: ServerApplication.java    From jt808 with 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 17
Source File: Regression_116630_swing.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 18
Source File: IceLeaf.java    From snowblossom with 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 19
Source File: JoglTestbedMain.java    From jbox2d with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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();
      }
    });
  }
 
Example 20
Source File: PhoneDialog.java    From Spark with 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;
}