@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); } });
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);
@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); } });
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); }
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(); }
@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); } });
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); }
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);
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); }
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);
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); }
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 ); }
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); }
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); } }
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(); } }
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()); }
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); } }
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); }