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

How to use
add
method
in
javax.swing.JFrame

Best Java code snippets using javax.swing.JFrame.add (Showing top 20 results out of 2,565)

Refine searchRefine arrow

  • JFrame.setVisible
  • JFrame.<init>
  • JFrame.setDefaultCloseOperation
  • JFrame.pack
  • JFrame.setSize
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

 JFrame aFrame = new JFrame();
aFrame.add(new JPanel() {{
 setSize(100,100);
 setLocation(50,50);
 setBackground(Color.red);
}});
origin: stackoverflow.com

 JFrame frame = new JFrame ("Test");
JTextArea textArea = new JTextArea ("Test");

JScrollPane scroll = new JScrollPane (textArea, 
  JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

frame.add(scroll);
frame.setVisible (true);
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: i2p/i2p.i2p

final JFrame frame = new JFrame();
frame.setSize(0, 0);
final JPopupMenu menu = getSwingMainMenu();
menu.setFocusable(true);
frame.add(menu);
TrayIcon ti = new TrayIcon(getTrayImage(), tooltip, null);
ti.addMouseListener(new MouseListener() {
origin: stackoverflow.com

 public static void main(String[] args) {
  JFrame frame = new TestScrollPane();
  JPanel panel = new JPanel();
  JTable table = new JTable();

  panel.setLayout(new BorderLayout());
  panel.add(new JLabel("NORTH"), BorderLayout.NORTH);
  panel.add(new JLabel("SOUTH"), BorderLayout.SOUTH);

  JScrollPane sp = new JScrollPane(table);
  sp.setBorder(BorderFactory.createEmptyBorder());
  panel.add(sp, BorderLayout.CENTER);
  frame.add(panel);

  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

 public static void main(String[] args) throws Exception {
  JFrame frame = new JFrame("Test");

  ImageIcon loading = new ImageIcon("ajax-loader.gif");
  frame.add(new JLabel("loading... ", loading, JLabel.CENTER));

  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setSize(400, 300);
  frame.setVisible(true);
}
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: 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.setLayout(new BorderLayout());
frame.setSize(200, 200);

// create the status bar panel and shove it down the bottom of the frame
JPanel statusPanel = new JPanel();
statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
frame.add(statusPanel, BorderLayout.SOUTH);
statusPanel.setPreferredSize(new Dimension(frame.getWidth(), 16));
statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS));
JLabel statusLabel = new JLabel("status");
statusLabel.setHorizontalAlignment(SwingConstants.LEFT);
statusPanel.add(statusLabel);

frame.setVisible(true);
origin: stackoverflow.com

 public static void main(String[] args) {
  JFrame frame = new JFrame();
  frame.setLayout(new GridBagLayout());
  JPanel panel = new JPanel();
  panel.add(new JLabel("This is a label"));
  panel.setBorder(new LineBorder(Color.BLACK)); // make it easy to see
  frame.add(panel, new GridBagConstraints());
  frame.setSize(400, 400);
  frame.setLocationRelativeTo(null);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setVisible(true);
}
origin: stackoverflow.com

 public static void main ( String[] args )
{
  JPanel middlePanel = new JPanel ();
  middlePanel.setBorder ( new TitledBorder ( new EtchedBorder (), "Display Area" ) );

  // create the middle panel components

  JTextArea display = new JTextArea ( 16, 58 );
  display.setEditable ( false ); // set textArea non-editable
  JScrollPane scroll = new JScrollPane ( display );
  scroll.setVerticalScrollBarPolicy ( ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS );

  //Add Textarea in to middle panel
  middlePanel.add ( scroll );

  // My code
  JFrame frame = new JFrame ();
  frame.add ( middlePanel );
  frame.pack ();
  frame.setLocationRelativeTo ( null );
  frame.setVisible ( true );
}
origin: stackoverflow.com

 public static void main(String args[]){
  JFrame f = new JFrame();
  f.setLayout(new BorderLayout());
  final JPanel p = new JPanel();
  p.add(new JLabel("A Panel"));
  f.add(p, BorderLayout.CENTER);

  //create a button which will hide the panel when clicked.
  JButton b = new JButton("HIDE");
  b.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
        p.setVisible(false);
    }
  });

  f.add(b,BorderLayout.SOUTH);
  f.pack();
  f.setVisible(true);
}
origin: stanfordnlp/CoreNLP

private void displayTsurgeonHelp() {
 if(tsurgeonHelpFrame != null) {
  tsurgeonHelpFrame.setVisible(true);
 } else {
  tsurgeonHelpFrame = new JFrame("TSurgeon Help...");
  JEditorPane helpText = new JEditorPane();
  helpText.setContentType("text/html");
  // StringBuffer s = new StringBuffer();
  // s.append(htmlTsurgeonHelp);
  helpText.setText(htmlTsurgeonHelp);
  helpText.setEditable(false);
  JScrollPane scroller = new JScrollPane(helpText);
  helpText.setCaretPosition(0);
  scroller.setPreferredSize(new Dimension(500,500));
  tsurgeonHelpFrame.add(scroller);
  tsurgeonHelpFrame.pack();
  tsurgeonHelpFrame.setBackground(Color.WHITE);
  tsurgeonHelpFrame.setVisible(true);
 }
}
origin: stanfordnlp/CoreNLP

private void displayHelp() {
 if (helpFrame != null) {
  helpFrame.setVisible(true);
 } else {
  helpFrame = new JFrame("Tregex Help...");
  //JPanel helpPanel = new JPanel();
  JEditorPane helpText = new JEditorPane();
  helpText.setContentType("text/html");
  // StringBuffer s = new StringBuffer();
  // s.append(htmlHelp);
  helpText.setText(htmlHelp);
  helpText.setEditable(false);
  //helpPanel.add(helpText);
  JScrollPane scroller = new JScrollPane(helpText);
  helpText.setCaretPosition(0);
  scroller.setPreferredSize(new Dimension(500,500));
  helpFrame.add(scroller);
  helpFrame.pack();
  helpFrame.setBackground(Color.WHITE);
  helpFrame.setVisible(true);
  //helpFrame.repaint();
 }
}
origin: stackoverflow.com

 public static void main(String[] args) throws IOException {

  // 1. create the pipes
  PipedInputStream inPipe = new PipedInputStream();
  PipedInputStream outPipe = new PipedInputStream();

  // 2. set the System.in and System.out streams
  System.setIn(inPipe);
  System.setOut(new PrintStream(new PipedOutputStream(outPipe), true));

  PrintWriter inWriter = new PrintWriter(new PipedOutputStream(inPipe), true);

  // 3. create the gui 
  JFrame frame = new JFrame("\"Console\"");
  frame.add(console(outPipe, inWriter));
  frame.setSize(400, 300);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setVisible(true);

  // 4. write some output (to JTextArea)
  System.out.println("Hello World!");
  System.out.println("Test");
  System.out.println("Test");
  System.out.println("Test");

  // 5. get some input (from JTextArea)
  Scanner s = new Scanner(System.in);
  System.out.printf("got from input: \"%s\"%n", s.nextLine());
}
origin: stackoverflow.com

 import java.awt.*;

public class TestComponent extends JPanel {

  private void drawString(Graphics g, String text, int x, int y) {
    for (String line : text.split("\n"))
      g.drawString(line, x, y += g.getFontMetrics().getHeight());
  }

  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    drawString(g, "hello\nworld", 20, 20);
    g.setFont(g.getFont().deriveFont(20f));
    drawString(g, "part1\npart2", 120, 120);
  }

  public static void main(String s[]) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(new TestComponent());
    f.setSize(220, 220);
    f.setVisible(true);
  }
}
origin: stackoverflow.com

 public static void main(String[] args) {
  JFrame frame = new JFrame();
  frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  frame.setBounds(0, 0, 300, 400);
  frame.setLayout(null);
  final JTabbedPane tabbedPane = new JTabbedPane();
  tabbedPane.addTab("One", new JPanel());
  tabbedPane.addTab("Two", new JPanel());
  tabbedPane.addTab("Three", new JPanel());
  tabbedPane.addChangeListener(new ChangeListener() {
    public void stateChanged(ChangeEvent e) {
      System.out.println("Tab: " + tabbedPane.getSelectedIndex());
    }
  });
  tabbedPane.setBounds(0, 0, 300, 400);
  frame.add(tabbedPane);
  frame.setVisible(true);
}
javax.swingJFrameadd

Popular methods of JFrame

  • <init>
  • setVisible
  • setDefaultCloseOperation
  • pack
  • getContentPane
  • setSize
  • 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 plugins for Android Studio
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