private static void assertChooser() { if (fc == null) { fc = new JFileChooser(); Box ab = new Box(BoxLayout.Y_AXIS); ab.add(afap = new AudioFormatAccessoryPanel("Sample format")); ab.add(sap = new SaveAccessoryPanel(null)); fc.setAccessory(ab); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setFileFilter( new FileFilter() { public boolean accept(File f) { return f.isDirectory() && !f.equals(Zoeos.getZoeosLocalDir()); } public String getDescription() { return "Directories"; } }); fc.setAcceptAllFileFilterUsed(false); } try { fc.setCurrentDirectory(new File(ZPREF_lastDir.getValue())); } catch (Exception e) { } }
public void init(List<T> sources) { this.sources = sources; consoles = new HashMap<T, ConsolePanel>(); singleNodeGUIS = new ArrayList<JComponent>(); // setPreferredSize(new Dimension(1000,700)); JSplitPane[] leftAndRight = new JSplitPane[] { new JSplitPane(JSplitPane.VERTICAL_SPLIT), new JSplitPane(JSplitPane.VERTICAL_SPLIT) }; for (int i = 0; i < sources.size(); i++) { T t = sources.get(i); Box box = Box.createVerticalBox(); ConsolePanel console = createConsole(); consoles.put(t, console); JScrollPane jsp = new JScrollPane(console); jsp.setMinimumSize(new Dimension(600, 300)); jsp.setPreferredSize(new Dimension(600, 300)); jsp.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)); box.add(jsp); // box.add(Box.createVerticalGlue()); box.add(createInputTF(t)); box.add(Box.createVerticalStrut(3)); box.setBorder(BorderFactory.createTitledBorder(String.valueOf(t))); singleNodeGUIS.add(box); leftAndRight[i / 2].add(box); } add(leftAndRight[0]); add(leftAndRight[1]); }
protected JComponent createCenterPanel() { JPanel contentPanel = new JPanel(new BorderLayout()); Box mainPanel = Box.createHorizontalBox(); myClassFilterEditor = new ClassFilterEditor( myProject, myChooserFilter, "reference.viewBreakpoints.classFilters.newPattern"); myClassFilterEditor.setPreferredSize(new Dimension(400, 200)); myClassFilterEditor.setBorder( IdeBorderFactory.createTitledBorder( DebuggerBundle.message("class.filters.dialog.inclusion.filters.group"), false, false, true)); mainPanel.add(myClassFilterEditor); myClassExclusionFilterEditor = new ClassFilterEditor( myProject, myChooserFilter, "reference.viewBreakpoints.classFilters.newPattern"); myClassExclusionFilterEditor.setPreferredSize(new Dimension(400, 200)); myClassExclusionFilterEditor.setBorder( IdeBorderFactory.createTitledBorder( DebuggerBundle.message("class.filters.dialog.exclusion.filters.group"), false, false, true)); mainPanel.add(myClassExclusionFilterEditor); contentPanel.add(mainPanel, BorderLayout.CENTER); return contentPanel; }
private MainPanel() { super(new BorderLayout()); StringBuffer buf = new StringBuffer(); for (int i = 0; i < 100; i++) { String s = i + LF; buf.append(s); } final JScrollPane scrollPane = new JScrollPane(new JTextArea(buf.toString())); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); JSpinner spinner = new JSpinner( new SpinnerNumberModel( scrollPane.getVerticalScrollBar().getUnitIncrement(1), 1, 100000, 1)); spinner.setEditor(new JSpinner.NumberEditor(spinner, "#####0")); spinner.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner s = (JSpinner) e.getSource(); scrollPane.getVerticalScrollBar().setUnitIncrement((Integer) s.getValue()); } }); Box box = Box.createHorizontalBox(); box.add(new JLabel("Unit Increment:")); box.add(Box.createHorizontalStrut(2)); box.add(spinner); box.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(box, BorderLayout.NORTH); add(scrollPane); setPreferredSize(new Dimension(320, 240)); }
private void initGui() { JComponent filler = new JComponent() { @Override public Dimension getPreferredSize() { return myTextLabel.getPreferredSize(); } }; setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(3, 20, 3, 20)); add(myTextLabel, BorderLayout.WEST); Box box = Box.createHorizontalBox(); box.add(Box.createHorizontalGlue()); JPanel panel = new JPanel(new GridLayout(1, myLabels.size(), 0, 0)); for (final JComponent myLabel : myLabels) { panel.add(myLabel); } panel.setMaximumSize(panel.getPreferredSize()); box.add(panel); box.add(Box.createHorizontalGlue()); add(box, BorderLayout.CENTER); add(filler, BorderLayout.EAST); }
/** * Creates the Factor definition subform * * @return - JPanel containing the Factor definition subform. */ private Container createTransposedView() { Box subformContainer = Box.createVerticalBox(); transposedSpreadsheetSubform = new TransposedSubForm( "spreadsheet data", FieldTypes.ROW, transposedSpreadsheetModel.getFields(), transposedSpreadsheetModel.getNumberOfRecords(), width, height, transposedSpreadsheetModel.getData(), transposedSpreadsheetModel.getSpreadsheet().getDataEntryEnv()); transposedSpreadsheetSubform.createGUI(); transposedSpreadsheetSubform.addPropertyChangeListener( "rowAdded", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { updateInformation(); } }); subformContainer.add(Box.createVerticalStrut(15)); subformContainer.add(transposedSpreadsheetSubform); subformContainer.add(Box.createVerticalStrut(15)); return subformContainer; }
/** Performs the action of loading a session from a file. */ public void actionPerformed(ActionEvent e) { DataModel dataModel = getDataEditor().getSelectedDataModel(); if (!(dataModel instanceof DataSet)) { JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "Must be a tabular data set."); return; } this.dataSet = (DataSet) dataModel; SpinnerNumberModel spinnerNumberModel = new SpinnerNumberModel(getNumLags(), 0, 20, 1); JSpinner jSpinner = new JSpinner(spinnerNumberModel); jSpinner.setPreferredSize(jSpinner.getPreferredSize()); spinnerNumberModel.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { SpinnerNumberModel model = (SpinnerNumberModel) e.getSource(); setNumLags(model.getNumber().intValue()); } }); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); Box b = Box.createVerticalBox(); Box b1 = Box.createHorizontalBox(); b1.add(new JLabel("Number of time lags: ")); b1.add(Box.createHorizontalGlue()); b1.add(Box.createHorizontalStrut(15)); b1.add(jSpinner); b1.setBorder(new EmptyBorder(10, 10, 10, 10)); b.add(b1); panel.add(b, BorderLayout.CENTER); EditorWindow editorWindow = new EditorWindow(panel, "Create time series data", "Save", true); DesktopController.getInstance().addEditorWindow(editorWindow); editorWindow.setVisible(true); editorWindow.addInternalFrameListener( new InternalFrameAdapter() { public void internalFrameClosed(InternalFrameEvent e) { EditorWindow window = (EditorWindow) e.getSource(); if (!window.isCanceled()) { if (dataSet.isContinuous()) { createContinuousTimeSeriesData(); } else if (dataSet.isDiscrete()) { createDiscreteTimeSeriesData(); } else { JOptionPane.showMessageDialog( JOptionUtils.centeringComp(), "Data set must be either continuous or discrete."); } } } }); }
public AuthorAnnotationEditor() { // field is added in super constructor box.add(author); box.add(value); box.setBorder(Borders.EMPTY_BORDER); }
private void createMarginBox(Container c, Component comp) { c.add(Box.createVerticalStrut(10)); Box lrMargins = Box.createHorizontalBox(); lrMargins.add(Box.createHorizontalStrut(10)); lrMargins.add(comp); lrMargins.add(Box.createHorizontalStrut(10)); c.add(lrMargins); c.add(Box.createVerticalStrut(10)); }
public Box createBox(TeXEnvironment env) { // first create a simple square root construction TeXFont tf = env.getTeXFont(); int style = env.getStyle(); // calculate minimum clearance clr float clr, drt = tf.getDefaultRuleThickness(style); if (style < TeXConstants.STYLE_TEXT) clr = tf.getXHeight(style, tf.getChar(sqrtSymbol, style).getFontCode()); else clr = drt; clr = drt + Math.abs(clr) / 4; // cramped style for the formula under the root sign Box bs = base.createBox(env.crampStyle()); HorizontalBox b = new HorizontalBox(bs); b.add(new SpaceAtom(TeXConstants.UNIT_MU, 1, 0, 0).createBox(env.crampStyle())); // create root sign float totalH = b.getHeight() + b.getDepth(); Box rootSign = DelimiterFactory.create(sqrtSymbol, env, totalH + clr + drt); // add half the excess to clr float delta = rootSign.getDepth() - (totalH + clr); clr += delta / 2; // create total box rootSign.setShift(-(b.getHeight() + clr)); OverBar ob = new OverBar(b, clr, rootSign.getHeight()); ob.setShift(-(b.getHeight() + clr + drt)); HorizontalBox squareRoot = new HorizontalBox(rootSign); squareRoot.add(ob); if (root == null) // simple square root return squareRoot; else { // nthRoot, not a simple square root // create box from root Box r = root.createBox(env.rootStyle()); // shift root up float bottomShift = FACTOR * (squareRoot.getHeight() + squareRoot.getDepth()); r.setShift(squareRoot.getDepth() - r.getDepth() - bottomShift); // negative kern Box negativeKern = new SpaceAtom(TeXConstants.UNIT_MU, -10f, 0, 0).createBox(env); // arrange both boxes together with the negative kern Box res = new HorizontalBox(); float pos = r.getWidth() + negativeKern.getWidth(); if (pos < 0) res.add(new StrutBox(-pos, 0, 0, 0)); res.add(r); res.add(negativeKern); res.add(squareRoot); return res; } }
public void buildGUI() { theFrame = new JFrame("Cyber BeatBox"); theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); BorderLayout layout = new BorderLayout(); JPanel background = new JPanel(layout); background.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); checkboxList = new ArrayList<JCheckBox>(); Box buttonBox = new Box(BoxLayout.Y_AXIS); JButton start = new JButton("Start"); start.addActionListener(new MyStartListener()); buttonBox.add(start); JButton stop = new JButton("Stop"); stop.addActionListener(new MyStopListener()); buttonBox.add(stop); JButton upTempo = new JButton("Tempo Up"); upTempo.addActionListener(new MyUpTempoListener()); buttonBox.add(upTempo); JButton downTempo = new JButton("Tempo Down"); downTempo.addActionListener(new MyDownTempoListener()); buttonBox.add(downTempo); Box nameBox = new Box(BoxLayout.Y_AXIS); for (int i = 0; i < 16; i++) { nameBox.add(new Label(instrumentNames[i])); } background.add(BorderLayout.EAST, buttonBox); background.add(BorderLayout.WEST, nameBox); theFrame.getContentPane().add(background); GridLayout grid = new GridLayout(16, 16); grid.setVgap(1); grid.setHgap(2); mainPanel = new JPanel(grid); background.add(BorderLayout.CENTER, mainPanel); for (int i = 0; i < 256; i++) { JCheckBox c = new JCheckBox(); c.setSelected(false); checkboxList.add(c); mainPanel.add(c); } // end loop setUpMidi(); theFrame.setBounds(50, 50, 300, 300); theFrame.pack(); theFrame.setVisible(true); } // close method
protected void instantiateFrame() { Box container = Box.createHorizontalBox(); JLabel confirmation1 = new JLabel(areYouSureIcon); confirmation1.setHorizontalAlignment(SwingConstants.RIGHT); final JLabel noButton = new JLabel(noIcon); noButton.setHorizontalAlignment(SwingConstants.RIGHT); noButton.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent mouseEvent) { noButton.setIcon(noIconOver); } @Override public void mouseExited(MouseEvent mouseEvent) { noButton.setIcon(noIcon); } @Override public void mousePressed(MouseEvent mouseEvent) { noButton.setIcon(noIcon); firePropertyChange(NO, "noPressed", ""); } }); final JLabel yesButton = new JLabel(yesIcon); yesButton.setHorizontalAlignment(SwingConstants.RIGHT); yesButton.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent mouseEvent) { yesButton.setIcon(yesIconOver); } @Override public void mouseExited(MouseEvent mouseEvent) { yesButton.setIcon(yesIcon); } @Override public void mousePressed(MouseEvent mouseEvent) { yesButton.setIcon(yesIcon); firePropertyChange(YES, "yesPressed", ""); } }); container.add(confirmation1); container.add(noButton); container.add(yesButton); add(container); }
private void init() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); Box labelBox = Box.createHorizontalBox(); labelBox.add(new JLabel("Initialize Variable: ")); labelBox.add(varName); labelBox.add(Box.createHorizontalGlue()); add(labelBox); add(Box.createVerticalStrut(10)); varEditPane.setLayout(new BorderLayout()); add(varEditPane); add(Box.createVerticalGlue()); }
/** * Constructor of class Wizard * * @param parent the parent frame * @param name the title of the dialog * @param modal whether the dialog should be modal */ public Wizard(JFrame parent, String name, boolean modal) { super(parent, name, modal); // Code inspired by http://java.sun.com/developer/technicalArticles/GUI/swing/wizard/ listeners = new LinkedList<WizardListener>(); returnCode = -1; this.parent = parent; panelMap = new HashMap<Object, WizardPanel>(); panels = new Vector<WizardPanel>(); firstPanel = null; currentPanel = null; handler = new EventHandler(); // Create the main panel JPanel buttonPanel = new JPanel(); Box buttonBox = new Box(BoxLayout.X_AXIS); cardPanel = new JPanel(); cardPanel.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10))); cardLayout = new CardLayout(); cardPanel.setLayout(cardLayout); backButton = new JButton("Back"); nextButton = new JButton("Next"); cancelButton = new JButton("Cancel"); backButton.addActionListener(handler); nextButton.addActionListener(handler); cancelButton.addActionListener(handler); backButton.setEnabled(false); buttonPanel.setLayout(new BorderLayout()); buttonPanel.add(new JSeparator(), BorderLayout.NORTH); buttonBox.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10))); buttonBox.add(backButton); buttonBox.add(Box.createHorizontalStrut(10)); buttonBox.add(nextButton); buttonBox.add(Box.createHorizontalStrut(30)); buttonBox.add(cancelButton); buttonPanel.add(buttonBox, java.awt.BorderLayout.EAST); getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH); getContentPane().add(cardPanel, java.awt.BorderLayout.CENTER); pack(); }
private void init() { setLayout(new BorderLayout()); tableModel = new NotesTableModel(getCharacter()); table = new JTable(tableModel); table.setRowHeight(50); tableModel.updateColumns(table); table.setDefaultRenderer(String.class, new NotesCellRenderer()); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { updateControls(); } }); add(new JScrollPane(table), "Center"); Box box = Box.createHorizontalBox(); box.add(Box.createHorizontalGlue()); addNoteButton = new JButton("Add Custom"); addNoteButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { String note = JOptionPane.showInputDialog("Custom Note"); getCharacter().addNote(getGameHandler().getClient().getClientName(), "Custom", note); updatePanel(); } }); box.add(addNoteButton); box.add(Box.createHorizontalGlue()); deleteNoteButton = new JButton("Delete Custom"); deleteNoteButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { Note note = getSelectedNote(); if (note != null) { getCharacter().deleteNote(note.getId()); updatePanel(); } } }); box.add(deleteNoteButton); box.add(Box.createHorizontalGlue()); add(box, "South"); updateControls(); }
/** * Constructs the Gui used to edit properties; called from each constructor. Constructs labels and * text fields for editing each property and adds appropriate listeners. */ private void buildGui() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); if (alphaField != null) { Box b1 = Box.createHorizontalBox(); b1.add(new JLabel("Alpha:")); b1.add(Box.createHorizontalStrut(10)); b1.add(Box.createHorizontalGlue()); b1.add(alphaField); add(b1); } Box b2 = Box.createHorizontalBox(); b2.add(new JLabel("Depth:")); b2.add(Box.createHorizontalStrut(10)); b2.add(Box.createHorizontalGlue()); b2.add(depthField); add(b2); // Box b4 = Box.createHorizontalBox(); // b4.add(Box.createHorizontalStrut(25)); // b4.add(new JLabel("(where possible)")); // b4.add(Box.createHorizontalGlue()); // add(b4); add(Box.createHorizontalGlue()); }
/** * Creates a dialog that is showing the histogram for the given node (if null one is selected for * you) */ private JPanel createNormalityTestDialog(Node selected) { DataSet dataSet = (DataSet) dataEditor.getSelectedDataModel(); QQPlot qqPlot = new QQPlot(dataSet, selected); NormalityTestEditorPanel editorPanel = new NormalityTestEditorPanel(qqPlot, dataSet); JTextArea display = new JTextArea( NormalityTests.runNormalityTests( dataSet, (ContinuousVariable) qqPlot.getSelectedVariable()), 20, 65); display.setEditable(false); editorPanel.addPropertyChangeListener(new NormalityTestListener(display)); Box box = Box.createHorizontalBox(); box.add(display); box.add(Box.createHorizontalStrut(3)); box.add(editorPanel); box.add(Box.createHorizontalStrut(5)); box.add(Box.createHorizontalGlue()); Box vBox = Box.createVerticalBox(); vBox.add(Box.createVerticalStrut(15)); vBox.add(box); vBox.add(Box.createVerticalStrut(5)); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(vBox, BorderLayout.CENTER); return panel; }
public MainPanel() { super(new BorderLayout()); BufferedImage bi = null; try { bi = ImageIO.read(getClass().getResource("test.jpg")); } catch (IOException ioe) { ioe.printStackTrace(); } bufferedImage = bi; List<AbstractAction> list = Arrays.asList( new AbstractAction("NONE") { @Override public void actionPerformed(ActionEvent e) { mode = Flip.NONE; repaint(); } }, new AbstractAction("VERTICAL") { @Override public void actionPerformed(ActionEvent e) { mode = Flip.VERTICAL; repaint(); } }, new AbstractAction("HORIZONTAL") { @Override public void actionPerformed(ActionEvent e) { mode = Flip.HORIZONTAL; repaint(); } }); Box box = Box.createHorizontalBox(); box.add(Box.createHorizontalGlue()); box.add(new JLabel("Flip: ")); for (AbstractAction a : list) { JRadioButton rb = new JRadioButton(a); if (bg.getButtonCount() == 0) { rb.setSelected(true); } box.add(rb); bg.add(rb); box.add(Box.createHorizontalStrut(5)); } add(p); add(box, BorderLayout.SOUTH); setOpaque(false); setPreferredSize(new Dimension(320, 240)); }
private void createGUIDialog() { JPanel mainPanel = new JPanel(new BorderLayout()); setContentPane(mainPanel); mainPanel.add(new JLabel("Select dimensions to rulerender: "), BorderLayout.PAGE_START); JPanel combosPanel = new JPanel(new GridLayout(2, 2, 10, 10)); mainPanel.add(combosPanel, BorderLayout.CENTER); combosPanel.add(new JLabel("Dimension 1:")); box1 = new JComboBox(choices.toArray()); box1.setEditable(false); box1.setSelectedIndex(0); combosPanel.add(box1); combosPanel.add(new JLabel("Dimension 2:")); box2 = new JComboBox(choices.toArray()); box2.setEditable(false); box2.setSelectedIndex(Math.min(choices.size(), 1)); combosPanel.add(box2); Box h = Box.createHorizontalBox(); mainPanel.add(h, BorderLayout.PAGE_END); h.add(Box.createHorizontalGlue()); JButton okButton = new JButton("OK"); h.add(okButton); okButton.setDefaultCapable(true); h.add(Box.createHorizontalStrut(10)); JButton cancelButton = new JButton("Cancel"); h.add(cancelButton); okButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { returnCode = OK_BUTTON; dispose(); } }); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { returnCode = CANCEL_BUTTON; dispose(); } }); }
private void init() { setLayout(new BorderLayout(0, 5)); setBorder(makeBorder()); Box box = Box.createVerticalBox(); box.add(makeTitlePanel()); box.add(createResetPanel()); box.add(createParameterPanel()); box.add(createFilenamePanel()); add(box, BorderLayout.NORTH); JPanel panel = createScriptPanel(); add(panel, BorderLayout.CENTER); // Don't let the input field shrink too much add(Box.createVerticalStrut(panel.getPreferredSize().height), BorderLayout.WEST); }
private void jbInit() throws Exception { box1 = Box.createVerticalBox(); this.getContentPane().setLayout(borderLayout1); close.setText("Close"); close.addActionListener(new CellHelpWindow_close_actionAdapter(this)); jLabel1.setText("Recommendation"); jLabel2.setText("Description"); jPanel1.setLayout(borderLayout2); jPanel2.setLayout(borderLayout3); description.setText("jTextPane1"); description.setContentType("text/html"); scp1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scp1.setToolTipText(""); recom.setText(""); recom.setContentType("text/html"); this.getContentPane().add(box1, BorderLayout.CENTER); box1.add(jPanel1, null); box1.add(jPanel2, null); this.getContentPane().add(jPanel3, BorderLayout.SOUTH); jPanel3.add(close, null); jPanel2.add(jLabel1, BorderLayout.NORTH); jPanel2.add(scp2, BorderLayout.CENTER); scp2.getViewport().add(recom, null); jPanel2.add(scp2, BorderLayout.CENTER); jPanel1.add(jLabel2, BorderLayout.NORTH); jPanel1.add(scp1, BorderLayout.CENTER); scp1.getViewport().add(description, null); }
public void setEntity(java.lang.Object ent) { Method[] methods = ent.getClass().getDeclaredMethods(); box.removeAll(); for (Method m : methods) { if (m.getName().toLowerCase().startsWith("get")) { String attName = m.getName().substring(3); Object result; try { result = m.invoke(ent, new Object[] {}); String value = "null"; if (result != null) value = result.toString(); JPanel attPane = new JPanel(new FlowLayout(FlowLayout.LEFT)); attPane.add(new JLabel(attName + " : " + m.getReturnType().getName() + " = " + value)); box.add(attPane); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } }
public void installNorthComponents(final Project project) { ContainerUtil.addAll( myNorthComponents, Extensions.getExtensions(IdeRootPaneNorthExtension.EP_NAME, project)); for (IdeRootPaneNorthExtension northComponent : myNorthComponents) { myNorthPanel.add(northComponent.getComponent()); northComponent.uiSettingsChanged(myUISettings); } }
public void add(int pos, Box b) { super.add(pos, b); if (pos == 0) { depth += b.depth + height; height = b.height; } else depth += b.height + b.depth; recalculateWidth(b); }
public final void add(Box b) { super.add(b); if (children.size() == 1) { height = b.height; depth = b.depth; } else depth += b.height + b.depth; recalculateWidth(b); }
public VerticalBox(Box b, float rest, int alignment) { this(); add(b); if (alignment == TeXConstants.ALIGN_CENTER) { StrutBox s = new StrutBox(0, rest / 2, 0, 0); super.add(0, s); height += rest / 2; depth += rest / 2; super.add(s); } else if (alignment == TeXConstants.ALIGN_TOP) { depth += rest; super.add(new StrutBox(0, rest, 0, 0)); } else if (alignment == TeXConstants.ALIGN_BOTTOM) { height += rest; super.add(0, new StrutBox(0, rest, 0, 0)); } }
private JPanel createSelectOutputDirectoryUI() { JPanel container = new JPanel(new BorderLayout()); setupFileChooser(); outputFileLocation = new FileSelectionPanel("", fileChooser); Box fileLocationContainer = Box.createVerticalBox(); fileLocationContainer.add( UIHelper.wrapComponentInPanel(new JLabel(chooseOutputLocation, JLabel.LEFT))); fileLocationContainer.add(Box.createVerticalStrut(5)); fileLocationContainer.add(outputFileLocation); container.add(fileLocationContainer, BorderLayout.NORTH); return container; }
/** Creates the main pane of the dialog. */ protected Component createPreferencesPane() { str = ResourceBundle.getBundle("org.pegadi.lister.PrefsDialogStrings"); Box pane = new Box(BoxLayout.Y_AXIS); Border b; JPanel selectionPane = new JPanel(); selectionPane.setLayout(new BoxLayout(selectionPane, BoxLayout.Y_AXIS)); ButtonGroup selectionGroup = new ButtonGroup(); b = BorderFactory.createTitledBorder(str.getString("selection_title")); selectionPane.setBorder(b); lastRadio = new JRadioButton(str.getString("selection_last")); selectionGroup.add(lastRadio); selectionPane.add(lastRadio); defaultRadio = new JRadioButton(str.getString("selection_default")); selectionGroup.add(defaultRadio); selectionPane.add(defaultRadio); pane.add(selectionPane); /** * **************************************************************** JPanel scorePanel = new * JPanel(new GridBagLayout()); b = * BorderFactory.createTitledBorder(str.getString("score_title")); scorePanel.setBorder(b); * * <p>scoreCheck = new JCheckBox(str.getString("score_label")); scorePanel.add(scoreCheck, new * GridBagConstraints2(0, 0, 2, 1, 1.0, 0.0 ,GridBagConstraints.NORTHWEST, * GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); * * <p>scorePanel.add(new JLabel(str.getString("score_hi_label")), new GridBagConstraints2(0, 1, * 1, 1, 0.0, 0.0 ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, * 5), 0, 0)); * * <p>topScoreField = new JTextField(4); scorePanel.add(topScoreField, new * GridBagConstraints2(1, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.NORTHWEST, * GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); * * <p>scorePanel.add(new JLabel(str.getString("score_day_label")), new GridBagConstraints2(0, 2, * 1, 1, 0.0, 0.0 ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, * 5), 0, 0)); * * <p>dayScoreField = new JTextField(4); scorePanel.add(dayScoreField, new * GridBagConstraints2(1, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.NORTHWEST, * GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); * * <p>scorePanel.add(new JLabel(str.getString("score_pers_label")), new GridBagConstraints2(0, * 3, 1, 1, 0.0, 0.0 ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, * 5), 0, 0)); * * <p>personalScoreField = new JTextField(4); scorePanel.add(personalScoreField, new * GridBagConstraints2(1, 3, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, * new Insets(5, 5, 5, 5), 0, 0)); * * <p>pane.add(scorePanel); *************************************************************** */ return pane; }
JPanel createCustomPanel() { Box p = new Box(BoxLayout.PAGE_AXIS); // left operand sink leftSink = new PartSink(PartType.EXPRESSION_PART); leftSink.addCombineListener( new CombineListener() { public void combined() { WorkspaceObject c = leftSink.getContainedPart(); Object o = c.getPart(); Expression exp = (Expression) o; op.setLeftOperand(exp); } public void split() { op.setLeftOperand(null); } }); p.add(leftSink); JLabel eqLab = new JLabel("<html><b>÷</b></html>"); p.add(eqLab); // right operand sink rightSink = new PartSink(PartType.EXPRESSION_PART); rightSink.addCombineListener( new CombineListener() { public void combined() { WorkspaceObject c = rightSink.getContainedPart(); Object o = c.getPart(); Expression exp = (Expression) o; op.setRightOperand(exp); } public void split() { op.setRightOperand(null); } }); p.add(rightSink); JPanel retPanel = new JPanel(); retPanel.setLayout(new BorderLayout()); retPanel.add(p, BorderLayout.CENTER); return retPanel; }
public void init() { horizontal.add(new Button("水平按钮一")); horizontal.add(Box.createHorizontalGlue()); horizontal.add(new Button("水平按钮二")); // 水平方向不可拉伸的间距,其宽度为10px horizontal.add(Box.createHorizontalStrut(10)); horizontal.add(new Button("水平按钮三")); vertical.add(new Button("垂直按钮一")); vertical.add(Box.createVerticalGlue()); vertical.add(new Button("垂直按钮二")); // 垂直方向不可拉伸的间距,其高度为10px vertical.add(Box.createVerticalStrut(10)); vertical.add(new Button("垂直按钮三")); f.add(horizontal, BorderLayout.NORTH); f.add(vertical); f.pack(); f.setVisible(true); }