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

The following examples show how to use javax.swing.JFrame#setVisible() . 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 check out the related API usage on the sidebar.
Example 1
public void show() {
    JPanel p = new JPanel(new BorderLayout()) {
        public void paintComponent(Graphics g) {
            g.setColor(Color.blue);
            g.fillRect(0, 0, getWidth(), getHeight());
        }
    };
    p.add(new ImageComponent(src), BorderLayout.WEST);
    if (dst != null) {
    p.add(new ImageComponent(dst), BorderLayout.EAST);
    }

    JFrame f = new JFrame("Transparency");
    f.add(p);

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
}
 
Example 2
public SaneAppletExample(String title, String[] argv){    
    JFrame.setDefaultLookAndFeelDecorated(true);

    JFrame frame=new JFrame(title);
//    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent ev) {
        stop();System.exit(0);
      }
    });

    init();

    frame.getContentPane().add(this);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    start();
  }
 
Example 3
@Override
public void componentShown(ComponentEvent e) {
    JFrame frame = (JFrame) e.getComponent();

    runActualTest(device, latch, frame, result);

    frame.setVisible(false);
    frame.dispose();
    latch.countDown();
}
 
Example 4
private static void printTexture() {
    f = new JFrame("Texture Printing Test");
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    final TexturePaintPrintingTest gpt = new TexturePaintPrintingTest();
    Container c = f.getContentPane();
    c.add(BorderLayout.CENTER, gpt);

    final JButton print = new JButton("Print");
    print.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PrinterJob job = PrinterJob.getPrinterJob();
            job.setPrintable(gpt);
            final boolean doPrint = job.printDialog();
            if (doPrint) {
                try {
                    job.print();
                } catch (PrinterException ex) {
                    throw new RuntimeException(ex);
                }
            }
        }
    });
    c.add(print, BorderLayout.SOUTH);

    f.pack();
    f.setVisible(true);
}
 
Example 5
Source Project: android-classyshark   File: Toolbar.java    License: Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    JFrame frame = new JFrame("ClassyShark");
    Toolbar toolbar = new Toolbar(null);
    toolbar.addKeyListenerToTypingArea(null);

    frame.getContentPane().add(toolbar);

    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}
 
Example 6
Source Project: meka   File: MicroCurve.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
  if (args.length != 1)
    throw new IllegalArgumentException("Required arguments: <dataset>");

  System.out.println("Loading data: " + args[0]);
  Instances data = DataSource.read(args[0]);
  MLUtils.prepareData(data);

  System.out.println("Cross-validate BR classifier");
  BR classifier = new BR();
  // further configuration of classifier
  String top = "PCut1";
  String vop = "3";
  Result result = Evaluation.cvModel(classifier, data, 10, top, vop);

  JFrame frame = new JFrame("Micro curve");
  frame.setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE);
  frame.getContentPane().setLayout(new BorderLayout());
  Instances performance = (Instances) result.getMeasurement(CURVE_DATA_MICRO);
  try {
    VisualizePanel panel = createPanel(performance);
    frame.getContentPane().add(panel, BorderLayout.CENTER);
  }
  catch (Exception ex) {
    System.err.println("Failed to create plot!");
    ex.printStackTrace();
  }
  frame.setSize(800, 600);
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
}
 
Example 7
Source Project: JglTF   File: GltfBrowserApplication.java    License: MIT License 5 votes vote down vote up
/**
 * Default constructor
 */
GltfBrowserApplication()
{
    frame = new JFrame("GltfBrowser");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    GltfTransferHandler transferHandler = 
        new GltfTransferHandler(this);
    frame.setTransferHandler(transferHandler);

    recentUrisMenu = new RecentUrisMenu(
        GltfBrowserApplication.class.getSimpleName(),
        uri -> openUriInBackground(uri));
    
    menuBar = new JMenuBar();
    menuBar.add(createFileMenu());
    frame.setJMenuBar(menuBar);
    
    openFileChooser = new JFileChooser(".");
    openFileChooser.setFileFilter(
        new FileNameExtensionFilter(
            "glTF Files (.gltf, .glb)", "gltf", "glb"));
    
    importObjFileChooser = new JFileChooser(".");
    
    objImportAccessoryPanel = new ObjImportAccessoryPanel();
    importObjFileChooser.setAccessory(objImportAccessoryPanel);
    importObjFileChooser.setFileFilter(
        new FileNameExtensionFilter(
            "OBJ files (.obj)", "obj"));
    
    saveFileChooser = new JFileChooser(".");
    
    desktopPane = new JDesktopPane();
    frame.getContentPane().add(desktopPane);
    
    frame.setSize(1000,700);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
 
Example 8
@Override
public void componentShown(ComponentEvent e) {
    JFrame frame = (JFrame) e.getComponent();

    runActualTest(device, latch, frame, result);

    frame.setVisible(false);
    frame.dispose();
    latch.countDown();
}
 
Example 9
Source Project: opencv-object-detection   File: DetectFace.java    License: MIT License 5 votes vote down vote up
public static void PencereHazirla() {
	frame = new JFrame();
	frame.setLayout(new FlowLayout());
	frame.setSize(700, 600);
	frame.setVisible(true);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
 
Example 10
public final static void main(String[] args){
	JPanel panel = new CheckGetBufferPoint();
	panel.setPreferredSize(new Dimension(500, 400));
	JFrame frame = new JFrame("Compute buffer of circles");
	frame.setContentPane(panel);
	frame.pack();
	frame.setVisible(true);		
}
 
Example 11
private static void createAndShowUI() {
    frame = new JFrame("bug7170310");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(200, 100);

    tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Main Tab", new JPanel());

    tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);

    frame.getContentPane().add(tabbedPane);
    frame.setVisible(true);
}
 
Example 12
Source Project: dctb-utfpr-2018-1   File: JLabelDemo.java    License: Apache License 2.0 5 votes vote down vote up
JLabelDemo() {

        // CRIA UM CONTEINER JFRAME
        JFrame jfrm = new JFrame("JLABEL COM ÍCONES DE IMAGENS");

        // FORNECE UM TAMANHO INICIAL PARA O QUADRO
        jfrm.setSize(500, 500);

        // ENCERRA O PROGRAMA QUANDO O USUÁRIO FECHA O APLICATIVO
        jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // CRIA UM ÍCONE E UM RÓTULO PARA VERDE
        ImageIcon goIcon = new ImageIcon(getClass().getResource("/imagens/verde.png"));
        JLabel jlabGo = new JLabel(" PASSE ", goIcon, SwingConstants.LEFT);

        // CRIA UM ÍCONE E UM RÓTULO PARA AMARELO
        ImageIcon cautionIcon = new ImageIcon(getClass().getResource("/imagens/amarelo.png"));
        JLabel jlabCaution = new JLabel(" ATENÇÃO  ", cautionIcon, SwingConstants.CENTER);

        // CRIA UM ÍCONE E UM RÓTULO PARA VERMELHO
        ImageIcon stopIcon = new ImageIcon(getClass().getResource("/imagens/vermelho.png"));
        JLabel jlabStop = new JLabel(" PARE", stopIcon, SwingConstants.RIGHT);

        // ADICIONA OS RÓTULOS AOS PAINEL DE CONTEÚDO
        jfrm.add(jlabGo, BorderLayout.NORTH);
        jfrm.add(jlabCaution, BorderLayout.CENTER);
        jfrm.add(jlabStop, BorderLayout.SOUTH);

        // EXIBE O QUADRO
        jfrm.setVisible(true);
    }
 
Example 13
Source Project: rest-client   File: RESTMain.java    License: Apache License 2.0 5 votes vote down vote up
/**
* 
* @Title: init 
* @Description: Component Initialization 
* @param
* @return void 
* @throws
 */
public static void init()
{
    MenuBarView mbv = new MenuBarView();
    JFrame frame = new JFrame(RESTConst.REST_CLIENT_VERSION);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(mbv.getJMenuBar());
    frame.getContentPane().add(RESTView.getView());
    frame.pack();
    frame.setVisible(true);
    frame.addWindowListener(wa);
    frame.setIconImage(UIUtil.getImage(RESTConst.LOGO));
    frame.setMinimumSize(new Dimension(RESTConst.MAIN_FRAME_WIDTH, RESTConst.MAIN_FRAME_HEIGHT));
    UIUtil.setLocation(frame);
}
 
Example 14
public final static void main(String[] args){
	JPanel panel = new CheckBufferPolylines();
	panel.setPreferredSize(new Dimension(600, 400));
	JFrame frame = new JFrame("Several buffers of polylines");
	frame.setContentPane(panel);
	frame.pack();
	frame.setVisible(true);		
}
 
Example 15
Source Project: microrts   File: FrontEnd.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    JFrame frame = new JFrame("microRTS Front End");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         
    frame.add(new FrontEnd(), BorderLayout.CENTER);
    frame.pack();
    frame.setVisible(true);
}
 
Example 16
public static void createAndShow() {
    try {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
    } catch(Exception cnf) {
        cnf.printStackTrace();
        throw new RuntimeException("GTK LaF must be supported");
    }
    frame = new JFrame("JFrame");
    frame.setSize(200, 200);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}
 
Example 17
Source Project: ThinkJavaCode2   File: Moire.java    License: MIT License 5 votes vote down vote up
public static void main(String[] args) {
    JFrame frame = new JFrame("Moire Pattern");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Canvas canvas = new Moire();
    canvas.setSize(400, 400);
    canvas.setBackground(Color.WHITE);
    frame.add(canvas);
    frame.pack();
    frame.setVisible(true);
}
 
Example 18
Source Project: meka   File: MacroCurve.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
  if (args.length != 1)
    throw new IllegalArgumentException("Required arguments: <dataset>");

  System.out.println("Loading data: " + args[0]);
  Instances data = DataSource.read(args[0]);
  MLUtils.prepareData(data);

  System.out.println("Cross-validate BR classifier");
  BR classifier = new BR();
  // further configuration of classifier
  String top = "PCut1";
  String vop = "3";
  Result result = Evaluation.cvModel(classifier, data, 10, top, vop);

  JFrame frame = new JFrame("Macro curve");
  frame.setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE);
  frame.getContentPane().setLayout(new BorderLayout());
  Instances performance = (Instances) result.getMeasurement(CURVE_DATA_MACRO);
  try {
    VisualizePanel panel = createPanel(performance);
    frame.getContentPane().add(panel, BorderLayout.CENTER);
  }
  catch (Exception ex) {
    System.err.println("Failed to create plot!");
    ex.printStackTrace();
  }
  frame.setSize(800, 600);
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
}
 
Example 19
Source Project: MSPaintIDE   File: MainGUI.java    License: MIT License 4 votes vote down vote up
public static void main(String[] args) throws IOException, InterruptedException, ExecutionException {
    System.setProperty("logPath", APP_DATA.getAbsolutePath() + "\\log");
    LOGGER = LoggerFactory.getLogger(MainGUI.class);

    System.setProperty("java.library.path", System.getProperty("java.library.path") + ";" + System.getenv("PATH"));

    LOGGER.info("Running in dev mode: {}", DEV_MODE);

    if (!System.getProperty("os.name").toLowerCase().contains("windows")) {
        JFrame frame = new JFrame("MS Paint IDE");
        frame.setSize(700, 200);
        JPanel jPanel = new JPanel();
        jPanel.add(new JLabel("<html><br><br><div style='text-align: center;'>Sorry, MS Paint IDE only supports Windows<br> However, the developer of MS Paint IDE is going to be adding support soon. <br> Stay tuned</div><br></html>"));
        frame.add(jPanel);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setResizable(false);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

    socketCommunicator = new DefaultInternalSocketCommunicator();

    if (args.length == 1) {
        var file = new File(args[0]);
        if (file.getName().endsWith(".ppf")) {
            if (socketCommunicator.serverAvailable()) {
                var message = "Error: You can't have more than one instance of MS Paint IDE running at the same time!";
                LOGGER.error(message);
                JOptionPane.showMessageDialog(null, message, "Fatal Error", JOptionPane.WARNING_MESSAGE);
                System.exit(1);
            }

            initialProject = initialProject.isFile() ? file : null;
        } else if (file.getName().endsWith(".png")) {
            Runtime.getRuntime().exec("mspaint.exe \"" + file.getAbsolutePath() + "\"");
            System.exit(0);
        } else {
            LOGGER.info("Name is {}", file.getName());
            if (!socketCommunicator.serverAvailable()) {
                HEADLESS = true;
                startServer(null);
                new TextEditorManager(file);
            } else {
                LOGGER.info("Server is available, connecting...");
                startDocumentClient(file.getAbsolutePath());
            }
            return;
        }
    }

    launch(args);
}
 
Example 20
Source Project: Ultraino   File: MainForm.java    License: MIT License 4 votes vote down vote up
private void showNewFrame(final JFrame frame){
    frame.setLocationRelativeTo(this);
    frame.setVisible(true);
}