List of usage examples for javax.swing JPanel add
public Component add(String name, Component comp)
From source file:com.joey.software.regionSelectionToolkit.controlers.ImageProfileToolDynamicRangePanel.java
public static void main(String[] input) { try {//from w ww .j a va 2s. co m DynamicRangeImage img = new DynamicRangeImage(ImageOperations.getGrayTestImage(600, 600, 3)); JPanel p = new JPanel(new BorderLayout()); p.add(img, BorderLayout.CENTER); img.setPanelMode(DynamicRangeImage.TYPE_MANUAL_PROFILE); FrameFactroy.getFrame(img); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:DateTimeEditor.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0);//from w w w. ja v a2 s . c o m } }); JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(new EmptyBorder(5, 5, 5, 5)); frame.setContentPane(panel); final DateTimeEditor field = new DateTimeEditor(DateTimeEditor.DATETIME, DateFormat.FULL); panel.add(field, "North"); JPanel buttonBox = new JPanel(new GridLayout(2, 2)); JButton showDateButton = new JButton("Show Date"); buttonBox.add(showDateButton); final JComboBox timeDateChoice = new JComboBox(); timeDateChoice.addItem("Time"); timeDateChoice.addItem("Date"); timeDateChoice.addItem("Date/Time"); timeDateChoice.setSelectedIndex(2); timeDateChoice.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { field.setTimeOrDateType(timeDateChoice.getSelectedIndex()); } }); buttonBox.add(timeDateChoice); JButton toggleButton = new JButton("Toggle Enable"); buttonBox.add(toggleButton); showDateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.println(field.getDate()); } }); toggleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { field.setEnabled(!field.isEnabled()); } }); panel.add(buttonBox, "South"); final JComboBox lengthStyleChoice = new JComboBox(); lengthStyleChoice.addItem("Full"); lengthStyleChoice.addItem("Long"); lengthStyleChoice.addItem("Medium"); lengthStyleChoice.addItem("Short"); lengthStyleChoice.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { field.setLengthStyle(lengthStyleChoice.getSelectedIndex()); } }); buttonBox.add(lengthStyleChoice); frame.pack(); Dimension dim = frame.getToolkit().getScreenSize(); frame.setLocation(dim.width / 2 - frame.getWidth() / 2, dim.height / 2 - frame.getHeight() / 2); frame.show(); }
From source file:com.limegroup.gnutella.gui.notify.AnimatedWindow.java
public static void main(String[] args) { JPanel content = new JPanel(new BorderLayout()); content.setBorder(BorderFactory.createLineBorder(Color.black, 2)); JLabel label = new JLabel("Hello World"); label.setIcon(UIManager.getIcon("FileView.computerIcon")); label.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); content.add(label, BorderLayout.CENTER); final AnimatedWindow window = new AnimatedWindow(null); window.setFinalLocation(new Point(200, 200)); window.setContentPane(content);//from w w w . j a v a 2 s . c om JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 10)); JButton button = new JButton("Bottom -> Top"); buttonPanel.add(button); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { window.setMode(AnimationMode.BOTTOM_TO_TOP); if (!window.isVisible() || window.isHideAnimationInProgress()) { window.doShow(); } else { window.doHide(); } } }); button = new JButton("Top -> Bottom"); buttonPanel.add(button); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { window.setMode(AnimationMode.TOP_TO_BOTTOM); if (!window.isVisible() || window.isHideAnimationInProgress()) { window.doShow(); } else { window.doHide(); } } }); button = new JButton("Fade"); buttonPanel.add(button); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { window.setMode(AnimationMode.FADE); if (!window.isVisible() || window.isHideAnimationInProgress()) { window.doShow(); } else { window.doHide(); } } }); JFrame app = new JFrame("AnimatedWindow Demo"); app.setContentPane(buttonPanel); app.pack(); app.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); } }); app.setVisible(true); }
From source file:Main.java
private static JPanel getPanel() { JPanel panel = new JPanel(new BorderLayout()); panel.add(new JLabel("Top"), BorderLayout.NORTH); panel.add(new JLabel("Center"), BorderLayout.CENTER); panel.add(new JLabel("Bottom"), BorderLayout.SOUTH); panel.setPreferredSize(new Dimension(400, 300)); return panel; }
From source file:Main.java
public static Component getButtonLayout(int num) { JPanel p = new JPanel(new BorderLayout(3, 3)); p.add(new JLabel("Label " + num), BorderLayout.NORTH); JPanel b = new JPanel(new GridLayout(1, 0, 25, 5)); for (int ii = 1; ii < 4; ii++) { b.add(new JButton("Button " + ii)); }/*w ww . j a va 2 s .c o m*/ p.add(b, BorderLayout.CENTER); return p; }
From source file:Main.java
public static JPanel placeInTitledEtchedJPanel(Component c, String title, Color titleColor) { JPanel parent = new JPanel(new BorderLayout()); parent.add(c, BorderLayout.CENTER); TitledBorder tb = new TitledBorder(title); tb.setBorder(BorderFactory.createEtchedBorder()); tb.setTitleColor(titleColor);// w ww .j ava 2s.c om parent.setBorder(tb); return parent; }
From source file:Main.java
/** * Creates a JPanel containing the component hugging the bottom side * @param component the component to wrap * @return a JPanel containing the component hugging the bottom side *///w w w . ja v a2s . c om public static JPanel hugSouth(JComponent component) { final JPanel result = new JPanel(new BorderLayout()); result.add(component, BorderLayout.SOUTH); return result; }
From source file:Main.java
/** * Creates a JPanel containing the component hugging the left side * @param component the component to wrap * @return a JPanel containing the component hugging the left side *///from w w w .jav a 2 s . c o m public static JPanel hugWest(JComponent component) { final JPanel result = new JPanel(new BorderLayout()); result.add(component, BorderLayout.WEST); return result; }
From source file:Main.java
/** * Creates a JPanel containing the component hugging the top side * @param component the component to wrap * @return a JPanel containing the component hugging the top side */// www . j a v a2 s .c o m public static JPanel hugNorth(JComponent component) { final JPanel result = new JPanel(new BorderLayout()); result.add(component, BorderLayout.NORTH); return result; }
From source file:QandE.Layout1.java
/** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread./* w w w. jav a 2 s .c o m*/ */ private static void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("Layout1"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Add the innards. JPanel p = new JPanel(new BorderLayout()); p.add(createComponent("Component 1"), BorderLayout.CENTER); frame.setContentPane(p); //Display the window. frame.pack(); frame.setVisible(true); }