List of usage examples for java.awt BorderLayout LINE_START
String LINE_START
To view the source code for java.awt BorderLayout LINE_START.
Click Source Link
From source file:sk.stuba.fiit.kvasnicka.topologyvisual.gui.components.DropDownButton.java
private void addSearchField(JPanel northPanel) { searchField = new JXSearchField("Filter"); searchField.setColumns(7);/*from w w w. j a va2s.c o m*/ searchField.setAlignmentX(LEFT_ALIGNMENT); searchField.setSearchMode(JXSearchField.SearchMode.INSTANT); searchField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { filterCheckBoxList(e.getActionCommand()); } }); northPanel.add(searchField, BorderLayout.LINE_START); }
From source file:FocusTraversalDemo.java
public FocusTraversalDemo() { super(new BorderLayout()); newPolicy = new MyOwnFocusTraversalPolicy(); tf1 = new JTextField("Field 1"); tf2 = new JTextField("A Bigger Field 2"); tf3 = new JTextField("Field 3"); tf4 = new JTextField("A Bigger Field 4"); tf5 = new JTextField("Field 5"); tf6 = new JTextField("A Bigger Field 6"); table = new JTable(4, 3); togglePolicy = new JCheckBox("Custom FocusTraversalPolicy"); togglePolicy.setActionCommand("toggle"); togglePolicy.addActionListener(this); togglePolicy.setFocusable(false); //Remove it from the focus cycle. //Note that HTML is allowed and will break this run of text //across two lines. label = new JLabel( "<html>Use Tab (or Shift-Tab) to navigate from component to component.<p>Control-Tab (or Control-Shift-Tab) allows you to break out of the JTable.</html>"); JPanel leftTextPanel = new JPanel(new GridLayout(3, 2)); leftTextPanel.add(tf1, BorderLayout.PAGE_START); leftTextPanel.add(tf3, BorderLayout.CENTER); leftTextPanel.add(tf5, BorderLayout.PAGE_END); leftTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel rightTextPanel = new JPanel(new GridLayout(3, 2)); rightTextPanel.add(tf2, BorderLayout.PAGE_START); rightTextPanel.add(tf4, BorderLayout.CENTER); rightTextPanel.add(tf6, BorderLayout.PAGE_END); rightTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel tablePanel = new JPanel(new GridLayout(0, 1)); tablePanel.add(table, BorderLayout.CENTER); tablePanel.setBorder(BorderFactory.createEtchedBorder()); JPanel bottomPanel = new JPanel(new GridLayout(2, 1)); bottomPanel.add(togglePolicy, BorderLayout.PAGE_START); bottomPanel.add(label, BorderLayout.PAGE_END); add(leftTextPanel, BorderLayout.LINE_START); add(rightTextPanel, BorderLayout.CENTER); add(tablePanel, BorderLayout.LINE_END); add(bottomPanel, BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:DragListDemo.java
public DragListDemo() { arrayListHandler = new ArrayListTransferHandler(); JList list1, list2;/* w ww .ja v a 2 s. c o m*/ DefaultListModel list1Model = new DefaultListModel(); list1Model.addElement("0 (list 1)"); list1Model.addElement("1 (list 1)"); list1Model.addElement("2 (list 1)"); list1Model.addElement("3 (list 1)"); list1Model.addElement("4 (list 1)"); list1Model.addElement("5 (list 1)"); list1Model.addElement("6 (list 1)"); list1 = new JList(list1Model); list1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); list1.setTransferHandler(arrayListHandler); list1.setDragEnabled(true); JScrollPane list1View = new JScrollPane(list1); list1View.setPreferredSize(new Dimension(200, 100)); JPanel panel1 = new JPanel(); panel1.setLayout(new BorderLayout()); panel1.add(list1View, BorderLayout.CENTER); panel1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); DefaultListModel list2Model = new DefaultListModel(); list2Model.addElement("0 (list 2)"); list2Model.addElement("1 (list 2)"); list2Model.addElement("2 (list 2)"); list2Model.addElement("3 (list 2)"); list2Model.addElement("4 (list 2)"); list2Model.addElement("5 (list 2)"); list2Model.addElement("6 (list 2)"); list2 = new JList(list2Model); list2.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); list2.setTransferHandler(arrayListHandler); list2.setDragEnabled(true); JScrollPane list2View = new JScrollPane(list2); list2View.setPreferredSize(new Dimension(200, 100)); JPanel panel2 = new JPanel(); panel2.setLayout(new BorderLayout()); panel2.add(list2View, BorderLayout.CENTER); panel2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setLayout(new BorderLayout()); add(panel1, BorderLayout.LINE_START); add(panel2, BorderLayout.LINE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:RadioButtonDemo.java
public RadioButtonDemo() { super(new BorderLayout()); //Create the radio buttons. JRadioButton birdButton = new JRadioButton(birdString); birdButton.setMnemonic(KeyEvent.VK_B); birdButton.setActionCommand(birdString); birdButton.setSelected(true);//from w ww . j av a2s .c o m JRadioButton catButton = new JRadioButton(catString); catButton.setMnemonic(KeyEvent.VK_C); catButton.setActionCommand(catString); JRadioButton dogButton = new JRadioButton(dogString); dogButton.setMnemonic(KeyEvent.VK_D); dogButton.setActionCommand(dogString); JRadioButton rabbitButton = new JRadioButton(rabbitString); rabbitButton.setMnemonic(KeyEvent.VK_R); rabbitButton.setActionCommand(rabbitString); JRadioButton pigButton = new JRadioButton(pigString); pigButton.setMnemonic(KeyEvent.VK_P); pigButton.setActionCommand(pigString); //Group the radio buttons. ButtonGroup group = new ButtonGroup(); group.add(birdButton); group.add(catButton); group.add(dogButton); group.add(rabbitButton); group.add(pigButton); //Register a listener for the radio buttons. birdButton.addActionListener(this); catButton.addActionListener(this); dogButton.addActionListener(this); rabbitButton.addActionListener(this); pigButton.addActionListener(this); //Set up the picture label. picture = new JLabel(createImageIcon("images/" + birdString + ".gif")); //The preferred size is hard-coded to be the width of the //widest image and the height of the tallest image. //A real program would compute this. picture.setPreferredSize(new Dimension(177, 122)); //Put the radio buttons in a column in a panel. JPanel radioPanel = new JPanel(new GridLayout(0, 1)); radioPanel.add(birdButton); radioPanel.add(catButton); radioPanel.add(dogButton); radioPanel.add(rabbitButton); radioPanel.add(pigButton); add(radioPanel, BorderLayout.LINE_START); add(picture, BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:SwingCheckBoxDemo.java
public SwingCheckBoxDemo() { super(new BorderLayout()); //Create the check boxes. chinButton = new JCheckBox("Chin"); chinButton.setMnemonic(KeyEvent.VK_C); chinButton.setSelected(true);// w w w . j a v a 2s. co m glassesButton = new JCheckBox("Glasses"); glassesButton.setMnemonic(KeyEvent.VK_G); glassesButton.setSelected(true); hairButton = new JCheckBox("Hair"); hairButton.setMnemonic(KeyEvent.VK_H); hairButton.setSelected(true); teethButton = new JCheckBox("Teeth"); teethButton.setMnemonic(KeyEvent.VK_T); teethButton.setSelected(true); //Register a listener for the check boxes. chinButton.addItemListener(this); glassesButton.addItemListener(this); hairButton.addItemListener(this); teethButton.addItemListener(this); //Indicates what's on the geek. choices = new StringBuffer("cght"); //Set up the picture label pictureLabel = new JLabel(); pictureLabel.setFont(pictureLabel.getFont().deriveFont(Font.ITALIC)); updatePicture(); /*Put the check boxes in a column in a panel*/ JPanel checkPanel = new JPanel(new GridLayout(0, 1)); checkPanel.add(chinButton); checkPanel.add(glassesButton); checkPanel.add(hairButton); checkPanel.add(teethButton); add(checkPanel, BorderLayout.LINE_START); add(pictureLabel, BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:TextInputDemo.java
protected JComponent createAddressDisplay() { JPanel panel = new JPanel(new BorderLayout()); addressDisplay = new JLabel(); addressDisplay.setHorizontalAlignment(JLabel.CENTER); regularFont = addressDisplay.getFont().deriveFont(Font.PLAIN, 16.0f); italicFont = regularFont.deriveFont(Font.ITALIC); updateDisplays();/*from w w w. j a v a 2s.co m*/ //Lay out the panel. panel.setBorder(BorderFactory.createEmptyBorder(GAP / 2, //top 0, //left GAP / 2, //bottom 0)); //right panel.add(new JSeparator(JSeparator.VERTICAL), BorderLayout.LINE_START); panel.add(addressDisplay, BorderLayout.CENTER); panel.setPreferredSize(new Dimension(200, 150)); return panel; }
From source file:com.microsoft.alm.plugin.idea.common.ui.common.tabs.TabFormImpl.java
/** * Create the tab view if not already done *//* www . ja v a2s. co m*/ protected void ensureInitialized() { if (!initialized) { createCustomView(); createFilterToolbar(); //toolbars final JPanel toolBarPanel; if (ApplicationManager.getApplication() != null) { final ActionToolbar prActionsToolbar = createToolbar(createActionsGroup()); final ActionToolbar feedbackActionsToolbar = createToolbar(createFeedbackGroup()); final ActionToolbar optionsActionsToolbar = createToolbar(createOptionsGroup()); // left panel of the top toolbar final FlowLayout flowLayout = new FlowLayout(FlowLayout.LEFT, 0, JBUI.scale(3)); // give vertical padding final JPanel toolBarPanelLeft = new JPanel(flowLayout); toolBarPanelLeft.add(prActionsToolbar.getComponent()); toolBarPanelLeft.add(searchFilter); addCustomTools(toolBarPanelLeft); // middle panel of the top toolbar final FlowLayout flowLayout2 = new FlowLayout(FlowLayout.LEFT, 0, JBUI.scale(3)); // give vertical padding final JPanel toolBarPanelMiddle = new JPanel(flowLayout2); toolBarPanelMiddle.add(optionsActionsToolbar.getComponent()); SwingHelper.setMargin(toolBarPanelMiddle, new Insets(JBUI.scale(2), JBUI.scale(15), 0, 0)); //entire top toolbar toolBarPanel = new JPanel(new BorderLayout()); toolBarPanel.add(toolBarPanelLeft, BorderLayout.LINE_START); toolBarPanel.add(toolBarPanelMiddle, BorderLayout.CENTER); toolBarPanel.add(feedbackActionsToolbar.getComponent(), BorderLayout.LINE_END); } else { //skip setup when called from unit tests toolBarPanel = new JPanel(); } //status panel with label and link final JPanel statusPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); statusLabel = new JLabel(); statusLink = new Hyperlink(); statusLink.setActionCommand(CMD_STATUS_LINK); statusPanel.add(statusLabel); statusPanel.add(statusLink); //tabPanel tabPanel = new JPanel(new BorderLayout()); tabPanel.add(toolBarPanel, BorderLayout.PAGE_START); tabPanel.add(scrollPanel, BorderLayout.CENTER); tabPanel.add(statusPanel, BorderLayout.PAGE_END); this.initialized = true; } }
From source file:org.omelogic.tome.EpiTome.java
public void init() { backingGraph = null;/*from w w w . java 2 s. c o m*/ tomeGraph = null; idFilter = null; JPanel tablePanel = new JPanel(); tomeTable = new JTable(); JScrollPane tomeTableScroller = new JScrollPane(tomeTable); tablePanel.setLayout(new BoxLayout(tablePanel, BoxLayout.PAGE_AXIS)); tablePanel.add(tomeTableScroller); tomeProps = new JLabel(""); JPanel tomePropsPanel = new JPanel(new BorderLayout()); tomePropsPanel.add(tomeProps, BorderLayout.LINE_START); //tablePanel.add(tomeTableFixed); tablePanel.add(tomePropsPanel); //JScrollPane tablePanelScroller = new JScrollPane(tablePanel); tablePanel.setPreferredSize(new Dimension(300, 400)); //####### CONTROLS ######################################### JPanel controlPanel = new JPanel(); JButton load = new JButton("LOAD"); load.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent act) { JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(new SIFFileFilter()); chooser.setMultiSelectionEnabled(false); int returnVal = chooser.showOpenDialog(tomeFrame); if (returnVal == JFileChooser.APPROVE_OPTION) { System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName()); } else { return; } File sifFile = chooser.getSelectedFile(); UndirectedSparseGraph result = null; try { result = SIFHandler.load(sifFile); } catch (Exception e) { System.out.println(e.toString()); } System.out.println("Loaded file!"); backingGraph = result; FilterDialog filterMe = new FilterDialog(); idFilter = filterMe.getFilter(); loadInitialGraph((UndirectedSparseGraph) TomeGraphUtilities.filterGraph(backingGraph, idFilter)); } }); JButton save = new JButton("SAVE"); save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent act) { if (tomeGraph == null) { JOptionPane.showMessageDialog(null, "No graph is loaded!", "ERROR!", JOptionPane.ERROR_MESSAGE); return; } JFileChooser chooser = new JFileChooser(); if (((Double) ((HashMap<String, Double>) (tomeGraph.getUserDatum("GraphStatistics"))) .get("AveragePathLength")).isInfinite()) { JOptionPane.showMessageDialog(null, "Graph is not fully connected! This renders most output useless. Try trimming the graph first...", "ERROR!", JOptionPane.ERROR_MESSAGE); return; } int returnVal = chooser.showSaveDialog(EpiTome.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); FileOutputStream out; // declare a file output object PrintStream p; // declare a print stream object try { // Create a new file output stream out = new FileOutputStream(file); // Connect print stream to the output stream p = new PrintStream(out); HashMap<String, Double> graphProps = (HashMap<String, Double>) tomeGraph .getUserDatum("GraphStatistics"); p.println("#---SUMMARY---"); p.println("#NumNodes:\t" + tomeGraph.numVertices()); p.println("#NumEdges:\t" + tomeGraph.numEdges()); p.println("#ClustCoeff:\t" + graphProps.get(TomeGraphUtilities.CLUSTERING_COEFFICIENT)); p.println("#AvgPathLen:\t" + graphProps.get(TomeGraphUtilities.AVERAGE_PATH_LENGTH)); p.println("#AvgDegree:\t" + graphProps.get(TomeGraphUtilities.AVERAGE_DEGREE)); p.println("#-------------"); p.println("\n\n"); p.println("NodeID\tClustCoeff\tAvgPathLen\tAvgDegree"); Iterator<TomeVertex> vertIter = tomeGraph.getVertices().iterator(); while (vertIter.hasNext()) { TomeVertex vert = vertIter.next(); p.println(vert.getID() + "\t" + vert.getClusteringCoefficient() + "\t" + vert.getAverageDistance() + "\t" + vert.getDegree()); } p.close(); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error writing to file!\n" + e.toString(), "ERROR!", JOptionPane.ERROR_MESSAGE); } } } }); JButton trim = new JButton("TRIM"); trim.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (tomeGraph == null) { JOptionPane.showMessageDialog(null, "No graph is loaded!", "ERROR!", JOptionPane.ERROR_MESSAGE); return; } TrimDialog trimMe = new TrimDialog(); loadSubGraph(trimMe.getTrimmedGraph(tomeGraph)); } }); JButton rset = new JButton("RSET"); rset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (backingGraph == null) { JOptionPane.showMessageDialog(null, "No graph is loaded!", "ERROR!", JOptionPane.ERROR_MESSAGE); return; } loadInitialGraph((UndirectedSparseGraph) TomeGraphUtilities.filterGraph(backingGraph, idFilter)); } }); JButton view = new JButton("VIEW"); view.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (tomeGraph == null) { JOptionPane.showMessageDialog(null, "No graph is loaded!", "ERROR!", JOptionPane.ERROR_MESSAGE); return; } GraphDialog graf = new GraphDialog(tomeGraph, getSelectedNodeSubGraph()); } }); JButton ctrl = new JButton("CTRL"); ctrl.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (tomeGraph == null) { JOptionPane.showMessageDialog(null, "No graph is loaded!", "ERROR!", JOptionPane.ERROR_MESSAGE); return; } try { ControlsDialog ctrls = new ControlsDialog(tomeGraph, backingGraph, NUM_CONTROLS, NUM_BINS_MAX); } catch (Exception excep) { } } }); JButton help = new JButton("HELP"); help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { HelpDialog.display(); } }); controlPanel.add(load); controlPanel.add(save); controlPanel.add(trim); controlPanel.add(rset); controlPanel.add(view); controlPanel.add(ctrl); controlPanel.add(help); //########################################################## Container content = tomeFrame.getContentPane(); content.removeAll(); content.add(tablePanel, BorderLayout.CENTER); content.add(controlPanel, BorderLayout.SOUTH); }
From source file:net.sf.jabref.gui.PreviewPanel.java
/** * * @param panel//ww w.j ava 2s .c o m * (may be null) If not given no toolbar is shown on the right * hand side. * @param databaseContext * (may be null) Used for resolving pdf directories for links. * @param layoutFile * (must be given) Used for layout */ public PreviewPanel(BasePanel panel, BibDatabaseContext databaseContext, String layoutFile) { super(new BorderLayout(), true); this.databaseContext = Optional.ofNullable(databaseContext); this.layoutFile = Objects.requireNonNull(layoutFile); updateLayout(); this.closeAction = new CloseAction(); this.printAction = new PrintAction(); this.copyPreviewAction = new CopyPreviewAction(); this.basePanel = Optional.ofNullable(panel); createPreviewPane(); if (panel != null) { // dropped files handler only created for main window // not for Windows as like the search results window this.previewPane.setTransferHandler( new PreviewPanelTransferHandler(panel.frame(), this, this.previewPane.getTransferHandler())); } // Set up scroll pane for preview pane scrollPane = new JScrollPane(previewPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(null); /* * If we have been given a panel and the preference option * previewPrintButton is set, show the tool bar */ if (this.basePanel.isPresent() && JabRefPreferences.getInstance().getBoolean(JabRefPreferences.PREVIEW_PRINT_BUTTON)) { add(createToolBar(), BorderLayout.LINE_START); } add(scrollPane, BorderLayout.CENTER); this.createKeyBindings(); }
From source file:components.TextSamplerDemo.java
public TextSamplerDemo() { setLayout(new BorderLayout()); //Create a regular text field. JTextField textField = new JTextField(10); textField.setActionCommand(textFieldString); textField.addActionListener(this); //Create a password field. JPasswordField passwordField = new JPasswordField(10); passwordField.setActionCommand(passwordFieldString); passwordField.addActionListener(this); //Create a formatted text field. JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime()); ftf.setActionCommand(textFieldString); ftf.addActionListener(this); //Create some labels for the fields. JLabel textFieldLabel = new JLabel(textFieldString + ": "); textFieldLabel.setLabelFor(textField); JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": "); passwordFieldLabel.setLabelFor(passwordField); JLabel ftfLabel = new JLabel(ftfString + ": "); ftfLabel.setLabelFor(ftf);//from w w w . j a v a 2 s. co m //Create a label to put messages during an action event. actionLabel = new JLabel("Type text in a field and press Enter."); actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); //Lay out the text controls and the labels. JPanel textControlsPane = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); textControlsPane.setLayout(gridbag); JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel }; JTextField[] textFields = { textField, passwordField, ftf }; addLabelTextRows(labels, textFields, gridbag, textControlsPane); c.gridwidth = GridBagConstraints.REMAINDER; //last c.anchor = GridBagConstraints.WEST; c.weightx = 1.0; textControlsPane.add(actionLabel, c); textControlsPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Create a text area. JTextArea textArea = new JTextArea("This is an editable JTextArea. " + "A text area is a \"plain\" text component, " + "which means that although it can display text " + "in any font, all of the text is in the same font."); textArea.setFont(new Font("Serif", Font.ITALIC, 16)); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); JScrollPane areaScrollPane = new JScrollPane(textArea); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setPreferredSize(new Dimension(250, 250)); areaScrollPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5)), areaScrollPane.getBorder())); //Create an editor pane. JEditorPane editorPane = createEditorPane(); JScrollPane editorScrollPane = new JScrollPane(editorPane); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(250, 145)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); //Create a text pane. JTextPane textPane = createTextPane(); JScrollPane paneScrollPane = new JScrollPane(textPane); paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); paneScrollPane.setPreferredSize(new Dimension(250, 155)); paneScrollPane.setMinimumSize(new Dimension(10, 10)); //Put the editor pane and the text pane in a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.5); JPanel rightPane = new JPanel(new GridLayout(1, 0)); rightPane.add(splitPane); rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Put everything together. JPanel leftPane = new JPanel(new BorderLayout()); leftPane.add(textControlsPane, BorderLayout.PAGE_START); leftPane.add(areaScrollPane, BorderLayout.CENTER); add(leftPane, BorderLayout.LINE_START); add(rightPane, BorderLayout.LINE_END); }