List of usage examples for javax.swing JPanel setLayout
public void setLayout(LayoutManager mgr)
From source file:com.jbombardier.console.panels.MachineTelemetryPanel.java
/** * Create the panel./*from w w w. j av a 2 s. c o m*/ */ public MachineTelemetryPanel() { setBorder(new TitledBorder(null, "Machine Telemetry", TitledBorder.LEADING, TitledBorder.TOP, null, null)); setLayout(new MigLayout("ins 0", "[grow,fill]0[grow,fill]0[grow,fill]0[grow,fill]", "[grow]0[grow]")); stackedBarCPU = ChartBuilder.startStackedBar().setTitle("CPU").setOrientation(PlotOrientation.HORIZONTAL) .setYAxisLabel("Percentage cpu").setYMaximum(100).setXAxisLabel("").setYAxisLabel("").toChart(); stackedBarMemory = ChartBuilder.startStackedBar().setTitle("Memory") .setOrientation(PlotOrientation.HORIZONTAL).setYAxisLabel("MBytes").toChart(); ioBarChart = ChartBuilder.startBar().setTitle("IO").setYAxisLabel("KBytes/sec") .setOrientation(PlotOrientation.HORIZONTAL).yAxisLock(1024).setVerticalXAxisLabels(true).toChart(); // add(stackedBarCPU.getComponent(), "cell 0 0,grow"); JPanel a = new JPanel(); a.add(stackedBarCPU.getComponent()); add(a, "cell 0 0,grow"); a.setLayout(new MigLayout("ins 0", "[grow,fill]", "[grow,fill]")); // add(stackedBarMemory.getComponent(), "cell 1 0,grow"); JPanel b = new JPanel(); b.add(stackedBarMemory.getComponent()); add(b, "cell 1 0,grow"); b.setLayout(new MigLayout("ins 0", "[grow,fill]", "[grow,fill]")); // add(stackedBarIO.getComponent(), "cell 2 0,grow, wrap"); JPanel c = new JPanel(); c.add(ioBarChart.getComponent()); add(c, "cell 2 0 2 1,grow"); c.setLayout(new MigLayout("ins 0", "[grow,fill]", "[grow,fill]")); xyCPU = (XYTimeChartPanel) ChartBuilder.startXY().setTitle("CPU").setYAxisLabel("Percentage cpu used") .toChart(); xyMemory = (XYTimeChartPanel) ChartBuilder.startXY().setTitle("Memory").setYAxisLabel("MBytes free") .toChart(); xyIORx = (XYTimeChartPanel) ChartBuilder.startXY().setTitle("Network IO").setYAxisLabel("KBytes/sec") .toChart(); xyIOTx = (XYTimeChartPanel) ChartBuilder.startXY().setTitle("Network IO").setYAxisLabel("KBytes/sec") .toChart(); // add(xyCPU.getComponent(), "cell 0 1,grow"); JPanel d = new JPanel(); d.add(xyCPU.getComponent()); add(d, "cell 0 1,grow"); d.setLayout(new MigLayout("ins 0", "[grow,fill]", "[grow,fill]")); // add(xyMemory.getComponent(), "cell 1 1,grow"); JPanel e = new JPanel(); e.add(xyMemory.getComponent()); add(e, "cell 1 1,grow"); e.setLayout(new MigLayout("ins 0", "[grow,fill]", "[grow,fill]")); JPanel f = new JPanel(); f.add(xyIORx.getComponent()); add(f, "cell 2 1,grow"); f.setLayout(new MigLayout("ins 0", "[grow,fill]", "[grow,fill]")); JPanel g = new JPanel(); g.add(xyIOTx.getComponent()); add(g, "cell 3 1,grow"); g.setLayout(new MigLayout("ins 0", "[grow,fill]", "[grow,fill]")); timer = TimerUtils.every("MachineTelemetryPanel-Updater", 500, TimeUnit.MILLISECONDS, new Runnable() { public void run() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { updateInternal2(); } }); } }); }
From source file:CubaHSQLDBServer.java
private CubaHSQLDBServer() { Font monospaced = Font.decode("monospaced"); statusArea = new JTextArea(2, 80); statusArea.setFont(monospaced);/*from w ww. j av a2 s . c o m*/ statusArea.setMargin(new Insets(5, 5, 5, 5)); exceptionArea = new JTextArea(26, 80); exceptionArea.setFont(monospaced); exceptionArea.setMargin(new Insets(5, 5, 5, 5)); JPanel exceptionWrapperContainer = new JPanel(); exceptionWrapperContainer.setLayout(new BorderLayout(0, 0)); exceptionWrapperContainer.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); exceptionWrapperContainer.add(exceptionArea); JPanel statusWrapperContainer = new JPanel(); statusWrapperContainer.setLayout(new BorderLayout(0, 0)); statusWrapperContainer.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); statusWrapperContainer.add(statusArea); addCopyPopup(statusArea); addCopyPopup(exceptionArea); exceptionBox = new JPanel(); LayoutBuilder.create(exceptionBox, BoxLayout.Y_AXIS).addSpace(5).addComponent(exceptionWrapperContainer); LayoutBuilder.create(this.getContentPane(), BoxLayout.X_AXIS).addSpace(5).addContainer(BoxLayout.Y_AXIS) .addSpace(5).addComponent(statusWrapperContainer).addComponent(exceptionBox).addSpace(5) .returnToParent().addSpace(5); statusArea.setEditable(false); exceptionArea.setEditable(false); exceptionBox.setVisible(false); exceptionArea.setBackground(new Color(255, 255, 212)); this.pack(); this.setResizable(true); this.setTitle("HSQLDB Server"); try { this.setIconImage(ImageIO.read(getClass().getResourceAsStream("/icons/database.png"))); } catch (IOException e) { throw new IllegalStateException("Unable to find icon for HSQLDB window"); } }
From source file:com.digitalgeneralists.assurance.ui.components.FileAttributesPanel.java
private void initializeComponent() { if (!this.initialized) { if (this.file == null) { this.dialogTitle = "No File Provided"; this.file = null; } else {/* ww w. j a v a2s. c o m*/ StringBuilder title = new StringBuilder(128); this.dialogTitle = title.append("Attributes for ").append(file.getFile().getName()).toString(); title.setLength(0); title = null; } GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); GridBagConstraints filePanelConstraints = new GridBagConstraints(); filePanelConstraints.anchor = GridBagConstraints.NORTH; filePanelConstraints.fill = GridBagConstraints.HORIZONTAL; filePanelConstraints.gridx = 0; filePanelConstraints.gridy = 0; filePanelConstraints.weightx = 1.0; filePanelConstraints.weighty = 0.1; filePanelConstraints.gridheight = 1; filePanelConstraints.gridwidth = 1; filePanelConstraints.insets = new Insets(5, 5, 5, 5); final JPanel filePanel = new JPanel(); filePanel.setLayout(new GridBagLayout()); GridBagConstraints filePathValueConstraints = new GridBagConstraints(); filePathValueConstraints.anchor = GridBagConstraints.WEST; filePathValueConstraints.gridx = 0; filePathValueConstraints.gridy = 0; filePathValueConstraints.weightx = 1.0; filePathValueConstraints.weighty = 1.0; filePathValueConstraints.gridheight = 1; filePathValueConstraints.gridwidth = 1; filePathValueConstraints.insets = new Insets(5, 5, 5, 5); String filePath = "File is null."; if (file != null) { File diskFile = file.getFile(); if (diskFile == null) { filePath = "The disk file is not set."; } else { filePath = diskFile.getPath(); } diskFile = null; } JLabel filePathValue = new JLabel(filePath); filePath = null; filePanel.add(filePathValue, filePathValueConstraints); this.add(filePanel, filePanelConstraints); Border attributesBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); attributesBorder = BorderFactory.createTitledBorder(attributesBorder, "File Attributes", TitledBorder.CENTER, TitledBorder.TOP); GridBagConstraints attributesPanelConstraints = new GridBagConstraints(); attributesPanelConstraints.anchor = GridBagConstraints.SOUTH; attributesPanelConstraints.fill = GridBagConstraints.BOTH; attributesPanelConstraints.gridx = 0; attributesPanelConstraints.gridy = 1; attributesPanelConstraints.weightx = 1.0; attributesPanelConstraints.weighty = 0.9; attributesPanelConstraints.gridheight = 1; attributesPanelConstraints.gridwidth = 1; attributesPanelConstraints.insets = new Insets(0, 5, 5, 5); JPanel attributesPanel = this.createFileAttributesPanel(file); attributesPanel.setBorder(attributesBorder); this.add(attributesPanel, attributesPanelConstraints); this.initialized = true; } }
From source file:io.github.jeremgamer.editor.panels.Actions.java
public Actions(final JFrame frame, final ActionPanel ap) { this.frame = frame; this.setBorder(BorderFactory.createTitledBorder("")); JButton add = null;/*w w w . j a v a 2 s. c o m*/ try { add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png")))); } catch (IOException e) { e.printStackTrace(); } add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") String name = jop.showInputDialog(null, "Nommez l'action :", "Crer une action", JOptionPane.QUESTION_MESSAGE); if (name != null) { for (int i = 0; i < data.getSize(); i++) { if (data.get(i).equals(name)) { name += "1"; } } data.addElement(name); new ActionSave(name); OtherPanel.updateLists(); ButtonPanel.updateLists(); ActionPanel.updateLists(); } } catch (IOException e) { e.printStackTrace(); } } }); JButton remove = null; try { remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { if (actionList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/actions/" + actionList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog(null, "tes-vous sr de vouloir supprimer cette action?", "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { if (actionList.getSelectedValue().equals(ap.getFileName())) { ap.setFileName(""); } ap.hide(); file.delete(); data.remove(actionList.getSelectedIndex()); OtherPanel.updateLists(); ButtonPanel.updateLists(); } } } catch (NullPointerException npe) { npe.printStackTrace(); } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); buttons.add(add); buttons.add(remove); updateList(); actionList.addMouseListener(new MouseAdapter() { @SuppressWarnings("unchecked") public void mouseClicked(MouseEvent evt) { JList<String> list = (JList<String>) evt.getSource(); if (evt.getClickCount() == 2) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { ap.show(); ap.load(new File("projects/" + Editor.getProjectName() + "/actions/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { ap.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { ap.hideThenShow(); previousSelection = list.getSelectedValue(); ap.load(new File("projects/" + Editor.getProjectName() + "/actions/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { ap.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { ap.show(); ap.load(new File("projects/" + Editor.getProjectName() + "/actions/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { ap.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { ap.hideThenShow(); previousSelection = list.getSelectedValue(); ap.load(new File("projects/" + Editor.getProjectName() + "/actions/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { ap.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(actionList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); OtherPanel.updateLists(); }
From source file:com.digitalgeneralists.assurance.ui.components.SettingsPanel.java
@Override protected void initializeComponent() { if (!this.initialized) { this.dialogTitle = Application.applicationShortName + " Settings"; // NOTE: There is no notion of add-mode in this dialog. There should // always be a single instance of the application configuration. if (this.configuration == null) { this.configuration = ApplicationConfiguration.createDefaultConfiguration(); }/*www . j a va 2s. c om*/ this.mode = AssuranceDialogMode.EDIT; GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); final JPanel scanSettingsPanel = new JPanel(); scanSettingsPanel.setLayout(new GridBagLayout()); Border scanSettingsPanelBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); scanSettingsPanelBorder = BorderFactory.createTitledBorder(scanSettingsPanelBorder, "Scan Settings", TitledBorder.CENTER, TitledBorder.TOP); GridBagConstraints scanSettingsPanelConstraints = new GridBagConstraints(); scanSettingsPanelConstraints.anchor = GridBagConstraints.NORTH; scanSettingsPanelConstraints.fill = GridBagConstraints.HORIZONTAL; scanSettingsPanelConstraints.gridx = 0; scanSettingsPanelConstraints.gridy = 0; scanSettingsPanelConstraints.weightx = 1.0; scanSettingsPanelConstraints.weighty = 1.0; scanSettingsPanelConstraints.gridheight = 1; scanSettingsPanelConstraints.gridwidth = 2; scanSettingsPanelConstraints.insets = new Insets(5, 5, 5, 5); scanSettingsPanel.setBorder(scanSettingsPanelBorder); this.add(scanSettingsPanel, scanSettingsPanelConstraints); GridBagConstraints ignoredFileNamesLabelConstraints = new GridBagConstraints(); ignoredFileNamesLabelConstraints.anchor = GridBagConstraints.NORTHWEST; ignoredFileNamesLabelConstraints.fill = GridBagConstraints.NONE; ignoredFileNamesLabelConstraints.gridx = 0; ignoredFileNamesLabelConstraints.gridy = 0; ignoredFileNamesLabelConstraints.weightx = 1.0; ignoredFileNamesLabelConstraints.weighty = 1.0; ignoredFileNamesLabelConstraints.gridheight = 1; ignoredFileNamesLabelConstraints.gridwidth = 1; ignoredFileNamesLabelConstraints.insets = new Insets(5, 10, 0, 5); final JLabel ignoredFileNamesLabel = new JLabel("Ignored Files", SwingConstants.LEFT); scanSettingsPanel.add(ignoredFileNamesLabel, ignoredFileNamesLabelConstraints); GridBagConstraints ignoredFileNamesTextFieldConstraints = new GridBagConstraints(); ignoredFileNamesTextFieldConstraints.anchor = GridBagConstraints.NORTH; ignoredFileNamesTextFieldConstraints.fill = GridBagConstraints.HORIZONTAL; ignoredFileNamesTextFieldConstraints.gridx = 0; ignoredFileNamesTextFieldConstraints.gridy = 1; ignoredFileNamesTextFieldConstraints.weightx = 1.0; ignoredFileNamesTextFieldConstraints.weighty = 1.0; ignoredFileNamesTextFieldConstraints.gridheight = 1; ignoredFileNamesTextFieldConstraints.gridwidth = 2; ignoredFileNamesTextFieldConstraints.insets = new Insets(2, 5, 5, 5); GridBagConstraints ignoredFileExtensionsLabelConstraints = new GridBagConstraints(); ignoredFileExtensionsLabelConstraints.anchor = GridBagConstraints.NORTHWEST; ignoredFileExtensionsLabelConstraints.fill = GridBagConstraints.NONE; ignoredFileExtensionsLabelConstraints.gridx = 0; ignoredFileExtensionsLabelConstraints.gridy = 2; ignoredFileExtensionsLabelConstraints.weightx = 1.0; ignoredFileExtensionsLabelConstraints.weighty = 1.0; ignoredFileExtensionsLabelConstraints.gridheight = 1; ignoredFileExtensionsLabelConstraints.gridwidth = 1; ignoredFileExtensionsLabelConstraints.insets = new Insets(5, 10, 0, 5); final JLabel ignoredFileExtensionsLabel = new JLabel("Ignored File Extensions", SwingConstants.LEFT); scanSettingsPanel.add(ignoredFileExtensionsLabel, ignoredFileExtensionsLabelConstraints); GridBagConstraints ignoredFileExtensionsTextFieldConstraints = new GridBagConstraints(); ignoredFileExtensionsTextFieldConstraints.anchor = GridBagConstraints.NORTH; ignoredFileExtensionsTextFieldConstraints.fill = GridBagConstraints.HORIZONTAL; ignoredFileExtensionsTextFieldConstraints.gridx = 0; ignoredFileExtensionsTextFieldConstraints.gridy = 3; ignoredFileExtensionsTextFieldConstraints.weightx = 1.0; ignoredFileExtensionsTextFieldConstraints.weighty = 1.0; ignoredFileExtensionsTextFieldConstraints.gridheight = 1; ignoredFileExtensionsTextFieldConstraints.gridwidth = 2; ignoredFileExtensionsTextFieldConstraints.insets = new Insets(2, 5, 5, 5); scanSettingsPanel.add(this.ignoredFileNamesTextField, ignoredFileNamesTextFieldConstraints); this.ignoredFileNamesTextField.getDocument().addDocumentListener(this.textPropertyValidationListener); scanSettingsPanel.add(this.ignoredFileExtensionsTextField, ignoredFileExtensionsTextFieldConstraints); this.ignoredFileExtensionsTextField.getDocument() .addDocumentListener(this.textPropertyValidationListener); GridBagConstraints numberScanThreadsLabelConstraints = new GridBagConstraints(); numberScanThreadsLabelConstraints.anchor = GridBagConstraints.NORTH; numberScanThreadsLabelConstraints.fill = GridBagConstraints.NONE; numberScanThreadsLabelConstraints.gridx = 0; numberScanThreadsLabelConstraints.gridy = 4; numberScanThreadsLabelConstraints.weightx = 1.0; numberScanThreadsLabelConstraints.weighty = 1.0; numberScanThreadsLabelConstraints.gridheight = 1; numberScanThreadsLabelConstraints.gridwidth = 1; numberScanThreadsLabelConstraints.insets = new Insets(10, 5, 0, 5); final JLabel numberOfThreadsLabel = new JLabel("Number of Threads", SwingConstants.RIGHT); scanSettingsPanel.add(numberOfThreadsLabel, numberScanThreadsLabelConstraints); GridBagConstraints numberScanThreadsSpinnerConstraints = new GridBagConstraints(); numberScanThreadsSpinnerConstraints.anchor = GridBagConstraints.NORTHWEST; numberScanThreadsSpinnerConstraints.fill = GridBagConstraints.NONE; numberScanThreadsSpinnerConstraints.gridx = 1; numberScanThreadsSpinnerConstraints.gridy = 4; numberScanThreadsSpinnerConstraints.weightx = 1.0; numberScanThreadsSpinnerConstraints.weighty = 1.0; numberScanThreadsSpinnerConstraints.gridheight = 1; numberScanThreadsSpinnerConstraints.gridwidth = 1; numberScanThreadsSpinnerConstraints.insets = new Insets(5, 5, 5, 5); scanSettingsPanel.add(this.numberScanThreadsSpinner, numberScanThreadsSpinnerConstraints); if (this.configuration != null) { this.ignoredFileNamesTextField.setText(this.configuration.getIgnoredFileNames()); this.ignoredFileExtensionsTextField.setText(this.configuration.getIgnoredFileExtensions()); this.numberScanThreadsSpinner.setValue(this.configuration.getNumberOfScanThreads()); } this.initialized = true; } }
From source file:SimpleSoundCapture.java
public SimpleSoundCapture() { setLayout(new BorderLayout()); EmptyBorder eb = new EmptyBorder(5, 5, 5, 5); SoftBevelBorder sbb = new SoftBevelBorder(SoftBevelBorder.LOWERED); setBorder(new EmptyBorder(5, 5, 5, 5)); JPanel p1 = new JPanel(); p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS)); JPanel p2 = new JPanel(); p2.setBorder(sbb);//from ww w. j a va 2s .com p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS)); JPanel buttonsPanel = new JPanel(); buttonsPanel.setBorder(new EmptyBorder(10, 0, 5, 0)); playB = addButton("Play", buttonsPanel, false); captB = addButton("Record", buttonsPanel, true); p2.add(buttonsPanel); p1.add(p2); add(p1); }
From source file:cn.edu.tsinghua.gui.HistogramDemo.java
/** * Initialize display./* www.jav a2s .com*/ * @author Sun Microsystems * @param filename is the image filename */ public HistogramDemo(String filename) { File f = new File(filename); if (f.exists() && f.canRead()) { source = JAI.create("fileload", filename); } else { return; } canvas = new ImageDisplay(source); canvas.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 2)); panner = new Panner(canvas, source, 128); panner.setBackground(Color.red); panner.setBorder(new EtchedBorder()); canvas.add(panner); Font font = new Font("SansSerif", Font.BOLD, 12); JLabel title = new JLabel(" Histogram"); title.setFont(font); title.setLocation(0, 32); setOpaque(true); setLayout(new BorderLayout()); setBackground(Color.white); graph = new XYPlot(); graph.setBackground(Color.black); graph.setBorder(new LineBorder(new Color(0, 0, 255), 1)); Colorbar cbar = new Colorbar(); cbar.setBackground(Color.black); cbar.setPreferredSize(new Dimension(256, 25)); cbar.setBorder(new LineBorder(new Color(255, 0, 255), 2)); JPanel hist_panel = new JPanel(); hist_panel.setLayout(new BorderLayout()); hist_panel.setBackground(Color.white); hist_panel.add(graph, BorderLayout.CENTER); hist_panel.add(cbar, BorderLayout.SOUTH); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(2, 1, 5, 5)); panel.setBackground(Color.white); panel.add(canvas); panel.add(hist_panel); JPanel controlPanel = new JPanel(); controlPanel.setLayout(new FlowLayout()); reset = new JButton("Reset"); equal = new JButton("Uniform"); norm = new JButton("Gaussian"); piece = new JButton("Piecewise"); reset.addActionListener(this); equal.addActionListener(this); norm.addActionListener(this); piece.addActionListener(this); controlPanel.add(reset); controlPanel.add(equal); controlPanel.add(norm); controlPanel.add(piece); add(title, BorderLayout.NORTH); add(panel, BorderLayout.CENTER); add(controlPanel, BorderLayout.SOUTH); // original histogram (remains unmodified) // graph.plot( getHistogram(source) ); graph.plot(getMultiHistogram(source)); }
From source file:com.intel.stl.ui.common.view.ChartsSectionView.java
protected void setLayout(JPanel mainPanel) { mainPanel.setLayout(new GridLayout(1, 4, 5, 5)); }
From source file:de.codesourcery.jasm16.ide.ui.views.HexDumpView.java
protected JPanel createPanel() { textArea.setEditable(false);/* w w w.j av a 2 s . co m*/ setColors(textArea); textArea.setFont(getMonospacedFont()); textArea.setEditable(false); // dump panel final JPanel dumpPanel = new JPanel(); setColors(dumpPanel); dumpPanel.setLayout(new GridBagLayout()); GridBagConstraints cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH); dumpPanel.add(textArea, cnstrs); // toolbar panel final JPanel toolbarPanel = new JPanel(); setColors(toolbarPanel); toolbarPanel.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE); toolbarPanel.add(new JLabel("Goto"), cnstrs); final JTextField gotoTextfield = new JTextField(); gotoTextfield.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final String val = gotoTextfield.getText(); Address adr; if (StringUtils.isBlank(val)) { gotoTextfield.setText("0000"); adr = Address.wordAddress(0); } else { try { adr = Address.wordAddress(Misc.parseHexString(val)); } catch (NumberFormatException e1) { gotoTextfield.setText("0000"); adr = Address.wordAddress(0); } } dumpStartAddress = adr; refreshDisplay(); } }); cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL); toolbarPanel.add(gotoTextfield, cnstrs); // create result panel final JPanel result = new JPanel(); setColors(result); result.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, false, true, GridBagConstraints.BOTH); result.add(dumpPanel, cnstrs); cnstrs = constraints(1, 0, true, true, GridBagConstraints.VERTICAL); result.add(toolbarPanel, cnstrs); textArea.addKeyListener(new PagingKeyAdapter() { @Override protected void onePageUp() { HexDumpView.this.onePageUp(); } @Override protected void onePageDown() { HexDumpView.this.onePageDown(); } @Override protected void oneLineUp() { HexDumpView.this.oneLineUp(); } @Override protected void oneLineDown() { HexDumpView.this.oneLineDown(); } }); result.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { refreshDisplay(); } }); return result; }
From source file:de.codesourcery.jasm16.ide.ui.views.EmulationOptionsView.java
private JPanel createPanel() { final JPanel result = new JPanel(); result.setLayout(new GridBagLayout()); // 'Memory protection' checkbox int y = 0;//from ww w .j av a 2 s . com GridBagConstraints cnstrs = constraints(0, y++, true, false, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = 2; result.add(box1, cnstrs); cnstrs = constraints(0, y++, true, false, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = 2; result.add(box2, cnstrs); cnstrs = constraints(0, y++, true, false, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = 2; result.add(box3, cnstrs); cnstrs = constraints(0, y++, true, false, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = 2; result.add(box8, cnstrs); cnstrs = constraints(0, y++, true, false, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = 2; result.add(box4, cnstrs); cnstrs = constraints(0, y++, true, false, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = 2; result.add(box5, cnstrs); cnstrs = constraints(0, y++, true, false, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = 2; result.add(box6, cnstrs); cnstrs = constraints(0, y++, true, false, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = 2; result.add(box7, cnstrs); cnstrs = constraints(0, y++, true, false, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = 2; result.add(diskDrivePanel, cnstrs); cnstrs = constraints(0, y++, true, false, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = 2; result.add(emulatorPanel, cnstrs); // cancel button cnstrs = constraints(0, y, false, false, GridBagConstraints.NONE); cnstrs.weightx = 0.33; cnstrs.anchor = GridBagConstraints.CENTER; final JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onCancel(); } }); result.add(cancelButton, cnstrs); // save button cnstrs = constraints(1, y, true, false, GridBagConstraints.NONE); cnstrs.weightx = 0.33; cnstrs.anchor = GridBagConstraints.CENTER; final JButton saveButton = new JButton("Save"); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final EmulationOptions options = new EmulationOptions(); saveChangesTo(options); onSave(options); } }); result.add(saveButton, cnstrs); return result; }