Tabnine Logo
JFrame.pack
Code IndexAdd Tabnine to your IDE (free)

How to use
pack
method
in
javax.swing.JFrame

Best Java code snippets using javax.swing.JFrame.pack (Showing top 20 results out of 4,968)

Refine searchRefine arrow

  • JFrame.setVisible
  • JFrame.<init>
  • JFrame.setDefaultCloseOperation
  • JFrame.add
  • JFrame.getContentPane
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: osmdroid/osmdroid

public static void main(final String[] args) {
  final JFrame j = new OSMMapTilePackagerUI();
  j.setPreferredSize(new Dimension(640, 400));
  j.setDefaultCloseOperation(EXIT_ON_CLOSE);
  j.pack();
  j.setVisible(true);
}
origin: jMonkeyEngine/jmonkeyengine

  public void run(){
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    createFrame();
    currentPanel.add(canvas, BorderLayout.CENTER);
    frame.pack();
    startApp();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
});
origin: 4thline/cling

  @Override
  public void run() {
    errorWindow.getContentPane().removeAll();
    JTextArea textArea = new JTextArea();
    textArea.setEditable(false);
    StringBuilder text = new StringBuilder();
    text.append("An exceptional error occurred!\nYou can try to continue or exit the application.\n\n");
    text.append("Please tell us about this here:\nhttp://www.4thline.org/projects/mailinglists-cling.html\n\n");
    text.append("-------------------------------------------------------------------------------------------------------------\n\n");
    Writer stackTrace = new StringWriter();
    throwable.printStackTrace(new PrintWriter(stackTrace));
    text.append(stackTrace.toString());
    textArea.setText(text.toString());
    JScrollPane pane = new JScrollPane(textArea);
    errorWindow.getContentPane().add(pane, BorderLayout.CENTER);
    JButton exitButton = new JButton("Exit Application");
    exitButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        System.exit(1);
      }
    });
    errorWindow.getContentPane().add(exitButton, BorderLayout.SOUTH);
    errorWindow.pack();
    Application.center(errorWindow);
    textArea.setCaretPosition(0);
    errorWindow.setVisible(true);
  }
});
origin: stackoverflow.com

 JFrame jf = new JFrame();
JPanel jp = new JPanel();
jp.setPreferredSize(new Dimension(400,800));// changed it to preferredSize, Thanks!
jf.getContentPane().add( jp );// adding to content pane will work here. Please read the comment bellow.
jf.pack();
origin: knowm/XChart

 @Override
 public void run() {
  // Create and set up the window.
  // Add content to the window.
  frame.add(ExampleChartTester.this);
  // Display the window.
  frame.pack();
  frame.setVisible(true);
 }
});
origin: 4thline/cling

public void toggleLogPanel() {
  if (!logPanelVisible) {
    getView().add(getLogPanel(), BorderLayout.CENTER);
    getLogController().getLogTableModel().setPaused(false);
    logPanelVisible = true;
  } else {
    getView().remove(getLogPanel());
    getLogController().getLogTableModel().setPaused(true);
    logPanelVisible = false;
  }
  getView().pack();
}
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

 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

JFrame frame = new JFrame("FooRendererTest");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(mainPanel); // or whatever...
frame.pack();
frame.setLocationRelativeTo(null);  // *** this will center your app ***
frame.setVisible(true);
origin: stackoverflow.com

 public static void main(String[] args) {
  JFrame frame = new JFrame("MyForm");
  frame.setContentPane(new MyForm().mainPanel);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.pack();
  frame.setVisible(true);
}
origin: stackoverflow.com

public static void main(String[] args) throws MalformedURLException {
   URL url = new URL("<URL to your Animated GIF>");
   Icon icon = new ImageIcon(url);
   JLabel label = new JLabel(icon);
   JFrame f = new JFrame("Animation");
   f.getContentPane().add(label);
   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   f.pack();
   f.setLocationRelativeTo(null);
   f.setVisible(true);
 }
origin: loklak/loklak_server

/**
 * show the image as JFrame on desktop
 */
public void show() {
  JLabel label = new JLabel(new ImageIcon(this.image));
  JFrame f = new JFrame();
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.getContentPane().add(label);
  f.pack();
  f.setVisible(true);
}

origin: stackoverflow.com

 JFrame jFrame = new JFrame("Test");
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//jFrame.setLocationRelativeTo(null);
jFrame.setSize(600, 600);
jFrame.pack();
jFrame.setVisible(true);
jFrame.setLocationRelativeTo(null); //To center the code
origin: stackoverflow.com

 JFrame frame = new JFrame();
frame.setLayout(new GridLayout());
JLabel label = new JLabel("<html>First line<br>Second line</html>");
frame.add(label);
frame.pack();
frame.setVisible(true);
origin: stackoverflow.com

 JFrame frame = new JFrame("test");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JPanel panel = new JPanel(new GridLayout(4,4,4,4));

for(int i=0 ; i<16 ; i++){
  JButton btn = new JButton(String.valueOf(i));
  btn.setPreferredSize(new Dimension(40, 40));
  panel.add(btn);
}
frame.setContentPane(panel);
frame.pack();
frame.setVisible(true);
origin: spotbugs/spotbugs

private static void createAndShowGUI() {
  // Create and set up the window.
  JFrame frame = new JFrame("SpotBugs browser integration Test");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  // Add content to the window.
  frame.add(new TestDesktopIntegration());
  // Display the window.
  frame.pack();
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
}
origin: stackoverflow.com

 JFrame frame = new JFrame();
frame.getContentPane().setLayout(new FlowLayout());
frame.getContentPane().add(new JLabel(new ImageIcon(img)));
frame.getContentPane().add(new JLabel(new ImageIcon(img2)));
frame.getContentPane().add(new JLabel(new ImageIcon(img3)));
frame.pack();
frame.setVisible(true);
//frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // if you want the X button to close the app
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: jMonkeyEngine/jmonkeyengine

private static void createWindowForPanel(AwtPanel panel, int location){
  JFrame frame = new JFrame("Render Display " + location);
  frame.getContentPane().setLayout(new BorderLayout());
  frame.getContentPane().add(panel, BorderLayout.CENTER);
  frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  frame.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosed(WindowEvent e) {
      if (++panelsClosed == 2){
        app.stop();
      }
    }
  });
  frame.pack();
  frame.setLocation(location, Toolkit.getDefaultToolkit().getScreenSize().height - 400);
  frame.setVisible(true);
}

javax.swingJFramepack

Popular methods of JFrame

  • <init>
  • setVisible
  • setDefaultCloseOperation
  • 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.
  • Top 12 Jupyter Notebook extensions
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