Java Code Examples for javax.swing.JFrame.setVisible()

The following are Jave code examples for showing how to use setVisible() of the javax.swing.JFrame class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: JCheckTree.java   View Source Code Vote up 6 votes
public static void main(String[] args) {
    JFrame frame = new JFrame("JCheckTreeTester"); // NOI18N

    try {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); // NOI18N
    } catch (Exception e) {
    }

    ;

    JCheckTree checkTree = new JCheckTree();
    checkTree.addCheckTreeListener(new CheckTreeListener() {
            public void checkTreeChanged(Collection changedNodes) {
                System.out.println(changedNodes);
            }

            public void checkNodeToggled(TreePath path, boolean before) {
                System.out.println("Node toggled"); // NOI18N
            }
        });

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new JScrollPane(checkTree));
    frame.pack();
    frame.setVisible(true);
}
 
Example 2
Project: incubator-netbeans   File: DiscreteProgress.java   View Source Code Vote up 6 votes
/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    try {
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    }

    ;

    DiscreteProgress progress = new DiscreteProgress();

    JFrame testFrame = new JFrame("Decimal Progress Test Frame"); // NOI18N
    testFrame.getContentPane().add(progress);
    testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    testFrame.pack();
    testFrame.setVisible(true);
}
 
Example 3
Project: openjdk-jdk10   File: MissingDragExitEventTest.java   View Source Code Vote up 6 votes
private static void initAndShowUI() {
    frame = new JFrame("Test frame");

    frame.setSize(SIZE, SIZE);
    frame.setLocationRelativeTo(null);
    final JTextArea jta = new JTextArea();
    jta.setBackground(Color.RED);
    frame.add(jta);
    jta.setText("1234567890");
    jta.setFont(jta.getFont().deriveFont(150f));
    jta.setDragEnabled(true);
    jta.selectAll();
    jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY,
                                     new TestdropTargetListener()));
    jta.addMouseListener(new TestMouseAdapter());
    frame.setVisible(true);
}
 
Example 4
Project: LivroJavaComoProgramar10Edicao   File: ShapesTest.java   View Source Code Vote up 6 votes
public static void main(String[] args)
{
   // obtain user's choice
   String input = JOptionPane.showInputDialog(
      "Enter 1 to draw rectangle\n" +
      "Enter 2 to draw ovals");
   
   int choice = Integer.parseInt(input); // convert input to int
   
   // create the panel with the user's input
   Shapes panel = new Shapes(choice);
   
   JFrame application = new JFrame(); // creates a new JFrame

   application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   application.add(panel); 
   application.setSize(300, 300); 
   application.setVisible(true); 
}
 
Example 5
Project: Sunrin2017   File: Swing01.java   View Source Code Vote up 6 votes
public static void main(String[] args) {
	JFrame frame = new JFrame();

	frame.setVisible(true);
	frame.setSize(new Dimension(1280, 720));
	// this kills the process on exit
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setTitle("Hello");

	JLabel label = new JLabel("Hello world");
	frame.add(label);

	JButton button = new JButton("Set zum as your homepage");
	button.addMouseListener(new CustomListener());
	frame.add(button);

	frame.setLayout(new FlowLayout());
}
 
Example 6
Project: OpenDA   File: TreeDemo.java   View Source Code Vote up 6 votes
/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event dispatch thread.
 */
private static void createAndShowGUI() {
    if (useSystemLookAndFeel) {
        try {
            UIManager.setLookAndFeel(
                UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            System.err.println("Couldn't use system look and feel.");
        }
    }

    //Create and set up the window.
    JFrame frame = new JFrame("TreeDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Add content to the window.
    frame.add(new TreeDemo());

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}
 
Example 7
Project: openjdk-jdk10   File: bug6921687.java   View Source Code Vote up 6 votes
private static void setup(JFrame frame) {
    JMenuBar menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);

    // First Menu, F - Mnemonic
    JMenu firstMenu = new JMenu("First Menu");
    firstMenu.setMnemonic(KeyEvent.VK_F);
    firstMenu.add(new JMenuItem("One", KeyEvent.VK_O));
    firstMenu.add(new JMenuItem("Two", KeyEvent.VK_T));
    menuBar.add(firstMenu);

    // Second Menu, S - Mnemonic
    JMenu secondMenu = new JMenu("Second Menu");
    secondMenu.setMnemonic(KeyEvent.VK_S);
    secondMenu.add(new JMenuItem("A Menu Item", KeyEvent.VK_A));
    menuBar.add(secondMenu);

    frame.setSize(350, 250);
    frame.setVisible(true);
}
 
Example 8
Project: LOSY   File: ListMembers.java   View Source Code Vote up 6 votes
private void jTableConsultaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableConsultaMouseClicked
   DefaultTableModel tabla = (DefaultTableModel) jTableConsulta.getModel();
   String dato=String.valueOf(tabla.getValueAt(jTableConsulta.getSelectedRow(), 0));
   int code = Integer.parseInt(dato);
   JOptionPane.showMessageDialog(null, position);
   if(position.equals("Director de laboratorio")){
   JFrame edit = new JFrame();
   edit.setVisible(true);
   edit.setSize(700, 500);
   
   
   EditProfile editProfile = new EditProfile(code,position);
   editProfile.setBounds(0, 0, 615, 450);
   
   edit.getContentPane().add(editProfile,null);
   }
  
}
 
Example 9
Project: smile_1.5.0_java7   File: MultivariateGaussianDistributionDemo.java   View Source Code Vote up 5 votes
public static void main(String[] args) {
    JFrame frame = new JFrame("MultivariateGaussian Distribution");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
    frame.getContentPane().add(new MultivariateGaussianDistributionDemo());
    frame.setVisible(true);
}
 
Example 10
Project: openjdk-jdk10   File: HorizontalMouseWheelOnShiftPressed.java   View Source Code Vote up 5 votes
static void createAndShowGUI() {
    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    textArea = new JTextArea("Hello World!");
    scrollPane = new JScrollPane(textArea);
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(scrollPane, BorderLayout.CENTER);
    frame.getContentPane().add(panel);
    frame.setVisible(true);
}
 
Example 11
Project: LivroJavaComoProgramar10Edicao   File: ShowColors.java   View Source Code Vote up 5 votes
public static void main(String[] args)
{
   // create frame for ColorJPanel
   JFrame frame = new JFrame("Using colors");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

   ColorJPanel colorJPanel = new ColorJPanel();
   frame.add(colorJPanel); 
   frame.setSize(400, 180);
   frame.setVisible(true);
}
 
Example 12
Project: jdk8u-jdk   File: Test6541987.java   View Source Code Vote up 5 votes
public void run() {
    String title = getClass().getName();
    JFrame frame = new JFrame(title);
    frame.setVisible(true);

    Color color = JColorChooser.showDialog(frame, title, Color.BLACK);
    if (color != null) {
        throw new Error("unexpected color: " + color);
    }
    frame.setVisible(false);
    frame.dispose();
}
 
Example 13
Project: VASSAL-src   File: FileConfigurer.java   View Source Code Vote up 5 votes
public static void main(String args[]) {
  final JFrame f = new JFrame();
  final FileConfigurer c =
    new ImageConfigurer(null, "Test file", new ArchiveWriter("testArchive"));
  c.addPropertyChangeListener(new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent evt) {
      System.err.println(String.valueOf(evt.getNewValue()));
    }
  });
  f.getContentPane().add(c.getControls());
  f.pack();
  f.setVisible(true);
}
 
Example 14
Project: openjdk-jdk10   File: CompositionArea.java   View Source Code Vote up 5 votes
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
Example 15
Project: bbm487s2017g1   File: CustomerMyBooksAndReservationsWindow.java   View Source Code Vote up 5 votes
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame("Library Book Loan System - My Books and Reservations");
    frame.setResizable(false);
    frame.setBounds(100, 100, 700, 400);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);
    
    JLabel label = new JLabel("Library Book Loan System");
    label.setHorizontalAlignment(SwingConstants.CENTER);
    label.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
    label.setBounds(10, 11, 674, 30);
    frame.getContentPane().add(label);
    
    JLabel lblBookReservations = new JLabel("My Books and Reservations");
    lblBookReservations.setHorizontalAlignment(SwingConstants.CENTER);
    lblBookReservations.setFont(new Font("Segoe UI Light", Font.PLAIN, 14));
    lblBookReservations.setBounds(10, 42, 674, 22);
    frame.getContentPane().add(lblBookReservations);
        
    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setBackground(SystemColor.text);
    tabbedPane.setBounds(10, 75, 674, 228);
    frame.getContentPane().add(tabbedPane);
    
    initializeCurrentBooks(tabbedPane);
    initializeWaitlist(tabbedPane);
    initializeHistory(tabbedPane);
    
    frame.setVisible(true);
}
 
Example 16
Project: Tarski   File: OurUtil.java   View Source Code Vote up 5 votes
/** Make the frame visible, non-iconized, and focused. */
public static void show(JFrame frame) {
   frame.setVisible(true);
   frame.setExtendedState(frame.getExtendedState() & ~JFrame.ICONIFIED);
   frame.requestFocus();
   frame.toFront();
}
 
Example 17
Project: Logisim   File: WindowMenuItem.java   View Source Code Vote up 4 votes
public void actionPerformed(ActionEvent event) {
	JFrame frame = getJFrame();
	frame.setExtendedState(Frame.NORMAL);
	frame.setVisible(true);
	frame.toFront();
}
 
Example 18
Project: batmapper   File: MapperTest1.java   View Source Code Vote up 4 votes
public static void main( String[] args ) {
        SparseMultigraph<Room, Exit> graph = new SparseMultigraph<Room, Exit>();


        MapperEngine engine = new MapperEngine( graph );

        JFrame frame = new JFrame( "Simple Graph View" );
        frame.setLayout( new FlowLayout() );
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        frame.getContentPane().add( engine.getPanel() );

        frame.pack();
        frame.setVisible( true );

        HashSet<String> exits = new HashSet<String>();
        exits.add( "ne" );
        exits.add( "n" );
        engine.moveToRoom( "testArea", "1", "enter path", false, "areaFirstRoom", "jshgfskgyfhsgfjhtsgdfhgsdfsygfsgdyfuysgdfjkhsgdfskuygfsuygfusygfuysd", exits );
        exits.clear();
        exits.add( "ne" );
        exits.add( "n" );
        exits.add( "w" );
        exits.add( "sw" );
        engine.moveToRoom( "testArea", "2", "n", false, "secondRoom", "jshgfskgyfhsgfjhtsgdfhgsdfsygfsgdyfuysgdfjkhsgdfskuygfsuygfusygfuysd", exits );
        exits.clear();
        exits.add( "ne" );
        exits.add( "n" );
        exits.add( "w" );
        exits.add( "sw" );
        engine.moveToRoom( "testArea", "3", "e", true, "thirdRoom", "jshgfskgyfhsgfjhtsgdfhgsdfsygfsgdyfuysgdfjkhsgdfskuygfsuygfusygfuysd", exits );
        exits.clear();
        exits.add( "ne" );
        exits.add( "n" );
        exits.add( "w" );
        exits.add( "sw" );
        engine.moveToRoom( "testArea", "4", "s", true, "fourthRoom", "jshgfskgyfhsgfjhtsgdfhgsdfsygfsgdyfuysgdfjkhsgdfskuygfsuygfusygfuysd", exits );
        exits.clear();
        exits.add( "w" );
        exits.add( "w" );
        exits.add( "e" );
        exits.add( "e" );
        engine.moveToRoom( "testArea", "5", "w", true, "fifthRoom", "jshgfskgyfhsgfjhtsgdfhgsdfsygfsgdyfuysgdfjkhsgdfskuygfsuygfusygfuysd", exits );
        exits.clear();
        exits.add( "ne" );
        exits.add( "nw" );
        exits.add( "sw" );
        exits.add( "se" );
        engine.moveToRoom( "testArea", "6", "n", false, "sixthRoom", "jshgfskgyfhsgfjhtsgdfhgsdfsygfsgdyfuysgdfjkhsgdfskuygfsuygfusygfuysd", exits );
        exits.clear();
        exits.add( "ne" );
        exits.add( "nw" );
        exits.add( "sw" );
        exits.add( "se" );
        engine.moveToRoom( "testArea", "7", "s", true, "seventhRoom", "jshgfskgyfhsgfjhtsgdfhgsdfsygfsgdyfuysgdfjkhsgdfskuygfsuygfusygfuysd", exits );
//    	exits.clear(); exits.add("ne"); exits.add("nw");exits.add("sw"); exits.add("se");
//    	engine.moveToRoom("testArea", "1", "jump to start", false, "areaFirstRoom", "jshgfskgyfhsgfjhtsgdfhgsdfsygfsgdyfuysgdfjkhsgdfskuygfsuygfusygfuysd", exits);

    }
 
Example 19
Project: What-Happened-to-Station-7   File: Station7.java   View Source Code Vote up 4 votes
public static void main(String... args) throws Throwable
{
	JFrame window = new JFrame();
	window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	window.setTitle("What Happened to Station 7");
	window.setMinimumSize(new Dimension(400, 225));
	window.setLayout(new GridBagLayout());
	window.setExtendedState(JFrame.MAXIMIZED_BOTH);

	JFrame opening_text = new JFrame();
	opening_text.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	opening_text.setTitle("This Is What Happened to Station 7");
	JTextArea textField = new JTextArea(
			"The date is 123.5432.1241511    Station 7 is in full operation when suddenly one of the arachnids spot a rather large blue and yellow battle-cruiser barreling towards the aft section of the outer wheel. It suddenly plunges it self deep within the station. The flag suddenly comes within view… Its the swedes on their eternal quest to increase their GDP. They start to scatter but they are not quick enough to survive the army of Carl XVI Gustaf. The Dramatic entrance of the battle-cruiser had created a hull breach and the amount of air in the station was starting to drop; those blast doors can only hold so long….																																																		You Play as the aliens represented by the Purple hexes your objective is to get to the next floor of Staition 7 via the cyan ecape doors the sweds represented by the blue tiles are out to get you it would be in your best intrests to avoid them as they will kill you very quickly, if you notics your color shifting it indicats a change in helth and you will be best adviced to seek out the red health boxes but be carful as they will only heal you so much");
	textField.setLineWrap(true);
	textField.setWrapStyleWord(true);
	opening_text.setMinimumSize(new Dimension(400, 225));
	opening_text.add(textField, BorderLayout.PAGE_START);
	opening_text.setExtendedState(JFrame.MAXIMIZED_BOTH);
	opening_text.setAlwaysOnTop(true);

	JFrame closing_text = new JFrame();
	closing_text.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	closing_text.setTitle("You Have Fell to the Swedes");
	JTextArea text = new JTextArea("You have failed to save your self…. The swedes trudge on obliterating the remaining inhabitants of the station. ");
	text.setLineWrap(true);
	text.setWrapStyleWord(true);
	closing_text.setMinimumSize(new Dimension(400, 225));
	closing_text.add(text, BorderLayout.PAGE_START);
	closing_text.setExtendedState(JFrame.MAXIMIZED_BOTH);

	SoundStuff soundStuff = new SoundStuff();
	soundStuff.dbol();

	Game game = new Game();

	GameRenderer render = new GameRenderer(game);
	render.addListeners(window);
	GridBagConstraints layoutGame = new GridBagConstraints();
	layoutGame.weightx = .9;
	layoutGame.weighty = .9;
	layoutGame.fill = GridBagConstraints.BOTH;
	layoutGame.anchor = GridBagConstraints.NORTH;
	window.add(render, layoutGame);

	GameInfo info = new GameInfo(game);
	info.addListeners();
	GridBagConstraints layoutInfo = new GridBagConstraints();
	layoutInfo.weightx = .1;
	layoutInfo.weighty = .1;
	layoutInfo.fill = GridBagConstraints.BOTH;
	layoutInfo.anchor = GridBagConstraints.NORTH;
	layoutInfo.gridy = 1;
	window.add(info, layoutInfo);

	game.init(render.new UIInterface(), info.new UIInterface());

	closing_text.setVisible(true);
	window.setVisible(true);
	opening_text.setVisible(true);
	Scanner reader = new Scanner(System.in);
	int n = reader.nextInt();
	if (n == 42)
	{
		System.out.print("adadfafd");
		SoundStuff cam = null;
		cam = new SoundStuff();
		cam.CCCP();
		reader.close();
	}
}
 
Example 20
Project: Logisim   File: PreferencesFrame.java   View Source Code Vote up 4 votes
public static void showPreferences() {
	JFrame frame = MENU_MANAGER.getJFrame(true);
	frame.setVisible(true);
}