/** OptionPaneDemo Constructor */ public OptionPaneDemo(SwingSet2 swingset) { // Set the title for this demo, and an icon used to represent this // demo inside the SwingSet2 app. super(swingset, "OptionPaneDemo", "toolbar/JOptionPane.gif"); JPanel demo = getDemoPanel(); demo.setLayout(new BoxLayout(demo, BoxLayout.X_AXIS)); JPanel bp = new JPanel() { public Dimension getMaximumSize() { return new Dimension(getPreferredSize().width, super.getMaximumSize().height); } }; bp.setLayout(new BoxLayout(bp, BoxLayout.Y_AXIS)); bp.add(Box.createRigidArea(VGAP30)); bp.add(Box.createRigidArea(VGAP30)); bp.add(createInputDialogButton()); bp.add(Box.createRigidArea(VGAP15)); bp.add(createWarningDialogButton()); bp.add(Box.createRigidArea(VGAP15)); bp.add(createMessageDialogButton()); bp.add(Box.createRigidArea(VGAP15)); bp.add(createComponentDialogButton()); bp.add(Box.createRigidArea(VGAP15)); bp.add(createConfirmDialogButton()); bp.add(Box.createVerticalGlue()); demo.add(Box.createHorizontalGlue()); demo.add(bp); demo.add(Box.createHorizontalGlue()); }
/** * 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()); }
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); }
/** * Create the pixel location panel * * @param labelFont the font for the labels * @return the location panel */ public JPanel createLocationPanel(Font labelFont) { // create a location panel JPanel locationPanel = new JPanel(); locationPanel.setLayout(new FlowLayout()); Box hBox = Box.createHorizontalBox(); // create the labels rowLabel = new JLabel("Row:"); colLabel = new JLabel("Column:"); // create the text fields colValue = new JTextField(Integer.toString(colIndex + numberBase), 6); colValue.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { displayPixelInformation(colValue.getText(), rowValue.getText()); } }); rowValue = new JTextField(Integer.toString(rowIndex + numberBase), 6); rowValue.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { displayPixelInformation(colValue.getText(), rowValue.getText()); } }); // set up the next and previous buttons setUpNextAndPreviousButtons(); // set up the font for the labels colLabel.setFont(labelFont); rowLabel.setFont(labelFont); colValue.setFont(labelFont); rowValue.setFont(labelFont); // add the items to the vertical box and the box to the panel hBox.add(Box.createHorizontalGlue()); hBox.add(rowLabel); hBox.add(rowPrevButton); hBox.add(rowValue); hBox.add(rowNextButton); hBox.add(Box.createHorizontalStrut(10)); hBox.add(colLabel); hBox.add(colPrevButton); hBox.add(colValue); hBox.add(colNextButton); locationPanel.add(hBox); hBox.add(Box.createHorizontalGlue()); return locationPanel; }
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(); }
/** * 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 ReplyView(MikroEventModel e, EventViewManager m) { super(); evm = m; textArea = new JTextArea("@" + evm.event.getAuthor() + " ", 4, 45); Font f = new Font("Nimbus Sans L Bold", Font.PLAIN, 15); textArea.setFont(f); textArea.setLineWrap(true); ((AbstractDocument) textArea.getDocument()).setDocumentFilter(new DocumentSizeFilter(140)); buttonPanel = new JPanel(); submitButton = new JButton("Post"); cancelButton = new JButton("Cancel"); submitButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { evm.reply(textArea.getText()); } }); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { evm.setEventView(); } }); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); buttonPanel.add(Box.createHorizontalGlue()); buttonPanel.add(submitButton); buttonPanel.add(Box.createHorizontalStrut(5)); buttonPanel.add(cancelButton); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(textArea); this.add(buttonPanel); }
public DelegationPanel() { final BoxLayout boxLayout = new BoxLayout(this, BoxLayout.X_AXIS); setLayout(boxLayout); add(new JLabel(RefactoringBundle.message("delegation.panel.method.calls.label"))); myRbModifyCalls = new JRadioButton(); myRbModifyCalls.setText(RefactoringBundle.message("delegation.panel.modify.radio")); add(myRbModifyCalls); myRbGenerateDelegate = new JRadioButton(); myRbGenerateDelegate.setText( RefactoringBundle.message("delegation.panel.delegate.via.overloading.method")); add(myRbGenerateDelegate); myRbModifyCalls.setSelected(true); final ButtonGroup bg = new ButtonGroup(); bg.add(myRbModifyCalls); bg.add(myRbGenerateDelegate); add(Box.createHorizontalGlue()); myRbModifyCalls.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { stateModified(); } }); myRbGenerateDelegate.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { stateModified(); } }); }
public HeaderPanel(String heading) { super(); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.setBackground(background); JLabel panelLabel = new JLabel(" " + heading, SwingConstants.LEFT); Font labelFont = new Font("Dialog", Font.BOLD, 18); panelLabel.setFont(labelFont); this.add(panelLabel); this.add(Box.createHorizontalGlue()); refresh = new JButton("Refresh"); refresh.addActionListener(this); this.add(refresh); this.add(Box.createHorizontalStrut(5)); root = new JComboBox(); Dimension d = root.getPreferredSize(); d.width = 90; root.setPreferredSize(d); root.setMaximumSize(d); File[] roots = directoryPane.getRoots(); for (int i = 0; i < roots.length; i++) root.addItem(roots[i].getAbsolutePath()); this.add(root); root.setSelectedIndex(directoryPane.getCurrentRootIndex()); root.addActionListener(this); this.add(Box.createHorizontalStrut(17)); }
private Component createOptionsPanel() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); hideButton = new JButton( new AbstractAction("Hide") { public void actionPerformed(ActionEvent e) { hideSelected(); } }); showButton = new JButton( new AbstractAction("Show") { public void actionPerformed(ActionEvent e) { showSelected(); } }); panel.add(showButton); panel.add(Box.createHorizontalStrut(10)); panel.add(hideButton); panel.add(Box.createHorizontalGlue()); panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); return panel; }
public Header() { super(BoxLayout.LINE_AXIS); this.label = new JLabel(); this.label.setAlignmentY(Component.TOP_ALIGNMENT); this.label.setOpaque(false); // this.label.setVerticalAlignment (SwingConstants.TOP); // this.label.setVerticalTextPosition (SwingConstants.TOP); this.add(this.label); this.add(Box.createHorizontalGlue()); this.paintProvider = new GradientPainter(Header.defaultPaintLeftColor, Header.defaultPaintRightColor); this.setPadding(Header.defaultPadding); Font f = this.getFont().deriveFont(Font.BOLD, 14); this.setFont(f); this.setTitleColor(Header.defaultTitleColor); }
/** 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."); } } } }); }
private Container createAuthorPane() { // Create buttons JButton showAuthor = new JButton(new ShowAuthorAction()); JButton showAllAuth = new JButton(new ShowAllAuthorsAction()); JButton deleteAuthor = new JButton(new DeleteAuthorAction()); // Create panel Box pane = new Box(X_AXIS); pane.add(Box.createHorizontalGlue()); pane.add(showAuthor); pane.add(Box.createHorizontalStrut(5)); pane.add(showAllAuth); pane.add(Box.createHorizontalStrut(5)); pane.add(deleteAuthor); pane.add(Box.createHorizontalGlue()); return pane; }
public void setValue(String key, JComponent value) { JPanel p = keyValueComponentMap.get(key); p.removeAll(); p.add(value); p.add(Box.createHorizontalGlue()); p.repaint(); p.getParent().repaint(); }
/** Creates and displays the main GUI This GUI has the list and the main * buttons */ public void showGUI() { final JScrollPane scrollPane = new JScrollPane(); table = new JTable( new DefaultTableModel( new Object[][] {}, new String[] {"Username", "Password", "Pin", "Reward"})); AccountManager.loadAccounts(); if (AccountManager.hasAccounts()) { for (Account account : AccountManager.getAccounts()) { ((DefaultTableModel) table.getModel()) .addRow( new Object[] { account.getUsername(), account.getReward(), account.getPin(), account.getReward() }); } } final JToolBar bar = new JToolBar(); bar.setMargin(new Insets(1, 1, 1, 1)); bar.setFloatable(false); removeButton = new JButton("Remove"); final JButton newButton = new JButton("Add"); final JButton doneButton = new JButton("Save"); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.getSelectionModel().addListSelectionListener(new TableSelectionListener()); table.setShowGrid(true); final TableColumnModel cm = table.getColumnModel(); cm.getColumn(cm.getColumnIndex("Password")).setCellRenderer(new PasswordCellRenderer()); cm.getColumn(cm.getColumnIndex("Password")).setCellEditor(new PasswordCellEditor()); cm.getColumn(cm.getColumnIndex("Pin")).setCellRenderer(new PasswordCellRenderer()); cm.getColumn(cm.getColumnIndex("Pin")).setCellEditor(new PasswordCellEditor()); cm.getColumn(cm.getColumnIndex("Reward")).setCellEditor(new RandomRewardEditor()); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setViewportView(table); add(scrollPane, BorderLayout.CENTER); newButton.setFocusable(false); newButton.setToolTipText(newButton.getText()); newButton.setText("+"); bar.add(newButton); removeButton.setFocusable(false); removeButton.setToolTipText(removeButton.getText()); removeButton.setText("-"); bar.add(removeButton); bar.add(Box.createHorizontalGlue()); doneButton.setToolTipText(doneButton.getText()); bar.add(doneButton); newButton.addActionListener(this); removeButton.addActionListener(this); doneButton.addActionListener(this); add(bar, BorderLayout.SOUTH); final int row = table.getSelectedRow(); removeButton.setEnabled(row >= 0 && row < table.getRowCount()); table.clearSelection(); doneButton.requestFocus(); setPreferredSize(new Dimension(600, 300)); pack(); setLocationRelativeTo(getOwner()); setResizable(false); }
@Override public JComponent createComponent() { if (myMainComponent == null) { myMainComponent = new JPanel(new BorderLayout()); myCbUseSoftWrapsAtConsole = new JCheckBox(ApplicationBundle.message("checkbox.use.soft.wraps.at.console"), false); myCommandsHistoryLimitField = new JTextField(3); myCbOverrideConsoleCycleBufferSize = new JCheckBox( ApplicationBundle.message( "checkbox.override.console.cycle.buffer.size", String.valueOf(ConsoleBuffer.getLegacyCycleBufferSize() / 1024)), false); myCbOverrideConsoleCycleBufferSize.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { myConsoleCycleBufferSizeField.setEnabled( myCbOverrideConsoleCycleBufferSize.isSelected()); } }); myConsoleCycleBufferSizeField = new JTextField(3); JPanel northPanel = new JPanel(new GridBagLayout()); GridBag gridBag = new GridBag(); gridBag.anchor(GridBagConstraints.WEST).setDefaultAnchor(GridBagConstraints.WEST); northPanel.add(myCbUseSoftWrapsAtConsole, gridBag.nextLine().next()); northPanel.add(Box.createHorizontalGlue(), gridBag.next().coverLine()); northPanel.add( new JLabel(ApplicationBundle.message("editbox.console.history.limit")), gridBag.nextLine().next()); northPanel.add(myCommandsHistoryLimitField, gridBag.next()); if (ConsoleBuffer.useCycleBuffer()) { northPanel.add(myCbOverrideConsoleCycleBufferSize, gridBag.nextLine().next()); northPanel.add(myConsoleCycleBufferSizeField, gridBag.next()); } if (!editFoldingsOnly()) { JPanel wrapper = new JPanel(new BorderLayout()); wrapper.add(northPanel, BorderLayout.WEST); myMainComponent.add(wrapper, BorderLayout.NORTH); } Splitter splitter = new Splitter(true); myMainComponent.add(splitter, BorderLayout.CENTER); myPositivePanel = new MyAddDeleteListPanel( "Fold console lines that contain", "Enter a substring of a console line you'd like to see folded:"); myNegativePanel = new MyAddDeleteListPanel( "Exceptions", "Enter a substring of a console line you don't want to fold:"); splitter.setFirstComponent(myPositivePanel); splitter.setSecondComponent(myNegativePanel); myPositivePanel.getEmptyText().setText("Fold nothing"); myNegativePanel.getEmptyText().setText("No exceptions"); } return myMainComponent; }
private Container createCustomerPane() { // Create buttons JButton showCus = new JButton(new ShowCustomerAction()); JButton showAllCus = new JButton(new ShowAllCustomersAction()); JButton deleteCus = new JButton(new DeleteCustomerAction()); // Create panel Box pane = new Box(X_AXIS); pane.add(Box.createHorizontalGlue()); pane.add(showCus); pane.add(Box.createHorizontalStrut(5)); pane.add(showAllCus); pane.add(Box.createHorizontalStrut(5)); pane.add(deleteCus); pane.add(Box.createHorizontalGlue()); return pane; }
/** Builds the MenuBar */ private void buildUI() { // Construct menu items JMenu lookAndFeel = new JMenu("Look and feel"); JRadioButtonMenuItem nativeLaF = new JRadioButtonMenuItem("Native", true); JRadioButtonMenuItem javaLaF = new JRadioButtonMenuItem("Java (Metal)"); JRadioButtonMenuItem motifLaF = new JRadioButtonMenuItem("Motif"); JMenu help = new JMenu("Help"); JMenuItem about = new JMenuItem("About"); // Add menu items to menu bar add(lookAndFeel); lookAndFeel.add(nativeLaF); lookAndFeel.add(javaLaF); lookAndFeel.add(motifLaF); add(Box.createHorizontalGlue()); add(help); help.add(about); // Add buttons to button group ButtonGroup laFGroup = new ButtonGroup(); laFGroup.add(nativeLaF); laFGroup.add(javaLaF); laFGroup.add(motifLaF); // Set action listeners nativeLaF.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { UIUtilities.setLookAndFeel(owner, UIManager.getSystemLookAndFeelClassName()); owner.pack(); } }); javaLaF.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { UIUtilities.setLookAndFeel(owner, UIManager.getCrossPlatformLookAndFeelClassName()); owner.pack(); } }); motifLaF.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { UIUtilities.setLookAndFeel(owner, "com.sun.java.swing.plaf.motif.MotifLookAndFeel"); owner.pack(); } }); about.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { UIUtilities.showAboutDialog(owner); } }); }
/** * @param listener - GUI * @param size - Dimension */ public KodeKsToolBar(GUI listener, Dimension size) { setPreferredSize(size); setOpaque(true); setBorder(BorderFactory.createBevelBorder(VERTICAL)); JButton ToolBarItem_NGame = new JButton(" New Game "); ToolBarItem_NGame.setPreferredSize(new Dimension(128, size.height)); ToolBarItem_NGame.setBorder(BorderFactory.createRaisedBevelBorder()); ToolBarItem_NGame.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new NewGameDialog(); } }); add(ToolBarItem_NGame); JButton ToolBarItem_Load = new JButton(" Load "); ToolBarItem_Load.setPreferredSize(new Dimension(128, size.height)); ToolBarItem_Load.setBorder(BorderFactory.createRaisedBevelBorder()); ToolBarItem_Load.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new LoadGame(); } }); JButton ToolBarItem_Save = new JButton(" Save "); ToolBarItem_Save.setPreferredSize(new Dimension(128, size.height)); ToolBarItem_Save.setBorder(BorderFactory.createRaisedBevelBorder()); ToolBarItem_Save.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new SaveGame(); } }); JButton ToolBarItem_Resign = new JButton(" Resign "); ToolBarItem_Resign.setPreferredSize(new Dimension(128, size.height)); ToolBarItem_Resign.setBorder(BorderFactory.createRaisedBevelBorder()); ToolBarItem_Resign.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new ResignDialog(); } }); setFloatable(false); add(ToolBarItem_NGame); add(ToolBarItem_Load); add(ToolBarItem_Save); add(ToolBarItem_Resign); add(Box.createHorizontalGlue()); }
private JPanel createSavePanel() { JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); saveButton = new JButton("Save"); saveButton.setEnabled(false); buttonPanel.add(Box.createHorizontalGlue()); buttonPanel.add(saveButton); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); return buttonPanel; }
private void initComponents() { final SimpleDateFormat dateFrmt = new SimpleDateFormat(DEFAULT_DATE_FORMAT); panel = new JPanel(); panel.setLayout(new BorderLayout()); JPanel north = new JPanel(); north.setLayout(new BoxLayout(north, BoxLayout.X_AXIS)); JLabel dateLbl = new JLabel("検査日:"); north.add(dateLbl); dateFld = new JTextField(10); dateFld.setMaximumSize(dateFld.getPreferredSize()); dateFld.setEditable(false); dateFld.setText(dateFrmt.format(new Date())); north.add(dateFld); north.add(Box.createHorizontalGlue()); editCheck = new JCheckBox("項目編集"); north.add(editCheck); panel.add(north, BorderLayout.NORTH); JPanel south = new JPanel(); south.setLayout(new FlowLayout()); deleteBtn = new JButton("削除", deleteIcon); deleteBtn.setEnabled(false); south.add(deleteBtn); closeBtn = new JButton("閉じる", closeIcon); south.add(closeBtn); saveBtn = new JButton("保存", saveIcon); south.add(saveBtn); panel.add(south, BorderLayout.SOUTH); setTable = new JTable(); JScrollPane scroll = new JScrollPane(setTable); centerPanel = new JPanel(); centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.X_AXIS)); centerPanel.add(scroll); panel.add(centerPanel, BorderLayout.CENTER); templateTable = new JTable(); templateTable.setToolTipText("DnDで左の施設内検査項目テーブルに追加してください。"); rtScroll = new JScrollPane(templateTable); Dimension d = new Dimension(200, 200); rtScroll.setPreferredSize(d); d = new Dimension(200, Integer.MAX_VALUE); rtScroll.setMaximumSize(d); dialog = new JDialog(); String title = ClientContext.getFrameTitle("院内検査項目追加"); dialog.setTitle(title); dialog.setModal(true); dialog.setContentPane(panel); ClientContext.setDolphinIcon(dialog); dialog.pack(); dialog.setLocationRelativeTo(chart.getFrame()); }
private Container createBookPane() { // Create buttons JButton bookLookup = new JButton(new BookLookupAction()); JButton showCat = new JButton(new ShowCatalogueAction()); JButton showLoanedBook = new JButton(new ShowLoanedBooksAction()); JButton deleteBook = new JButton(new DeleteBookAction()); // Create panel Box pane = new Box(X_AXIS); pane.add(Box.createHorizontalGlue()); pane.add(bookLookup); pane.add(Box.createHorizontalStrut(5)); pane.add(showCat); pane.add(Box.createHorizontalStrut(5)); pane.add(showLoanedBook); pane.add(Box.createHorizontalStrut(5)); pane.add(deleteBook); pane.add(Box.createHorizontalGlue()); return pane; }
public JPanel createContentPane() { // We create a bottom JPanel to place everything on. JPanel totalGUI = new JPanel(); // We set the layout of the main JPanel to be BoxLayout. // LINE_AXIS sets them left to right, PAGE_AXIS sets them // from top to bottom. totalGUI.setLayout(new BoxLayout(totalGUI, BoxLayout.LINE_AXIS)); JPanel redPanel = new JPanel(); redPanel.setBackground(Color.red); redPanel.setMinimumSize(new Dimension(50, 50)); redPanel.setPreferredSize(new Dimension(50, 50)); totalGUI.add(redPanel); // This is the first spacer. This creates a spacer 10px wide that // will never get bigger or smaller. totalGUI.add(Box.createRigidArea(new Dimension(10, 0))); JPanel yellowPanel = new JPanel(); yellowPanel.setBackground(Color.yellow); yellowPanel.setPreferredSize(new Dimension(50, 50)); totalGUI.add(yellowPanel); // This spacer takes any spare space and places it as part of the spacer // If you drag the window wider, the space will get wider. totalGUI.add(Box.createHorizontalGlue()); JPanel greenPanel = new JPanel(); greenPanel.setBackground(Color.green); greenPanel.setPreferredSize(new Dimension(50, 50)); totalGUI.add(greenPanel); // This spacer is a custom spacer. // The minimum size acts like a rigid area that // will not get any smaller than 10 pixels on the x-axis (horizontal) // and not get any smaller than 50 pixels on the y axis (vertical). // The way the maximum size is set up means the spacer acts like glue // and will expand to fit the available space. Dimension minSize = new Dimension(10, 50); Dimension prefSize = new Dimension(10, 50); Dimension maxSize = new Dimension(Short.MAX_VALUE, 50); totalGUI.add(new Box.Filler(minSize, prefSize, maxSize)); JPanel bluePanel = new JPanel(); bluePanel.setBackground(Color.blue); bluePanel.setPreferredSize(new Dimension(50, 50)); totalGUI.add(bluePanel); totalGUI.setOpaque(true); return totalGUI; }
/** * Update the dialog contents. * * @param jheader The job portion of the dialog header. * @param job The queue job. * @param info The current job status information. */ public void updateContents( String jheader, QueueJob job, QueueJobInfo info, SubProcessExecDetails details) { ActionAgenda agenda = job.getActionAgenda(); QueueJobResults results = info.getResults(); String dir = "-"; if ((agenda != null) && (info.getOsType() != null)) dir = agenda.getTargetPath(info.getOsType()).toString(); String hostname = ""; if (info.getHostname() != null) hostname = (" [" + info.getHostname() + "]"); String command = "-"; if (details != null) command = details.getCommand(); TreeMap<String, String> env = new TreeMap<String, String>(); if (details != null) env = details.getEnvironment(); setHeader("Execution Details -" + jheader + hostname); pWorkingDirField.setText(dir); BaseAction action = job.getAction(); pCommandLineLabel.setText( "Action Command: " + action.getName() + " (v" + action.getVersionID() + ")"); pCommandLineArea.setText(command); { Component comps[] = UIFactory.createTitledPanels(); { JPanel tpanel = (JPanel) comps[0]; JPanel vpanel = (JPanel) comps[1]; if (!env.isEmpty()) { String last = env.lastKey(); for (String key : env.keySet()) { String value = env.get(key); JTextField field = UIFactory.createTitledTextField(tpanel, key + ":", sTSize, vpanel, value, sVSize); field.setHorizontalAlignment(JLabel.LEFT); if (!key.equals(last)) UIFactory.addVerticalSpacer(tpanel, vpanel, 3); } } else { tpanel.add(Box.createRigidArea(new Dimension(sTSize, 0))); vpanel.add(Box.createHorizontalGlue()); } } pEnvLabel.setText("Toolset Environment: " + agenda.getToolset()); pEnvScroll.setViewportView(comps[2]); } }
void initComponents() { JPanel mainPanel = new JPanel(new BorderLayout()); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); Color bgColor = Color.getHSBColor(0.58f, 0.17f, 0.95f); buttonPanel.setBackground(bgColor); Border empty = BorderFactory.createEmptyBorder(5, 5, 5, 5); buttonPanel.setBorder(empty); textField = new JTextField(75); buttonPanel.add(textField); buttonPanel.add(Box.createHorizontalStrut(10)); searchPHI = new JButton("Search PHI"); searchPHI.addActionListener(this); buttonPanel.add(searchPHI); buttonPanel.add(Box.createHorizontalStrut(10)); searchTrial = new JButton("Search Trial IDs"); searchTrial.addActionListener(this); buttonPanel.add(searchTrial); buttonPanel.add(Box.createHorizontalStrut(20)); buttonPanel.add(Box.createHorizontalGlue()); saveAs = new JCheckBox("Save As..."); saveAs.setBackground(bgColor); buttonPanel.add(saveAs); mainPanel.add(buttonPanel, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(); textPane = new ColorPane(); // textPane.setEditable(false); scrollPane.setViewportView(textPane); mainPanel.add(scrollPane, BorderLayout.CENTER); JPanel footerPanel = new JPanel(); footerPanel.setLayout(new BoxLayout(footerPanel, BoxLayout.X_AXIS)); footerPanel.setBackground(bgColor); message = new JLabel("Ready..."); footerPanel.add(message); mainPanel.add(footerPanel, BorderLayout.SOUTH); setTitle(windowTitle); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); getContentPane().add(mainPanel, BorderLayout.CENTER); pack(); centerFrame(); }
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()); }
/** * Create the toolbar. By default this reads the resource file for the definition of the toolbar. */ private Component createToolbar() { toolbar = new JToolBar(); for (String toolKey : getToolBarKeys()) { if (toolKey.equals("-")) { toolbar.add(Box.createHorizontalStrut(5)); } else { toolbar.add(createTool(toolKey)); } } toolbar.add(Box.createHorizontalGlue()); return toolbar; }
/** * Create the toolbar. By default this reads the resource file for the definition of the toolbar. */ private Component createToolbar() { toolbar = new JToolBar(); String[] toolKeys = SCSUtility.tokenize(getResourceString("toolbar")); for (int i = 0; i < toolKeys.length; i++) { if (toolKeys[i].equals("-")) { toolbar.add(Box.createHorizontalStrut(5)); } else { toolbar.add(createTool(toolKeys[i])); } } toolbar.add(Box.createHorizontalGlue()); return toolbar; }
public FooterPanel() { super(); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.setBackground(Color.getHSBColor(0.58f, 0.17f, 0.95f)); subdirectories = new JCheckBox("Include subdirectories"); subdirectories.setBackground(background); this.add(subdirectories); this.add(Box.createHorizontalGlue()); extensionButton = new JButton(filter.getDescription()); this.add(extensionButton); this.add(Box.createHorizontalStrut(17)); extensionButton.addActionListener(this); }
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)); }