当前位置: 首页>>代码示例>>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;未经允许,请勿转载。