frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JPanel gui = new JPanel(new BorderLayout(5,5)); gui.setBorder( new TitledBorder("BorderLayout(5,5)") ); JPanel plafComponents = new JPanel( new FlowLayout(FlowLayout.RIGHT, 3,3)); plafComponents.setBorder( new TitledBorder("FlowLayout(FlowLayout.RIGHT, 3,3)") ); JPanel dynamicLabels = new JPanel(new BorderLayout(4,4)); dynamicLabels.setBorder( new TitledBorder("BorderLayout(4,4)") ); gui.add(dynamicLabels, BorderLayout.WEST); final JPanel labels = new JPanel(new GridLayout(0,2,3,3)); labels.setBorder( new TitledBorder("GridLayout(0,2,3,3)") ); labels.add( new JLabel("Label " + ++labelCount) ); frame.validate(); JPanel imagePanel = new JPanel(new GridBagLayout()); imagePanel.setBorder( new TitledBorder("GridBagLayout()") );
JOptionPane.showMessageDialog( null, new JLabel( new ImageIcon( img.getScaledInstance( f.setJMenuBar(mb); JPanel p = new JPanel( new BorderLayout(5,5) ); p.setBorder( new TitledBorder("Main GUI") ); p.add( new JScrollPane(new JTree()), BorderLayout.WEST );
public PropertySlider() { titledBorder = new TitledBorder(""); setBorder(titledBorder); borderLayout = new BorderLayout(); setLayout(borderLayout); label = new JLabel(""); slider = new JSlider(); slider.setMinimum(0); slider.setMaximum(100); slider.setMinorTickSpacing(1); slider.setMajorTickSpacing(10); slider.addChangeListener(this); add(slider, BorderLayout.CENTER); add(label, BorderLayout.EAST); }
private void initializeComponent() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); getRootPane().setLayout(new BorderLayout()); c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(5, 5, 5, 5); panel.add(nameField, c); JLabel commentLabel = new JLabel("Comment"); c = new GridBagConstraints(); c.gridy = 2; JPanel resultPanel = new JPanel(); resultPanel.setLayout(new GridBagLayout()); resultPanel.setBorder(new TitledBorder("Results")); JButton addResultButton = new JButton("Add"); addResultButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { removeResultButton = new JButton("Remove"); removeResultButton.setEnabled(false); removeResultButton.addActionListener(new ActionListener() {
import java.awt.*; import javax.swing.*; import javax.swing.border.TitledBorder; public class TestCenterGridbagLayout { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable(){ public void run() { JPanel mainPanel = new JPanel(new GridLayout(3, 3)); for (int i = 0; i < 9; i++) { mainPanel.add(new JButton("Button")); } mainPanel.setBorder(new TitledBorder("Main Panel")); JPanel wrapperPanel = new JPanel(new GridBagLayout()); wrapperPanel.setPreferredSize(new Dimension(350, 300)); wrapperPanel.add(mainPanel); wrapperPanel.setBorder(new TitledBorder("Wrapper panel with GridbagLayout")); JOptionPane.showMessageDialog(null, wrapperPanel); } }); } }
TradesPanel() { JTable table = new JTable( m_model); JScrollPane scroll = new JScrollPane( table); scroll.setBorder( new TitledBorder( "Trade Log")); HtmlButton but = new HtmlButton( "Refresh") { @Override public void actionPerformed() { onRefresh(); } }; JPanel p = new JPanel( new FlowLayout( FlowLayout.RIGHT)); p.add( but); setLayout( new BorderLayout() ); add( scroll); add( p, BorderLayout.SOUTH); }
JPanel panel = new JPanel(); panel.setBorder(new TitledBorder("Title")); menu.add(panel);
void initGUI() { removeAll(); classBrowserButton = new JButton("Examine..."); classBrowserButton.setToolTipText("Opens a new window that lets you examine classes and create new object instances"); classBrowserButton.addActionListener(this); classBrowserButton.setEnabled(false); //classBrowserButton.setActionCommand(COMMAND_CREATE_BEAN); DefaultComboBoxModel dcm = new SortedComboBoxModel(); classField = new JComboBox(dcm); classField.setSize(400, (int) classField.getSize().getHeight()); classField.addActionListener(this); classField.setEnabled(true); final JTextComponent tc = (JTextComponent) classField.getEditor().getEditorComponent(); tc.getDocument().addDocumentListener(this); setBorder(new TitledBorder("Class browser")); setLayout(new BorderLayout()); add("North", new JLabel("Full class name:")); add("Center", classField); add("East", classBrowserButton); adjustSize(); updatedClassFilter(); installSearchable(); }
desktop = createDesktopPane(); JInternalFrame iFrame = createInternalFrame(); desktop.add(iFrame); JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(new TitledBorder("DesktopPane")); panel.add(desktop);
public void createPanel1() { jPanel1 = new JPanel(); //jPanel1.setLayout(new GridLayout(0, 1); jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.Y_AXIS)); jPanel1.setBorder(new TitledBorder("Select a Layout Manger")); jPanel1.add(jrbFlowLayout); jPanel1.add(jrbGridLayout); jPanel1.add(jrbDiagLayout); ButtonGroup buttonGroup1 = new ButtonGroup(); buttonGroup1.add(jrbFlowLayout); buttonGroup1.add(jrbGridLayout); buttonGroup1.add(jrbDiagLayout); }
public void initGUI() { setBorder(new TitledBorder(null, Messages.getString("DicomZipImport.title"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); setLayout(new FlowLayout(FlowLayout.LEFT, 3, 3)); btnOpen = new JButton(Messages.getString("DicomZipImport.select_file")); //$NON-NLS-1$ btnOpen.addActionListener(e -> browseImgFile()); add(btnOpen); add(fileLabel); }
/** * Gives the panel a titled border with the given title. * @param title The title. */ public void setTitle(final String title) { panel.setBorder(new TitledBorder(title)); } }
private void initComponents() { contentPane = new JPanel(); JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); buttonOK = new JButton(); buttonCancel = new JButton(); JPanel panel3 = new JPanel(); txtDeckList = new JEditorPane(); contentPane.setBorder(new javax.swing.border.CompoundBorder( new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0), "Import from Clipboard", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12), panel2.add(buttonOK, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); panel2.add(buttonCancel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); panel1.add(panel2, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
JPanel options = new JPanel(); BoxLayout bl = new BoxLayout(options,BoxLayout.Y_AXIS); options.setLayout(bl); sampleRate.setToolTipText("Samples per second"); sampleRate.setSelectedIndex(1); JPanel pSampleRate = new JPanel(new BorderLayout()); pSampleRate.setBorder(new TitledBorder("Sample Rate")); pSampleRate.add( sampleRate ); sampleRate.addActionListener(new ActionListener() { JPanel pFPW = new JPanel( new BorderLayout() ); pFPW.setBorder(new TitledBorder("Frames per Wavelength")); bottomOption.add( harmonic, BorderLayout.WEST ); frequency = new JLabel(); bottomOption.add( frequency, BorderLayout.CENTER ); JPanel play = new JPanel(new BorderLayout(3,3)); play.setBorder( new EmptyBorder(4,4,4,4) ); JButton bPlay = new JButton("Code Key"); bPlay.setToolTipText("Click to make tone!"); Dimension preferredSize = bPlay.getPreferredSize();
public void run() { JTextField account = new JTextField(10); JPanel accountPanel = new JPanel(new GridLayout()); accountPanel.add(account); accountPanel.setBorder(new TitledBorder("Account")); JLabel firstDigitListLabel = new JLabel("Leading Digit Change"); JPanel firstDigitListPanel = new JPanel(new BorderLayout(4,2)); firstDigitListPanel.add(firstDigitListLabel, BorderLayout.WEST); JComboBox firstDigitCombo = new JComboBox(firstDigitList); firstDigitListPanel.add(firstDigitCombo); firstDigitCombo.setSelectedIndex(0); firstDigitListPanel.setBorder(new TitledBorder("LDC")); JPanel panel = new JPanel(); panel.add(accountPanel); panel.add(firstDigitListPanel);
import java.awt.GridBagLayout; import javax.swing.*; import javax.swing.border.TitledBorder; public class CenteringWithGridBag { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable(){ public void run() { JPanel gridBagPanel = new JPanel(new GridBagLayout()); gridBagPanel.setBorder(new TitledBorder("JPanel with GridBagLayout")); JPanel innerPanel = new JPanel(); innerPanel.setBorder(new TitledBorder("JPanel Wrap")); innerPanel.add(new JButton("Button")); gridBagPanel.add(innerPanel); JFrame frame = new JFrame("GridBagLayout Test"); frame.add(gridBagPanel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } }
ChainPanel() { JScrollPane scrollPuts = new JScrollPane( m_putsTable); scrollPuts.setBorder( new TitledBorder( "Puts")); JScrollPane scrollCalls = new JScrollPane( m_callsTable); scrollCalls.setBorder( new TitledBorder( "Calls")); VerticalPanel underPanel = new VerticalPanel(); underPanel.add( "Underlying price", m_labUnderPrice); JPanel mainPanel = new JPanel(); mainPanel.setLayout( new BoxLayout( mainPanel, BoxLayout.X_AXIS)); mainPanel.add( scrollCalls); mainPanel.add( scrollPuts); setLayout( new BorderLayout() ); add( underPanel, BorderLayout.NORTH); add( mainPanel); m_timer.start(); ApiDemo.INSTANCE.controller().reqTopMktData( m_underContract, "", false, m_stockListener); }
private JPanel createFeaturePanel() { final JPanel featurePanel = new JPanel(); featurePanel.setBorder(new TitledBorder("Feature Selection")); featurePanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = DialogUtils.createGridBagConstraints(); DialogUtils.addComponent(featurePanel, gbc, "Feature bands: ", new JScrollPane(featureBandNames)); DialogUtils.fillPanel(featurePanel, gbc); return featurePanel; }
/** * Create new properties panel. */ public PropertiesPanel(String title) { super(new GridBagLayout()); if(title!=null) setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), title)); this.components = new HashMap(); this.gbc = new GridBagConstraints(); gbc.gridy = 0; gbc.anchor = GridBagConstraints.PAGE_START; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(1,1,1,1); adddummy = true; dummy = new JLabel(); gbc.weighty = 1; add(dummy, gbc); gbc.weighty = 0; }
JTextArea ta = new JTextArea(20, 20); JScrollPane sp = new JScrollPane(ta); JPanel wrapper = new JPanel(new BorderLayout()); wrapper.setBorder(new TitledBorder("Details")); wrapper.add(sp);