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); } });
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); }
JFrame f = new JFrame(); f.getContentPane().add(sp);
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); }
private void buildExtractButton() { if (extractButton == null) { JPanel buttonPanel = new JPanel(); extractButton = new JButton("Run NER"); buttonPanel.add(extractButton); frame.getContentPane().add(buttonPanel, BorderLayout.SOUTH); extractButton.addActionListener(actor); } }
frame.getContentPane().add(containerSplitPane); frame.setDefaultCloseOperation(exitOnClose ? JFrame.EXIT_ON_CLOSE : WindowConstants.DISPOSE_ON_CLOSE);
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); } });
methodPanel.add(secureMethod3Button); frame = new JFrame("Apache Shiro Sample Application"); frame.setSize(500, 200); Container panel = frame.getContentPane(); panel.setLayout(new BorderLayout()); panel.add(logo, BorderLayout.NORTH); panel.add(valuePanel, BorderLayout.CENTER); panel.add(methodPanel, BorderLayout.SOUTH);
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);
private static void createTabs(){ tabbedPane = new JTabbedPane(); canvasPanel1 = new JPanel(); canvasPanel1.setLayout(new BorderLayout()); tabbedPane.addTab("jME3 Canvas 1", canvasPanel1); canvasPanel2 = new JPanel(); canvasPanel2.setLayout(new BorderLayout()); tabbedPane.addTab("jME3 Canvas 2", canvasPanel2); frame.getContentPane().add(tabbedPane); currentPanel = canvasPanel1; }
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
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); } });
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); }
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); }
private void buildContentPanel() { editorPane = new JEditorPane (); editorPane.setContentType("text/rtf"); editorPane.addKeyListener(new InputListener()); // defaultAttrSet = ((StyledEditorKit)editorPane.getEditorKit()).getInputAttributes(); StyleConstants.setFontFamily(defaultAttrSet, "Lucinda Sans"); Document doc = new DefaultStyledDocument(); editorPane.setDocument(doc); try { doc.insertString(0, initText, defaultAttrSet); } catch (Exception ex) { throw new RuntimeException(ex); } JScrollPane scrollPane = new JScrollPane(editorPane); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); editorPane.setEditable(true); }
JFrame frame=new JFrame(); frame.getContentPane().add(new JPanel());
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); } });
public JFrame showInJFrame(String title, int width, int height, boolean allowZoom, boolean showControls, boolean exitOnClose) { final JFrame main = new JFrame(title); int mainWidth = width; JScrollPane scroll = new JScrollPane(this); main.getContentPane().add(scroll, BorderLayout.CENTER); final CursorDisplayer glass = new CursorDisplayer(); main.setGlassPane(glass); JPanel zoomPanel = new JPanel(); zoomPanel.setLayout(new BoxLayout(zoomPanel, BoxLayout.Y_AXIS)); main.getContentPane().add(zoomPanel, BorderLayout.WEST); zoomPanel.add(Box.createVerticalGlue()); JButton zoomIn = new JButton("Zoom In");
public static void main(String[] args) { Rectangle box = new Rectangle(5, 10, 20, 30); // New stuff - Create a program window and set it up. JFrame window = new JFrame(); // Tell Swing to exit the program when the program window is closed. window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Set the window boundaries to be 300x300 on the screen, and position it 30 pixels from the top and left edges of the monitor. window.setBounds(30, 30, 300, 300); // Get the content pane of the window, and give it our own custom component. window.getContentPane().add(new JComponent() { // Not a typo - this is some advanced magic called an "anonymous class". Rectangle myBox = box; // Give the component a reference to our box object. public void paint(Graphics g) { g.drawRect(myBox.x, myBox.y, myBox.width, myBox.height); } }); // Make our window appear. window.setVisible(true); }
private void buildContentPanel() { editorPane = new JEditorPane (); editorPane.setContentType("text/rtf"); editorPane.addKeyListener(new InputListener()); // defaultAttrSet = ((StyledEditorKit)editorPane.getEditorKit()).getInputAttributes(); StyleConstants.setFontFamily(defaultAttrSet, "Lucida Sans"); Document doc = new DefaultStyledDocument(); editorPane.setDocument(doc); try { doc.insertString(0, initText, defaultAttrSet); } catch (Exception ex) { throw new RuntimeException(ex); } JScrollPane scrollPane = new JScrollPane(editorPane); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); editorPane.setEditable(true); }