List of usage examples for javax.swing BorderFactory createEmptyBorder
public static Border createEmptyBorder(int top, int left, int bottom, int right)
From source file:com.tascape.qa.th.android.tools.UiAutomatorViewer.java
private void start() throws Exception { SwingUtilities.invokeLater(() -> { jd = new ViewerParameterDialog("Launch Android App"); JPanel jpParameters = new JPanel(); jpParameters.setLayout(new BoxLayout(jpParameters, BoxLayout.PAGE_AXIS)); jd.setParameterPanel(jpParameters); {/* www . j av a 2 s. c o m*/ JPanel jp = new JPanel(); jpParameters.add(jp); jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS)); jp.add(new JLabel("Devices")); jp.add(jcbDevices); } { JPanel jp = new JPanel(); jpParameters.add(jp); jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS)); jp.add(new JLabel("App Package Name")); jp.add(jtfApp); if (StringUtils.isNotEmpty(appPackageName)) { jtfApp.setText(appPackageName); } jtfApp.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { jbLaunch.doClick(); } } }); } { JPanel jp = new JPanel(); jpParameters.add(jp); jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS)); jp.add(new JLabel("Interaction time (minute)")); jsDebugMinutes.getEditor().setEnabled(false); jp.add(jsDebugMinutes); } { JPanel jp = new JPanel(); jpParameters.add(jp); jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS)); jp.add(Box.createRigidArea(new Dimension(518, 2))); } JPanel jpAction = new JPanel(); jd.setActionPanel(jpAction); jpAction.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS)); jbLaunch.setFont(jbLaunch.getFont().deriveFont(Font.BOLD)); jbLaunch.setBorder(BorderFactory.createEtchedBorder()); jbLaunch.setEnabled(false); jpAction.add(jbLaunch); jbLaunch.addActionListener(event -> { new Thread() { @Override public void run() { launchApp(); } }.start(); }); jd.showDialog(); new Thread() { @Override public void run() { try { detectDevices(); } catch (Exception ex) { throw new RuntimeException(ex); } } }.start(); }); }
From source file:IconDemoApp.java
/** * Default constructor for the demo.//from w w w . j a v a 2s . c o m */ public IconDemoApp() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("Icon Demo: Please Select an Image"); // A label for displaying the pictures photographLabel.setVerticalTextPosition(JLabel.BOTTOM); photographLabel.setHorizontalTextPosition(JLabel.CENTER); photographLabel.setHorizontalAlignment(JLabel.CENTER); photographLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // We add two glue components. Later in process() we will add thumbnail // buttons // to the toolbar inbetween thease glue compoents. This will center the // buttons in the toolbar. buttonBar.add(Box.createGlue()); buttonBar.add(Box.createGlue()); add(buttonBar, BorderLayout.SOUTH); add(photographLabel, BorderLayout.CENTER); setSize(400, 300); // this centers the frame on the screen setLocationRelativeTo(null); // start the image loading SwingWorker in a background thread loadimages.execute(); }
From source file:CheckBoxDemo.java
public CheckBoxDemo() { super(new BorderLayout()); // Create the check boxes. chinButton = new JCheckBox("Chin"); chinButton.setMnemonic(KeyEvent.VK_C); chinButton.setSelected(true);/*from w w w . j av a 2 s . c o 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:components.IconDemoApp.java
/** * Default constructor for the demo./*from w w w.j ava 2s . c o m*/ */ public IconDemoApp() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("Icon Demo: Please Select an Image"); // A label for displaying the pictures photographLabel.setVerticalTextPosition(JLabel.BOTTOM); photographLabel.setHorizontalTextPosition(JLabel.CENTER); photographLabel.setHorizontalAlignment(JLabel.CENTER); photographLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // We add two glue components. Later in process() we will add thumbnail buttons // to the toolbar inbetween thease glue compoents. This will center the // buttons in the toolbar. buttonBar.add(Box.createGlue()); buttonBar.add(Box.createGlue()); add(buttonBar, BorderLayout.SOUTH); add(photographLabel, BorderLayout.CENTER); setSize(400, 300); // this centers the frame on the screen setLocationRelativeTo(null); // start the image loading SwingWorker in a background thread loadimages.execute(); }
From source file:hr.restart.util.chart.ChartXYZ2.java
void showOptions() { if (optionsPanel == null) { catSlider = new JSlider(0, 50, iCategoryMargin); catSlider.setPaintLabels(true);//from w w w . j ava 2 s . c o m catSlider.setPaintTicks(true); catSlider.setMajorTickSpacing(10); catSlider.setMinorTickSpacing(5); catSlider.setSnapToTicks(true); colSlider = new JSlider(-80, 20, iColumnMargin); colSlider.setPaintLabels(true); colSlider.setPaintTicks(true); colSlider.setMajorTickSpacing(20); colSlider.setMinorTickSpacing(5); catSlider.setSnapToTicks(true); colFirst = new JLabel(" "); colFirst.setOpaque(true); colFirst.setBackground(cFirst); colSecond = new JLabel(" "); colSecond.setOpaque(true); colSecond.setBackground(cSecond); JButton selFirst = new JButton("..."); selFirst.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Color ret = JColorChooser.showDialog(ChartXYZ2.this, "Boja prvog stupca", cFirst); if (ret != null) colFirst.setBackground(ret); } }); JButton selSecond = new JButton("..."); selSecond.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Color ret = JColorChooser.showDialog(ChartXYZ2.this, "Boja drugog stupca", cSecond); if (ret != null) colSecond.setBackground(ret); } }); optionsPanel = new JPanel(new GridBagLayout()); optionsPanel.setBorder(BorderFactory.createEmptyBorder(15, 20, 15, 20)); GridBagConstraints c = new GridBagConstraints(); c.weightx = 0.1; c.weighty = 1; c.gridx = 0; c.gridy = 0; c.anchor = c.LINE_START; c.insets = new Insets(2, 10, 2, 2); optionsPanel.add(new JLabel("Razmak izmeu grupa"), c); c.gridy = 1; optionsPanel.add(new JLabel("Razmak izmeu stupaca "), c); c.gridy = 2; optionsPanel.add(new JLabel("Boja prvog stupca"), c); c.gridy = 3; optionsPanel.add(new JLabel("Boja drugog stupca"), c); c.weightx = 0.9; c.gridwidth = 2; c.gridx = 1; c.gridy = 0; c.fill = c.HORIZONTAL; optionsPanel.add(catSlider, c); c.gridy = 1; optionsPanel.add(colSlider, c); c.weightx = 0; c.gridwidth = 1; c.gridy = 2; c.fill = c.NONE; optionsPanel.add(colFirst, c); c.gridy = 3; optionsPanel.add(colSecond, c); c.weightx = 0.9; c.gridx = 2; c.gridy = 2; optionsPanel.add(selFirst, c); c.gridy = 3; optionsPanel.add(selSecond, c); } else { catSlider.setValue(iCategoryMargin); colSlider.setValue(iColumnMargin); colFirst.setBackground(cFirst); colSecond.setBackground(cSecond); } raInputDialog dlg = new raInputDialog(); if (dlg.show(this, optionsPanel, "Opcije prikaza")) { iCategoryMargin = catSlider.getValue(); iColumnMargin = colSlider.getValue(); cFirst = colFirst.getBackground(); cSecond = colSecond.getBackground(); selectionChanged(); } }
From source file:ch.epfl.leb.sass.ijplugin.SimulatorStatusFrame.java
/** * Creates a new status frame./*from ww w. j a v a2s .c om*/ * * @param groundTruthYLabel The y-axis label for the ground truth signal. * @param analyzerYLabel The units output by the analyzer. * @param setpointYLabel The units of the controller setpoint. * @param outputYLabel The units output by the controller. */ public SimulatorStatusFrame(String groundTruthYLabel, String analyzerYLabel, String setpointYLabel, String outputYLabel) { String seriesLabel = ""; String yLabel = ""; CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(new NumberAxis("Simulation Outputs")); Font yLabelFont = new Font("Dialog", Font.PLAIN, 10); datasets = new XYSeriesCollection[4]; for (int i = 0; i < SUBPLOT_COUNT; i++) { switch (i) { case 0: seriesLabel = "True density"; yLabel = groundTruthYLabel; break; case 1: seriesLabel = "Analyzer output"; yLabel = analyzerYLabel; break; case 2: seriesLabel = "Setpoint"; yLabel = setpointYLabel; break; case 3: seriesLabel = "Controller output"; yLabel = outputYLabel; break; } XYSeries timeseries = new XYSeries(seriesLabel); datasets[i] = new XYSeriesCollection(timeseries); NumberAxis numberaxis = new NumberAxis(yLabel); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setNumberFormatOverride(new DecimalFormat("###0.00")); XYPlot xyplot = new XYPlot(datasets[i], null, numberaxis, new StandardXYItemRenderer()); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.getRangeAxis().setLabelFont(yLabelFont); combineddomainxyplot.add(xyplot); } JFreeChart jfreechart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, combineddomainxyplot, true); jfreechart.setBorderPaint(Color.black); jfreechart.setBorderVisible(true); jfreechart.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); ValueAxis valueaxis = combineddomainxyplot.getDomainAxis(); valueaxis.setAutoRange(true); // Number of frames to display valueaxis.setFixedAutoRange(2000D); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setPreferredSize(new Dimension(800, 500)); chartpanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chartpanel.setVisible(true); JPanel jPanel = new JPanel(); jPanel.setLayout(new BorderLayout()); jPanel.add(chartpanel, BorderLayout.NORTH); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); add(jPanel); pack(); setVisible(true); }
From source file:be.ac.ua.comp.scarletnebula.gui.addserverwizard.ChooseImagePage.java
private final JPanel getAllImagesPanel(final CloudProvider provider) { final JPanel panel = new JPanel(new BorderLayout()); final TableRowSorter<MachineImageTableModel> sorter = new TableRowSorter<MachineImageTableModel>( allImagesModel);/*w ww. java 2 s .co m*/ allImagesTable.setRowSorter(sorter); allImagesTable.setFillsViewportHeight(true); allImagesTable.addMouseListener(new SmartImageModelContextMenuMouseListener(provider, allImagesModel, allImagesTable, favoriteImagesPanel.getModel())); final JPanel aboveTable = new JPanel(new BorderLayout()); final JPanel searchPanel = getSearchPanel(sorter); aboveTable.add(searchPanel, BorderLayout.NORTH); aboveTable.add(throbberPanel, BorderLayout.SOUTH); panel.add(aboveTable, BorderLayout.NORTH); final JScrollPane tableScrollPane = new JScrollPane(allImagesTable); tableScrollPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 20, 10, 20), BorderFactory.createBevelBorder(BevelBorder.LOWERED))); panel.add(tableScrollPane, BorderLayout.CENTER); return panel; }
From source file:events.TableListSelectionDemo.java
public TableListSelectionDemo() { super(new BorderLayout()); String[] columnNames = { "French", "Spanish", "Italian" }; String[][] tableData = { { "un", "uno", "uno" }, { "deux", "dos", "due" }, { "trois", "tres", "tre" }, { "quatre", "cuatro", "quattro" }, { "cinq", "cinco", "cinque" }, { "six", "seis", "sei" }, { "sept", "siete", "sette" } }; table = new JTable(tableData, columnNames); listSelectionModel = table.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler()); table.setSelectionModel(listSelectionModel); JScrollPane tablePane = new JScrollPane(table); //Build control area (use default FlowLayout). JPanel controlPane = new JPanel(); String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" }; final JComboBox comboBox = new JComboBox(modes); comboBox.setSelectedIndex(2);/* ww w .jav a 2 s . c o m*/ comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newMode = (String) comboBox.getSelectedItem(); if (newMode.equals("SINGLE_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } else { listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } output.append("----------" + "Mode: " + newMode + "----------" + newline); } }); controlPane.add(new JLabel("Selection mode:")); controlPane.add(comboBox); //Build output area. output = new JTextArea(1, 10); output.setEditable(false); JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); //Do the layout. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); add(splitPane, BorderLayout.CENTER); JPanel topHalf = new JPanel(); topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS)); JPanel listContainer = new JPanel(new GridLayout(1, 1)); JPanel tableContainer = new JPanel(new GridLayout(1, 1)); tableContainer.setBorder(BorderFactory.createTitledBorder("Table")); tableContainer.add(tablePane); tablePane.setPreferredSize(new Dimension(420, 130)); topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); topHalf.add(listContainer); topHalf.add(tableContainer); topHalf.setMinimumSize(new Dimension(250, 50)); topHalf.setPreferredSize(new Dimension(200, 110)); splitPane.add(topHalf); JPanel bottomHalf = new JPanel(new BorderLayout()); bottomHalf.add(controlPane, BorderLayout.PAGE_START); bottomHalf.add(outputPane, BorderLayout.CENTER); //XXX: next line needed if bottomHalf is a scroll pane: //bottomHalf.setMinimumSize(new Dimension(400, 50)); bottomHalf.setPreferredSize(new Dimension(450, 110)); splitPane.add(bottomHalf); }
From source file:de.rub.syssec.saaf.gui.frame.CfgSelectorFrame.java
/** * A frame to generate and open Control Flow Graphs. CFGs are created using mxGraph * and are saved as PNGs.//w ww. jav a2 s . c o m * * @param smaliClass the smali class to select methods from */ public CfgSelectorFrame(ClassInterface smaliClass) { super(smaliClass.getFullClassName(true), true, true, true, true); this.smaliClass = smaliClass; listModel = new MethodTableModel(smaliClass); list.setModel(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { int viewRow = list.getSelectedRow(); if (viewRow <= 0) { showButton.setEnabled(false); } else { showButton.setEnabled(true); } } }); JScrollPane listScrollPane = new JScrollPane(list); ActionListener al = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(SHOW_OPERATION)) { generateAndShowCfg(true); } else if (e.getActionCommand().equals(GENERATE_OPERATION)) { generateAndShowCfg(false); } } }; generateButton = new JButton(GENERATE_OPERATION); generateButton.setActionCommand(GENERATE_OPERATION); generateButton.addActionListener(al); showButton = new JButton(SHOW_OPERATION); showButton.setEnabled(false); showButton.addActionListener(al); saveCfgCheckBox = new JCheckBox("Save a copy"); saveCfgCheckBox.setToolTipText("Save a copy in the configured CFG folder upon generation."); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.add(generateButton); buttonPane.add(saveCfgCheckBox); buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel filler = new JPanel(); filler.setPreferredSize(new Dimension(10, 10)); buttonPane.add(filler); buttonPane.add(showButton); add(listScrollPane, BorderLayout.CENTER); add(buttonPane, BorderLayout.PAGE_END); this.setPreferredSize(new Dimension(500, 250)); this.pack(); this.setVisible(true); }
From source file:com.intel.stl.ui.common.view.DistributionPiePanel.java
public void setLabels(String[] itemNames, ImageIcon[] icons, int labelColumns) { if (icons.length != itemNames.length) { throw new IllegalArgumentException( "Inconsistent number of items. " + " itemNames=" + itemNames.length + " icons=" + icons.length); }// w w w. jav a2s .c o m labels = new JLabel[icons.length]; for (int i = 0; i < icons.length; i++) { labels[i] = new JLabel(itemNames[i], icons[i], JLabel.LEFT); } int rows = 1; if (labelColumns <= 0) { labelPanel.setLayout(new FlowLayout()); for (JLabel label : labels) { labelPanel.add(label); } } else { BoxLayout layout = new BoxLayout(labelPanel, BoxLayout.X_AXIS); labelPanel.setLayout(layout); JPanel[] columns = new JPanel[labelColumns]; for (int i = 0; i < columns.length; i++) { labelPanel.add(Box.createHorizontalGlue()); columns[i] = new JPanel(); columns[i].setOpaque(false); columns[i].setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 3)); BoxLayout cLayout = new BoxLayout(columns[i], BoxLayout.Y_AXIS); columns[i].setLayout(cLayout); labelPanel.add(columns[i]); } labelPanel.add(Box.createHorizontalGlue()); rows = (int) Math.ceil((double) labels.length / labelColumns); int index = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < labelColumns; j++) { columns[i].add(index < labels.length ? labels[index] : Box.createGlue()); index += 1; } } } }