List of usage examples for javax.swing JPanel add
public Component add(Component comp)
From source file:mysynopsis.FTPUploader.java
public static void display() throws IOException { JTextField address = new JTextField(server); JTextField username = new JTextField(user); JPasswordField password = new JPasswordField(pass); JTextField directory = new JTextField(dir); JPanel panel = new JPanel(new GridLayout(10, 1)); panel.add(new JLabel("Server Address:")); panel.add(address);//from ww w. ja va 2 s .c o m panel.add(new JLabel("Username:")); panel.add(username); panel.add(new JLabel("Password:")); panel.add(password); panel.add(new JLabel("Upload Directory:")); panel.add(directory); int result; /*JOptionPane pane = new JOptionPane(panel,JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION); JDialog dialog = pane.createDialog(MotherFrame.mframe, "FTP Upload Wizard - My Synopsis"); dialog.setSize(new Dimension(300,300)); dialog.setVisible(true);*/ result = JOptionPane.showConfirmDialog(MotherFrame.mframe, panel, "FTP Upload Wizard", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { server = address.getText(); user = username.getText(); pass = new String(password.getPassword()); // System.out.println(pass); dir = directory.getText(); JOptionPane.showMessageDialog(MotherFrame.mframe, "Press OK to start FTP Upload"); HTMLWriter.writeHTML(); JOptionPane.showMessageDialog(MotherFrame.mframe, uploadWizard()); } else { // System.out.println("Cancelled"); } }
From source file:org.jfree.chart.demo.DialDemo2a.java
public static JPanel createDemoPanel() { JPanel jpanel = new JPanel(new GridLayout(1, 2)); jpanel.add(new DemoPanelA()); jpanel.add(new DemoPanelB()); return jpanel; }
From source file:org.jw.service.factory.StatisticsChartFactory.java
public static void connectChartPanel(JPanel container, JFreeChart chart) { ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setSize(container.getSize()); container.add(chartPanel); }
From source file:YAxisAlignXButtonMixed.java
private static Container makeIt(String title) { JPanel container = new JPanel(); container.setBorder(BorderFactory.createTitledBorder(title)); BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS); container.setLayout(layout);/*from ww w .j a va 2 s.c o m*/ AButton button = new AButton("0.0", 0.0f); container.add(button); button = new AButton(".25", .25f); container.add(button); button = new AButton(".50", .50f); container.add(button); button = new AButton(".75", .75f); container.add(button); button = new AButton("1.0", 1.0f); container.add(button); return container; }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.IntHistogramVisualizer.java
/** * Creates the combo box (drop-down list) to choose between visualization of the histogram as bar chart or * as a scatter plot./*from www.j a v a2 s . co m*/ * * @param aContainer Container control, to which the combo box is to be added. * @param aSelectedIndex Which choice is to be initially selected. This parameter must have one of the * values <code>{1; 2}</code>. * @return The newly created combo box control. */ private static JComboBox addChoice(Box aContainer, int aSelectedIndex) { final String[] choices = new String[] { Messages.DI_SHOWHIST, Messages.DI_SHOWSCAT }; JComboBox choiceCombo = new JComboBox(choices); choiceCombo.setSelectedIndex(aSelectedIndex); choiceCombo.setEditable(false); JPanel choicePanel = new JPanel(); choicePanel.add(choiceCombo); aContainer.add(choicePanel); return choiceCombo; }
From source file:Main.java
private static JPanel createLogin() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); JLabel label = new JLabel("login panel."); label.setFont(label.getFont().deriveFont(Font.ITALIC, 24f)); label.setAlignmentX(0.5f);/*from w w w . j a v a2 s. co m*/ label.setBorder(new EmptyBorder(0, 20, 0, 20)); p.add(Box.createVerticalStrut(36)); p.add(label); p.add(Box.createVerticalStrut(144)); return p; }
From source file:Main.java
public static JPanel createPainelContainer(String title, LayoutManager layout, Component... components) { final JPanel container = new JPanel(); container.setBorder(BorderFactory.createTitledBorder(title)); if (layout != null) container.setLayout(layout);// w w w. j a v a2 s. c o m for (Component c : components) { container.add(c); } return container; }
From source file:Main.java
public static boolean showModalDialogOnEDT(JComponent contents, String title, String okButtonMessage, String cancelButtonMessage, ModalityType modalityType, final boolean systemExitOnDisposed) { class Result { boolean OK = false; }// ww w . ja va 2 s .com final Result result = new Result(); final JDialog dialog = new JDialog((Frame) null, title, true) { @Override public void dispose() { super.dispose(); if (systemExitOnDisposed) { System.exit(0); } } }; // ensure it doesn't block other dialogs if (modalityType != null) { dialog.setModalityType(modalityType); } // See http://stackoverflow.com/questions/1343542/how-do-i-close-a-jdialog-and-have-the-window-event-listeners-be-notified dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); if (okButtonMessage != null) { buttonPane.add(new JButton(new AbstractAction(okButtonMessage) { @Override public void actionPerformed(ActionEvent e) { result.OK = true; dialog.dispose(); } })); } if (cancelButtonMessage != null) { buttonPane.add(new JButton(new AbstractAction(cancelButtonMessage) { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } })); } JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.setLayout(new BorderLayout()); panel.add(contents, BorderLayout.CENTER); panel.add(buttonPane, BorderLayout.SOUTH); // startup frame dialog.getContentPane().add(panel); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.pack(); // This hopefully centres the dialog even though the parameter is null // see http://stackoverflow.com/questions/213266/how-do-i-center-a-jdialog-on-screen dialog.setLocationRelativeTo(null); dialog.setVisible(true); return result.OK; }
From source file:com.joey.software.memoryToolkit.MemoryUsagePanel.java
public static JFrame getMemoryUsagePanel(int dataNum, int delay) { final MemoryUsagePanel u = new MemoryUsagePanel(dataNum, delay); JFrame f = new JFrame("Memory Usage"); f.setLayout(new BorderLayout()); f.getContentPane().add(u, BorderLayout.CENTER); f.setSize(800, 400);//w w w .ja v a 2s. co m f.setVisible(true); final JButton runButton = new JButton("Start"); runButton.addActionListener(new ActionListener() { boolean running = false; @Override public void actionPerformed(ActionEvent e) { if (running) { running = false; u.stopUpdating(); runButton.setText("Start"); } else { running = true; u.startUpdating(); runButton.setText("Stop"); } } }); JButton garbage = new JButton("Run GC"); garbage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.gc(); } }); JPanel temp = new JPanel(new GridLayout(1, 1)); temp.add(runButton); temp.add(garbage); f.getContentPane().add(temp, BorderLayout.SOUTH); return f; }
From source file:Main.java
/** * Creates a labeled panel containing a slider and considering * a particular width//from ww w. ja v a 2s .co m * * @param slider * @param label * @return a panel for the slider */ public static JPanel createSliderPanel(final JSlider slider, String label, int width) { final JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.setBorder(new TitledBorder(label)); p.setPreferredSize(new Dimension(width, 60)); p.add(slider); return p; }