Tabnine Logo
JFrame.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
javax.swing.JFrame
constructor

Best Java code snippets using javax.swing.JFrame.<init> (Showing top 20 results out of 7,605)

Refine searchRefine arrow

  • Window.setVisible
  • Container.add
  • JFrame.setDefaultCloseOperation
  • Window.pack
  • Window.setLocationRelativeTo
origin: libgdx/libgdx

  public void run () {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setSize(480, 320);
    frame.setLocationRelativeTo(null);
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel);
    panel.add(new NewSlider(200, 100, 500, 0.1f, 150, 300));
    frame.setVisible(true);
  }
});
origin: stackoverflow.com

 JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Timer timer = new Timer(1000, (ActionEvent e) -> {
  frame.setTitle(String.valueOf(System.currentTimeMillis()));
});
timer.setRepeats(true);
timer.start();
frame.setVisible(true);
origin: stackoverflow.com

$cat HelloWorldSwing.java
 package start;
 import javax.swing.*;
 public class HelloWorldSwing {
   public static void main(String[] args) {
     //Create and set up the window.
     JFrame frame = new JFrame("HelloWorldSwing");
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     JLabel label = new JLabel("Hello World");
     frame.add(label);
     //Display the window.
     frame.pack();
     frame.setVisible(true);
   }
 }
 class Dummy {
   // just to have another thing to pack in the jar
 }
origin: stackoverflow.com

 import java.awt.Dimension;

import javax.swing.JFrame;

public class JFrameExample {
  public static void main(String[] args) {
    JFrame frame = new JFrame("Hello World");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setMinimumSize(new Dimension(100, 100));
    frame.setVisible(true);
  }
}
origin: stackoverflow.com

 import java.awt.*;
import java.awt.geom.Line2D;
import javax.swing.*;

public class FrameTest {
  public static void main(String[] args) {
    JFrame jf = new JFrame("Demo");
    Container cp = jf.getContentPane();
    cp.add(new JComponent() {
      public void paintComponent(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
        g2.setStroke(new BasicStroke(10));
        g2.draw(new Line2D.Float(30, 20, 80, 90));
      }
    });
    jf.setSize(300, 200);
    jf.setVisible(true);
  }
}
origin: jMonkeyEngine/jmonkeyengine

public void show(){
  frame = new JFrame("HDR View");
  label = new JLabel(new ImageIcon(image));
  frame.getContentPane().add(label);
  frame.setLayout(new FlowLayout());
  frame.pack();
  frame.setVisible(true);
}
origin: stackoverflow.com

 import javax.swing.JFrame;
import javax.swing.JLabel;

public class Annoying {
  public static void main(String[] args) {
    JFrame frame = new JFrame("Hello!!");

    // Set's the window to be "always on top"
    frame.setAlwaysOnTop( true );

    frame.setLocationByPlatform( true );
    frame.add( new JLabel("  Isn't this annoying?") );
    frame.pack();
    frame.setVisible( true );
  }
}
origin: libgdx/libgdx

  public void run () {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setSize(480, 320);
    frame.setLocationRelativeTo(null);
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel);
    panel.add(new NewSlider(200, 100, 500, 0.1f, 150, 300));
    frame.setVisible(true);
  }
});
origin: stackoverflow.com

 private void makeGUI()
{
  final JFrame f = new JFrame();
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.getContentPane().setLayout(new FlowLayout());

  // include: "class AnswerWorker" code here.
  // include: "JButton" b code here.

  f.getContentPane().add(b);
  f.getContentPane().add(new JButton("Nothing"));
  f.pack();
  f.setVisible(true);
}
origin: stackoverflow.com

 import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.WindowConstants;

public class test {

  public static void main(String[] args) {
    final JFrame frame = new JFrame("Test");
    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent ev) {
        //frame.dispose();
      }
    });
    frame.setVisible(true);

  }

}
origin: stackoverflow.com

JFrame frame = new JFrame();
JPanel panel = new JPanel();
frame.getContentPane().add(panel);
frame.setVisible(true);
origin: stanfordnlp/CoreNLP

public static void main(String[] args) throws IOException {
 TreeJPanel tjp = new TreeJPanel();
 // String ptbTreeString1 = "(ROOT (S (NP (DT This)) (VP (VBZ is) (NP (DT a) (NN test))) (. .)))";
 String ptbTreeString = "(ROOT (S (NP (NNP Interactive_Tregex)) (VP (VBZ works)) (PP (IN for) (PRP me)) (. !))))";
 if (args.length > 0) {
  ptbTreeString = args[0];
 }
 Tree tree = (new PennTreeReader(new StringReader(ptbTreeString), new LabeledScoredTreeFactory(new StringLabelFactory()))).readTree();
 tjp.setTree(tree);
 tjp.setBackground(Color.white);
 JFrame frame = new JFrame();
 frame.getContentPane().add(tjp, BorderLayout.CENTER);
 frame.addWindowListener(new WindowAdapter() {
  @Override
  public void windowClosing(WindowEvent e) {
   System.exit(0);
  }
 });
 frame.pack();
 frame.setVisible(true);
 frame.setVisible(true);
}
origin: stackoverflow.com

 package com.stackoverflow.test;

import java.net.URL;
import javax.swing.*;  // Wild carded for brevity. 
            // Actual code imports single classes
public class Main {
  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable(){
      public void run() {
        URL url = Main.class.getResource(
                   "/resources/stackoverflow.png");
        ImageIcon icon = new ImageIcon(url);
        JFrame frame = new JFrame();
        frame.add(new JLabel(icon));
        frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      }
    });
  }
}
origin: libgdx/libgdx

  public void run () {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setSize(480, 320);
    frame.setLocationRelativeTo(null);
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel);
    panel.add(new Slider(200, 100, 500, 0.1f, 150, 300));
    frame.setVisible(true);
  }
});
origin: knowm/XChange

 @Override
 public void run() {
  // Create and set up the window.
  JFrame frame = new JFrame("XChart");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.add(chartPanel);
  // Display the window.
  frame.pack();
  frame.setVisible(true);
 }
});
origin: stackoverflow.com

 import java.awt.AWTEvent;
import java.awt.MouseInfo;
import java.awt.Toolkit;
import java.awt.event.AWTEventListener;

import javax.swing.JFrame;

public class Application1 {
  public static void main(String[] args) {
    Toolkit.getDefaultToolkit().addAWTEventListener(
     new Listener(), AWTEvent.MOUSE_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK);
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }

  private static class Listener implements AWTEventListener {
    public void eventDispatched(AWTEvent event) {
      System.out.print(MouseInfo.getPointerInfo().getLocation() + " | ");
      System.out.println(event);
    }
  }
}
origin: stackoverflow.com

 package temp;
import java.awt.EventQueue;
import javax.swing.JFrame;

public class Main {
  public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
      @Override
      public void run() {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.add(new NewJPanel());
        f.pack();
        f.setVisible(true);
      }
    });
  }
}
origin: libgdx/libgdx

  public void run () {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setSize(480, 320);
    frame.setLocationRelativeTo(null);
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel);
    panel.add(new Slider(200, 100, 500, 0.1f, 150, 300));
    frame.setVisible(true);
  }
});
origin: knowm/XChange

 @Override
 public void run() {
  // Create and set up the window.
  JFrame frame = new JFrame("XChart");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.add(chartPanel);
  // Display the window.
  frame.pack();
  frame.setVisible(true);
 }
});
origin: stackoverflow.com

public void run() {
  final JFrame f = new JFrame("Say Bye Bye!");
  f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  f.addWindowListener( new WindowAdapter() {
    @Override
  f.setSize(300,200);
  f.setLocationByPlatform(true);
  f.setVisible(true);
javax.swingJFrame<init>

Popular methods of JFrame

  • setVisible
  • setDefaultCloseOperation
  • pack
  • getContentPane
  • setSize
  • add
  • addWindowListener
  • dispose
  • setTitle
  • setContentPane
  • setLocation
  • setLocationRelativeTo
  • setLocation,
  • setLocationRelativeTo,
  • setJMenuBar,
  • setLayout,
  • setResizable,
  • setIconImage,
  • setBounds,
  • getRootPane,
  • getSize

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • getSystemService (Context)
  • getSupportFragmentManager (FragmentActivity)
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now