List of usage examples for java.awt Insets Insets
public Insets(int top, int left, int bottom, int right)
From source file:concurrency.Flipper.java
public Flipper() { super("Flipper"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Make text boxes getContentPane().setLayout(new GridBagLayout()); constraints = new GridBagConstraints(); constraints.insets = new Insets(3, 10, 3, 10); headsText = makeText();//from www . jav a 2 s . c om totalText = makeText(); devText = makeText(); //Make buttons startButton = makeButton("Start"); stopButton = makeButton("Stop"); stopButton.setEnabled(false); //Display the window. pack(); setVisible(true); }
From source file:geneon.intellij.plugin.jenkins.ui.EditServerDialog.java
@Nullable @Override//from ww w . j a va 2s.c o m protected JComponent createCenterPanel() { nameTextField.setMinimumSize(new Dimension(300, 10)); urlTextField.setMinimumSize(new Dimension(300, 10)); JButton testButton = new JButton("Test"); testButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { testSettings(); } }); JPanel panel = new JPanel(new GridBagLayout()); JLabel nameLabel = new JLabel("Server name:"); panel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0)); panel.add(nameTextField, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0)); JLabel urlLabel = new JLabel("URL:"); panel.add(urlLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0)); panel.add(urlTextField, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0)); panel.add(testButton, new GridBagConstraints(0, 2, 2, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 0, 0)); return panel; }
From source file:coolmap.canvas.datarenderer.renderer.impl.NumberToBoxPlot.java
public NumberToBoxPlot() { setName("Number to BoxPlot"); setDescription("Use bar height to represent numeric values"); //initialize UI configUI.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0;//from ww w . j av a2s . c o m c.gridy = 0; c.ipadx = 5; c.ipady = 5; c.insets = new Insets(5, 5, 5, 5); c.gridwidth = 1; c.gridx = 0; c.gridy++; c.gridwidth = 1; // JButton button = new JButton("Apply"); // configUI.add(button, c); // button.setToolTipText("Apply preset data ranges"); // button.addActionListener(new ActionListener() { // // @Override // public void actionPerformed(ActionEvent e) { // try { // MinMaxItem item = (MinMaxItem) (presetRangeComboBox.getSelectedItem()); // minValueField.setText(item.getMinMax().lowerEndpoint().toString()); // maxValueField.setText(item.getMinMax().upperEndpoint().toString()); // } catch (Exception ex) { // minValueField.setText("-1"); // maxValueField.setText("1"); // } // // updateRenderer(); // } // }); configUI.add(new JLabel("Preset range:"), c); c.gridx = 1; c.gridwidth = 1; presetRangeComboBox = new JComboBox(); configUI.add(presetRangeComboBox, c); presetRangeComboBox.addItem(new DataMinMaxItem()); presetRangeComboBox.addItem(new DefinedMinMaxItem(-1, 1)); presetRangeComboBox.addItem(new DefinedMinMaxItem(0, 1)); presetRangeComboBox.addItem(new DefinedMinMaxItem(-1, 0)); presetRangeComboBox.addItem(new DefinedMinMaxItem(0, 100)); presetRangeComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { try { MinMaxItem item = (MinMaxItem) (presetRangeComboBox.getSelectedItem()); minValueField.setText(item.getMinMax().lowerEndpoint().toString()); maxValueField.setText(item.getMinMax().upperEndpoint().toString()); } catch (Exception ex) { minValueField.setText("-1"); maxValueField.setText("1"); } } }); //////////////////////////////////////////////////////////////////////////////// // c.weightx = 0.2; c.gridx = 0; c.gridy++; c.gridwidth = 1; configUI.add(new JLabel("Min value: "), c); c.gridx = 1; // c.weightx = 0.3; configUI.add(minValueField, c); c.gridx = 0; c.gridy++; c.gridwidth = 1; configUI.add(new JLabel("Max value: "), c); c.gridx = 1; configUI.add(maxValueField, c); c.gridx = 0; c.gridy++; c.gridwidth = 1; configUI.add(new JLabel("Disect boundary: "), c); c.gridx = 1; configUI.add(disectField, c); disectField.setText("0"); c.gridx = 0; c.gridy++; c.gridwidth = 3; JButton button = new JButton("Update", UI.getImageIcon("refresh")); configUI.add(button, c); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //hit button, redraw! updateRenderer(); } }); }
From source file:components.ProgressMonitorDemo.java
public ProgressMonitorDemo() { super(new BorderLayout()); //Create the demo's UI. startButton = new JButton("Start"); startButton.setActionCommand("start"); startButton.addActionListener(this); taskOutput = new JTextArea(5, 20); taskOutput.setMargin(new Insets(5, 5, 5, 5)); taskOutput.setEditable(false);/* ww w .ja v a2 s . c o m*/ add(startButton, BorderLayout.PAGE_START); add(new JScrollPane(taskOutput), BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:com.game.ui.views.CharachterEditorPanel.java
public void doGui() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JLabel noteLbl = new JLabel("Pls select a value to choose an enemy or you can create a new " + "Enemy entity below. Once selected an Enemy character, its' details will be available below"); noteLbl.setAlignmentX(0);/*from w w w . j a v a 2 s . com*/ // noteLbl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(noteLbl); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (GameCharacter character : GameBean.enemyDetails) { System.out.println(character.getName()); model.addElement(character.getName()); } comboBox = new JComboBox(model); comboBox.setSelectedIndex(-1); comboBox.setMaximumSize(new Dimension(100, 30)); comboBox.setAlignmentX(0); comboBox.setActionCommand("dropDown"); comboBox.addActionListener(this); add(Box.createVerticalStrut(10)); add(comboBox); add(Box.createVerticalStrut(10)); JPanel panel1 = new JPanel(); panel1.setAlignmentX(0); panel1.setBorder(LineBorder.createGrayLineBorder()); panel1.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(5, 5, 5, 5); c.weightx = 1; c.weighty = 1; c.gridwidth = 2; JLabel enemyDtlLbl = new JLabel("Enemy Character Details : "); enemyDtlLbl.setFont(new Font("Times New Roman", Font.BOLD, 15)); panel1.add(enemyDtlLbl, c); c.gridwidth = 1; c.gridy = 1; JLabel nameLbl = new JLabel("Name : "); panel1.add(nameLbl, c); c.gridx = 1; JTextField name = new JTextField(""); name.setColumns(20); panel1.add(name, c); c.gridx = 0; c.gridy = 2; JLabel imageLbl = new JLabel("Image Path : "); panel1.add(imageLbl, c); c.gridx = 1; JTextField image = new JTextField(""); image.setColumns(20); panel1.add(image, c); c.gridx = 0; c.gridy = 3; JLabel healthLbl = new JLabel("Health Pts : "); panel1.add(healthLbl, c); c.gridx = 1; JTextField health = new JTextField(""); health.setColumns(20); panel1.add(health, c); c.gridx = 0; c.gridy = 4; JLabel attackPtsLbl = new JLabel("Attack Points : "); panel1.add(attackPtsLbl, c); c.gridx = 1; JTextField attackPts = new JTextField(""); attackPts.setColumns(20); panel1.add(attackPts, c); c.gridx = 0; c.gridy = 5; JLabel armoursPtsLbl = new JLabel("Armour Points : "); panel1.add(armoursPtsLbl, c); c.gridx = 1; JTextField armourPts = new JTextField(""); armourPts.setColumns(20); panel1.add(armourPts, c); c.gridx = 0; c.gridy = 6; JLabel attackRngeLbl = new JLabel("Attack Range : "); panel1.add(attackRngeLbl, c); c.gridx = 1; JTextField attackRnge = new JTextField(""); attackRnge.setColumns(20); panel1.add(attackRnge, c); c.gridx = 0; c.gridy = 7; JLabel movementLbl = new JLabel("Movement : "); panel1.add(movementLbl, c); c.gridx = 1; JTextField movement = new JTextField(""); movement.setColumns(20); panel1.add(movement, c); c.gridx = 0; c.gridy = 8; c.gridwidth = 2; JButton submit = new JButton("Save"); submit.addActionListener(this); submit.setActionCommand("button"); panel1.add(submit, c); add(panel1); c.gridx = 0; c.gridy = 9; JLabel validationMess = new JLabel("Pls enter all the fields or pls choose a character from the drop down"); validationMess.setForeground(Color.red); validationMess.setVisible(false); add(validationMess, c); add(Box.createVerticalGlue()); }
From source file:be.ac.ua.comp.scarletnebula.gui.AllGraphsPanel.java
/** * Places all components (graphs) in the panel. *//*from w w w. ja v a2 s . c o m*/ private void placeComponents() { final GridBagConstraints constraints = new GridBagConstraints(); int numberOfComponentsPlaced = 0; int currXPos = 0; final int graphHeight = 150; final int graphWidth = 100; final Collection<String> datastreams = statisticsManager.getAvailableDatastreams(); for (final String streamname : datastreams) { LOG.info("drawing stream"); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 0.5; constraints.gridx = currXPos; constraints.gridy = numberOfComponentsPlaced / 2; constraints.insets = new Insets(10, 0, 0, 0); final DecoratedGraph graph = new DecoratedGraph((long) 10 * 60 * 1000, statisticsManager.getDatastream(streamname)); graph.registerRelativeDatastream(server, streamname, Color.GREEN); graph.addServerToRefresh(server); final ChartPanel chartPanel = graph.getChartPanel(); chartPanel.setPreferredSize(new Dimension(graphWidth, graphHeight)); add(chartPanel, constraints); if (currXPos == 0) { currXPos = 1; } else { currXPos = 0; } numberOfComponentsPlaced++; } }
From source file:de.costache.calendar.JCalendar.java
/** * Initializes the GUI/*from w w w.j ava 2 s . c o m*/ */ private void initGui() { this.setBackground(Color.white); headerPane = new HeaderPanel(this); contentPane = new ContentPanel(this); headerPane.getIntervalLabel().setText(contentPane.getStrategy().getDisplayInterval()); this.setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.fill = GridBagConstraints.BOTH; add(headerPane, c); c.gridx = 0; c.gridy = 1; c.weighty = 0.9; c.insets = new Insets(10, 10, 10, 10); add(contentPane, c); }
From source file:dk.dma.epd.shore.gui.notification.StrategicRouteNotificationDetailPanel.java
/** * {@inheritDoc}/* w w w . j a v a 2 s. c o m*/ */ @Override protected JPanel createInfoPanel() { // Initialize member variables here, since this method // is called by super's constructor mmsiTxt = new JLabel(" "); nameTxt = new JLabel(" "); callSignTxt = new JLabel(" "); destinationTxt = new JLabel(" "); sogTxt = new JLabel(" "); typeTxt = new JLabel(" "); lengthTxt = new JLabel(" "); widthTxt = new JLabel(" "); draughtTxt = new JLabel(" "); cogTxt = new JLabel(" "); String[] infoTitles = { "MMSI:", "Name:", "Call Sign:", "Destination:", "SOG:", "Type:", "Lenght:", "Width:", "Draught:", "COG:" }; infoLabels = new JLabel[] { mmsiTxt, nameTxt, callSignTxt, destinationTxt, sogTxt, typeTxt, lengthTxt, widthTxt, draughtTxt, cogTxt }; int[] infoCols = { 5, 5 }; JPanel infoPanel = new JPanel(new GridBagLayout()); Insets insets2 = new Insets(2, 5, 2, 5); infoPanel.setBorder(BorderFactory.createTitledBorder("Ship Info")); for (int col = 0, index = 0; col < infoCols.length; col++) { for (int row = 0; row < infoCols[col]; row++, index++) { infoPanel.add(bold(new JLabel(infoTitles[index])), new GridBagConstraints(col * 2, row, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0)); infoPanel.add(minSize(infoLabels[index], 40), new GridBagConstraints(col * 2 + 1, row, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets2, 0, 0)); } } return infoPanel; }
From source file:de.tor.tribes.ui.components.DatePicker.java
private void init() { //build Header for (int i = 0; i < 7; i++) { JLabel head = new JLabel(dayNames[i]); head.setBackground(GRAY);/* w ww . ja v a2 s . c om*/ head.setOpaque(true); head.setPreferredSize(new Dimension(20, 20)); head.setMinimumSize(new Dimension(20, 20)); head.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.PAGE_START; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = i; gbc.gridy = 0; gbc.insets = new Insets(2, 2, 6, 2); gbc.ipadx = 0; gbc.ipady = 0; gbc.weightx = 1.0; gbc.weighty = 0.0; jPanelDaySelection.add(head, gbc); } daysInMonth = new CrossedLabel[WEEKS_TO_SHOW][7]; datesInMonth = new Date[WEEKS_TO_SHOW][7]; for (int i = 0; i < WEEKS_TO_SHOW; i++) { for (int j = 0; j < 7; j++) { daysInMonth[i][j] = new CrossedLabel(); daysInMonth[i][j].setPreferredSize(new Dimension(20, 20)); daysInMonth[i][j].setMinimumSize(new Dimension(20, 20)); daysInMonth[i][j].setHorizontalAlignment(javax.swing.SwingConstants.CENTER); daysInMonth[i][j].addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseevent) { dayClicked(mouseevent); } }); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.PAGE_START; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = j; gbc.gridy = i + 1; gbc.insets = new Insets(2, 2, 2, 2); gbc.ipadx = 0; gbc.ipady = 0; gbc.weightx = 1.0; gbc.weighty = 0.0; jPanelDaySelection.add(daysInMonth[i][j], gbc); } } buildCalendar(); }
From source file:com.haulmont.cuba.desktop.gui.components.CubaFileUploadWrapper.java
public CubaFileUploadWrapper(Button uploadButton) { setLayout(new BorderLayout()); ComponentsFactory componentsFactory = AppBeans.get(ComponentsFactory.NAME); container = (DesktopHBox) componentsFactory.createComponent(DesktopHBox.NAME); container.setSpacing(true);/* w w w. j av a 2s . co m*/ add(container.unwrap(JPanel.class)); fileNameButton = (LinkButton) componentsFactory.createComponent(LinkButton.NAME); fileNameButton.setVisible(false); fileNameButton.setAction(new AbstractAction("") { @Override public void actionPerform(Component component) { if (fileNameButtonClickListener != null) { fileNameButtonClickListener.run(); } } }); setFileName(null); container.add(fileNameButton); fileNameButton.setAlignment(Component.Alignment.MIDDLE_LEFT); this.uploadButton = uploadButton; JButton jUploadButton = uploadButton.unwrap(JButton.class); jUploadButton.setMargin(new Insets(0, 0, 0, 0)); container.add(uploadButton); uploadButton.setAlignment(Component.Alignment.MIDDLE_RIGHT); clearButton = (Button) componentsFactory.createComponent(Button.NAME); clearButton.setAction(new AbstractAction("") { @Override public void actionPerform(Component component) { if (clearButtonListener != null) { clearButtonListener.run(); } } }); clearButton.setCaption(messages.getMainMessage("FileUploadField.clearButtonCaption")); clearButton.setVisible(false); JButton jClearButton = clearButton.unwrap(JButton.class); jClearButton.setMargin(new Insets(0, 0, 0, 0)); container.add(clearButton); clearButton.setAlignment(Component.Alignment.MIDDLE_RIGHT); setShowFileName(false); }