當前位置: 首頁>>代碼示例>>Java>>正文


Java JFrame.setVisible方法代碼示例

本文整理匯總了Java中javax.swing.JFrame.setVisible方法的典型用法代碼示例。如果您正苦於以下問題:Java JFrame.setVisible方法的具體用法?Java JFrame.setVisible怎麽用?Java JFrame.setVisible使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JFrame的用法示例。


在下文中一共展示了JFrame.setVisible方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import javax.swing.JFrame; //導入方法依賴的package包/類
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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:JCheckTree.java

示例2: main

import javax.swing.JFrame; //導入方法依賴的package包/類
/**
 * @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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:DiscreteProgress.java

示例3: initAndShowUI

import javax.swing.JFrame; //導入方法依賴的package包/類
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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:MissingDragExitEventTest.java

示例4: main

import javax.swing.JFrame; //導入方法依賴的package包/類
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); 
}
 
開發者ID:cleitonferreira,項目名稱:LivroJavaComoProgramar10Edicao,代碼行數:20,代碼來源:ShapesTest.java

示例5: main

import javax.swing.JFrame; //導入方法依賴的package包/類
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());
}
 
開發者ID:BedrockDev,項目名稱:Sunrin2017,代碼行數:19,代碼來源:Swing01.java

示例6: createAndShowGUI

import javax.swing.JFrame; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:OpenDA-Association,項目名稱:OpenDA,代碼行數:27,代碼來源:TreeDemo.java

示例7: setup

import javax.swing.JFrame; //導入方法依賴的package包/類
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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:bug6921687.java

示例8: jTableConsultaMouseClicked

import javax.swing.JFrame; //導入方法依賴的package包/類
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);
   }
  
}
 
開發者ID:franco026,項目名稱:LOSY,代碼行數:19,代碼來源:ListMembers.java

示例9: initialize

import javax.swing.JFrame; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:hisener,項目名稱:bbm487s2017g1,代碼行數:34,代碼來源:CustomerMyBooksAndReservationsWindow.java

示例10: main

import javax.swing.JFrame; //導入方法依賴的package包/類
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);
}
 
開發者ID:takun2s,項目名稱:smile_1.5.0_java7,代碼行數:8,代碼來源:MultivariateGaussianDistributionDemo.java

示例11: createAndShowGUI

import javax.swing.JFrame; //導入方法依賴的package包/類
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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:HorizontalMouseWheelOnShiftPressed.java

示例12: main

import javax.swing.JFrame; //導入方法依賴的package包/類
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);
}
 
開發者ID:cleitonferreira,項目名稱:LivroJavaComoProgramar10Edicao,代碼行數:12,代碼來源:ShowColors.java

示例13: run

import javax.swing.JFrame; //導入方法依賴的package包/類
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();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:13,代碼來源:Test6541987.java

示例14: main

import javax.swing.JFrame; //導入方法依賴的package包/類
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);
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:14,代碼來源:FileConfigurer.java

示例15: CompositionArea

import javax.swing.JFrame; //導入方法依賴的package包/類
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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:CompositionArea.java


注:本文中的javax.swing.JFrame.setVisible方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。