public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Object[] values = (Object[]) list.getModel().getElementAt(index); String icoState = (String) (values[0]); setIcon(null); if (icoState.equals("bad")) { // Error setIcon(errIco); setBackground(list.getSelectionForeground()); // RED setForeground(Color.BLACK); setBorder(BorderFactory.createLineBorder(Color.BLUE, 1)); } else if (icoState.equals("good")) { // Ok setIcon(nrmIco); setBackground(list.getSelectionBackground()); // GREEN setForeground(Color.BLACK); setBorder(BorderFactory.createLineBorder(Color.BLUE, 1)); } else if (icoState.equals("goodcont")) { // Ok setIcon(imdIco); setBackground(list.getSelectionBackground()); // GREEN setForeground(Color.BLACK); setBorder(BorderFactory.createLineBorder(list.getSelectionBackground(), 1)); } else { setIcon(ibdIco); // Errorcont setBackground(list.getSelectionForeground()); // RED setForeground(Color.BLACK); setBorder(BorderFactory.createLineBorder(list.getSelectionForeground(), 1)); } setText((String) (values[1])); setFont(list.getFont()); return this; }
/** {@inheritDoc} */ @Override public Component getListCellRendererComponent( JList list, final Object value, final int index, boolean isSelected, final boolean cellHasFocus) { Component label = getObjectComponent(list, value, index, isSelected, cellHasFocus); if (label instanceof JComponent) ((JComponent) label).setOpaque(false); panel.removeAll(); panel.add(label); panel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); panel.restoreBackground(); if (cellHasFocus) if (panel.isBackgroundRestored()) panel.setBackground(UIUtils.setAlpha(list.getSelectionBackground(), 100)); else panel.setBorder(BorderFactory.createLineBorder(list.getSelectionBackground())); if (isSelected) if (panel.isBackgroundRestored()) panel.setBackground(UIUtils.setAlpha(list.getSelectionBackground(), 200)); else panel.setBorder(BorderFactory.createLineBorder(list.getSelectionBackground())); if (index == hoveredIndex) panel.mouseEntered(null); return panel; }
public void buildPopulationBox() { rebuilding = true; populationBox.removeAll(); peopleList = new ArrayList<Object>(); famList = new ArrayList<Family>(); peopleList.addAll(ctxt.individualCensus); String plur = (peopleList.size() == 1 ? "" : "s"); populationBox.setLayout(new BoxLayout(populationBox, BoxLayout.PAGE_AXIS)); populationBox.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "Current Population")); populationBox.setAlignmentX(0.5f); populationBox.add(Box.createRigidArea(new Dimension(8, 0))); indivLabel = new JLabel("Contains " + peopleList.size() + " Individual" + plur); indivLabel.setAlignmentX(0.5f); populationBox.add(indivLabel); if (peopleList.size() > 0) { JPanel indivBtnBox = new JPanel(); indivBtnBox.setLayout(new BoxLayout(indivBtnBox, BoxLayout.LINE_AXIS)); Dimension sizer2 = new Dimension(350, 50); String[] indMenu = genIndMenu(peopleList); indPick = new JComboBox(indMenu); indPick.addActionListener(listener); indPick.setActionCommand("view/edit person"); indPick.setMinimumSize(sizer2); indPick.setMaximumSize(sizer2); indPick.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "View/Edit Person")); indivBtnBox.add(indPick); populationBox.add(indivBtnBox); } // end of if-any-people-exist famList.addAll(ctxt.familyCensus); // end of filtering deleted records plur = (famList.size() == 1 ? "y" : "ies"); famLabel = new JLabel("Contains " + famList.size() + " Famil" + plur); famLabel.setAlignmentX(0.5f); populationBox.add(Box.createRigidArea(new Dimension(0, 4))); populationBox.add(famLabel); if (famList.size() > 0) { JPanel famBtnBox = new JPanel(); famBtnBox.setLayout(new BoxLayout(famBtnBox, BoxLayout.LINE_AXIS)); Dimension sizer2 = new Dimension(350, 50); String[] famMenu = genFamMenu(famList); famPick = new JComboBox(famMenu); famPick.addActionListener(listener); famPick.setActionCommand("view/edit family"); famPick.setMinimumSize(sizer2); famPick.setMaximumSize(sizer2); famPick.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "View/Edit Family")); famBtnBox.add(famPick); populationBox.add(famBtnBox); } // end of if-any-families-exist rebuilding = false; } // end of method buildPopulationBox
void updateColor() { if (gNode.isInitial()) { setBackground(Color.yellow); setBorder(BorderFactory.createLineBorder(Color.yellow, 1)); // two pixels wide } else { setBackground(Color.white); setBorder(BorderFactory.createLineBorder(Color.black, 1)); } }
/** Return the cell's border. */ protected Border border( JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) { if (hasFocus) { return UIManager.getBorder("Table.focusCellHighlightBorder"); } if (selected) { return BorderFactory.createLineBorder(table.getSelectionBackground(), 1); } return BorderFactory.createLineBorder(table.getBackground(), 1); }
public void updateKeyboardUI() { if (Skin.VIETNAMESE_KEY.isEnabled()) { chkVietnamese.setText(" V "); chkVietnamese.setBackground(Color.yellow); chkVietnamese.setBorder(BorderFactory.createLineBorder(Color.red, 1)); } else { chkVietnamese.setText(" E "); chkVietnamese.setBackground(Color.cyan); chkVietnamese.setBorder(BorderFactory.createLineBorder(Color.blue, 1)); } }
public void drawItems() { itemList.removeAll(); OrderedItem orders[] = commande.getOrders(); for (int i = 0; i < orders.length; i++) { GridBagConstraints constraintLeft = new GridBagConstraints(), constraintRight = new GridBagConstraints(); constraintLeft.gridx = 0; constraintLeft.gridy = GridBagConstraints.RELATIVE; constraintLeft.fill = GridBagConstraints.HORIZONTAL; constraintRight.gridx = 1; constraintRight.gridy = GridBagConstraints.RELATIVE; constraintRight.fill = GridBagConstraints.HORIZONTAL; String itemText = orders[i].getItem().getNom(); if (itemText.length() > 15) { itemText = itemText.substring(0, 12) + "..."; } JLabel item = new JLabel(itemText); JPanel itemTextHolder = new JPanel(); itemTextHolder.setBorder(BorderFactory.createLineBorder(Color.BLUE)); itemTextHolder.setBackground(Color.WHITE); itemTextHolder.add(item); itemList.add(itemTextHolder, constraintLeft); Color bg = Color.WHITE; String statusIcon = ""; JLabel itemStatus = new JLabel(); JPanel statusHolder = new JPanel(); switch (orders[i].getStatus()) { case 0: bg = Color.RED; statusIcon = "\u2718"; break; case 1: bg = Color.YELLOW; statusIcon = "\u2718"; break; case 2: bg = Color.GREEN; statusIcon = "\u2718"; break; case 3: bg = Color.GRAY; statusIcon = "\u2713"; break; } itemStatus.setText(statusIcon); statusHolder.setBackground(bg); statusHolder.setBorder(BorderFactory.createLineBorder(Color.BLUE)); statusHolder.add(itemStatus); itemList.add(statusHolder, constraintRight); } validate(); repaint(); }
public AccountInfoPanel() { setLayout(new MigLayout("gap 0, fill")); // setBorder(BorderFactory.createLineBorder(Color.BLACK)); number2.setBorder(BorderFactory.createLineBorder(Color.BLACK)); number.setBorder(BorderFactory.createLineBorder(Color.BLACK)); balance2.setBorder(BorderFactory.createLineBorder(Color.BLACK)); balance.setBorder(BorderFactory.createLineBorder(Color.BLACK)); add(number2, "grow, align center"); add(number, "wrap, grow, align center"); add(balance2, "grow, align center"); add(balance, "grow, align center"); }
public SettingsPanel() { setLayout(new MigLayout("fill")); setBorder(BorderFactory.createLineBorder(Color.BLACK)); add(backBtn, "c, grow"); add(transferBtn, "c, grow"); add(historyBtn, "c, grow"); }
public void redrawCommande() { itemPanel.removeAll(); OrderedItem orders[] = commande.getOrders(); GridBagConstraints c = new GridBagConstraints(); c.gridy = GridBagConstraints.RELATIVE; c.fill = GridBagConstraints.BOTH; for (int i = 0; i < orders.length; i++) { c.gridx = 0; JPanel itemLabelHolder = new JPanel(); itemLabelHolder.add(new JLabel(orders[i].getItem().getNom())); itemLabelHolder.setBackground(Color.WHITE); itemLabelHolder.setBorder(BorderFactory.createLineBorder(Color.BLUE)); itemPanel.add(itemLabelHolder, c); c.gridx = 1; itemPanel.add(new OrderedItemPanel(orders[i]), c); c.gridx = 2; JButton killButton = new JButton("\u2716"); killButton.setBackground(Color.RED); killButton.setForeground(Color.WHITE); killButton.addActionListener(getHandler()); killButton.setActionCommand("CDelete" + i); JPanel buttonHolder = new JPanel(); buttonHolder.add(killButton); itemPanel.add(buttonHolder, c); } validate(); repaint(); }
public class MyListCellRenderer implements ListCellRenderer { private JLabel jlblCell = new JLabel(" ", JLabel.LEFT); private Border lineBorder = BorderFactory.createLineBorder(Color.black, 1); private Border emptyBorder = BorderFactory.createEmptyBorder(2, 2, 2, 2); /** Implement this method in ListCellRenderer */ public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Object[] pair = (Object[]) value; // Cast value into an array jlblCell.setOpaque(true); jlblCell.setIcon((ImageIcon) pair[0]); jlblCell.setText(pair[1].toString()); if (isSelected) { jlblCell.setForeground(list.getSelectionForeground()); jlblCell.setBackground(list.getSelectionBackground()); } else { jlblCell.setForeground(list.getForeground()); jlblCell.setBackground(list.getBackground()); } jlblCell.setBorder(cellHasFocus ? lineBorder : emptyBorder); return jlblCell; } }
public void mousePressed(MouseEvent e) { if (e.getButton() == e.BUTTON3) { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); int index = list.locationToIndex(e.getPoint()); GetImageFile gif = new GetImageFile(files[index]); JTextArea area = new JTextArea( "File: " + gif.getImageString() + "\n" + "Score: " + nf.format(scores[index]) + "\n" + "Pairs: " + nrpairs[index]); area.setEditable(false); area.setBorder(BorderFactory.createLineBorder(Color.black)); area.setFont(new Font("times", Font.PLAIN, 12)); PopupFactory factory = PopupFactory.getSharedInstance(); popup = factory.getPopup( null, area, (int) e.getComponent().getLocationOnScreen().getX() + e.getX() + 25, (int) e.getComponent().getLocationOnScreen().getY() + e.getY()); popup.show(); } }
public GUILogi5Board(Game game) { this.game = game; dim = game.getDimensions()[0]; setLayout(new GridLayout(dim, dim)); spaces = new JButton[dim][dim]; for (int i = 0; i < spaces.length; i++) { for (int j = 0; j < spaces[i].length; j++) { Space otherSpace = game.getSpaceAt(i, j); GUILogi5Space spacey = new GUILogi5Space(i, j, spaceSize); int[] loc = spacey.getDims(); spacey.setSpace(game.getSpaceAt(loc[0], loc[1])); spaces[i][j] = spacey; add(spacey); } } setBorder(BorderFactory.createLineBorder(Color.black)); setPreferredSize(new Dimension(spaceSize * spaces.length, spaceSize * spaces[0].length)); setMaximumSize(new Dimension(spaceSize * spaces.length, spaceSize * spaces[0].length)); int num = 255; Color[] colors = new Color[6]; for (int i = 0; i < colors.length; i++) { colors[i] = new Color(num, num, num, 220); num -= 30; } possibleColors = colors; }
/** * Creates the panel that appears when there are no pages * * @return JPanel */ protected JPanel createFirstPanel() { firstButtonPanel = new JPanel(new GridBagLayout()); firstButtonPanel.setBorder(BorderFactory.createLineBorder(Color.black)); firstButtonPanel.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent _evt) { if (OSPRuntime.isPopupTrigger(_evt)) return; // SwingUtilities.isRightMouseButton(_evt)) return; if (!firstButtonPanel.isEnabled()) return; Object obj = JOptionPane.showInputDialog( getComponent(), res.getString("TabbedEditor.NewName"), res.getString("TabbedEditor.Rename"), JOptionPane.QUESTION_MESSAGE, null, null, getUniqueName(defaultString)); if (obj == null) return; String txt = obj.toString().trim(); if (txt.length() > 0) addPage(defaultType, txt, null, true); else addPage(defaultType, defaultString, null, true); } }); String label = res.getOptionalString("TabbedEditor.ClickHere." + defaultHeader); if (label == null) label = res.getString("TabbedEditor.ClickHere"); firstButton = new JLabel(label); firstButton.setFont(firstButton.getFont().deriveFont(TabbedEditor.BUTTON_FONT_SIZE)); firstButtonPanel.add(firstButton); JPanel firstPanel = new JPanel(new GridLayout(0, 1)); firstPanel.add(firstButtonPanel); return firstPanel; }
private void initComponents() { // Message - JLabel lblMessage = new JLabel( String.format( "An unexpected error has occurred: %s", e == null ? "Unexpected exception" : e.getMessage())); lblMessage.setIcon(icon); lblMessage.setPreferredSize(new Dimension(360, 40)); lblMessage.setBorder(BorderFactory.createLineBorder(Color.red)); // txtTrace - ExceptionTracePane txtTrace = new ExceptionTracePane(); txtTrace.setBackground(new Color(92, 0, 0)); txtTrace.setException(e); // srlTrace - JScrollPane JPanel traceWrapper = new JPanel(new BorderLayout()); traceWrapper.add(txtTrace, BorderLayout.CENTER); srlTrace = new JScrollPane(traceWrapper); srlTrace.setPreferredSize(new Dimension(360, 200)); srlTrace.setVisible(false); // btnDetails - JButton btnDetails = new JButton(new DetailsButtonAction()); btnDetails.setPreferredSize(new Dimension(100, 40)); // btnClose - JButton btnClose = new JButton(new CloseButtonAction()); btnClose.setDefaultCapable(true); btnClose.setPreferredSize(new Dimension(100, 40)); }
private void createCells() { // Sets the right size for the panel and sets up a GridBagLayout grid.setSize(rows * 18, (cols * 18) + 22); GridBagLayout gridBag = new GridBagLayout(); GridBagConstraints g = new GridBagConstraints(); grid.setLayout(gridBag); // Creates the arrays needed for the cells cells = new JLabel[rows][cols]; alive = new boolean[rows][cols]; mark = new boolean[rows][cols]; // Two for loops with which we can reach every cell for (int x = 0; x < rows; x++) { for (int y = 0; y < cols; y++) { // Makes a new JLabel for each cell, sets its icon to blank, and adds a border cells[x][y] = new JLabel(); cells[x][y].setIcon(white); cells[x][y].setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); // All cells start dead and not marked for change alive[x][y] = false; mark[x][y] = false; // Adds the mouselistener to each cell so it's state can be changed cells[x][y].addMouseListener(click); // Adds the cell to the correct position in the grid g.gridx = x; g.gridy = y; grid.add(cells[x][y], g); } } }
@NotNull private static JPanel createFilesViewPanel(@NotNull List<VirtualFile> files) { JPanel panel = new JPanel(new BorderLayout(0, 2)); panel.add(new JLabel("Files to add:"), BorderLayout.NORTH); final JBList fileList = new JBList(ArrayUtil.EMPTY_STRING_ARRAY); fileList.setBorder(BorderFactory.createLineBorder(Color.lightGray)); fileList.addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { fileList.clearSelection(); } }); fileList.setFocusable(false); fileList.setRequestFocusEnabled(false); fileList.setBackground(Gray._242); fileList.setCellRenderer( new ListCellRendererWrapper<VirtualFile>() { @Override public void customize( JList list, VirtualFile value, int index, boolean selected, boolean hasFocus) { setText(" " + value.getName()); } }); fileList.setListData(files.toArray()); panel.add(fileList, BorderLayout.CENTER); return panel; }
private JTextField createField(final String text) { final JTextField field = new JTextField(text) { public Dimension getPreferredSize() { Dimension preferredSize = super.getPreferredSize(); return new Dimension(preferredSize.width, myTextHeight); } }; field.setBackground(UIUtil.getPanelBackground()); field.setEditable(false); final Border lineBorder = BorderFactory.createLineBorder(UIUtil.getPanelBackground()); final DottedBorder dotted = new DottedBorder(UIUtil.getActiveTextColor()); field.setBorder(lineBorder); // field.setFocusable(false); field.setHorizontalAlignment(JTextField.RIGHT); field.setCaretPosition(0); field.addFocusListener( new FocusAdapter() { public void focusGained(FocusEvent e) { field.setBorder(dotted); } public void focusLost(FocusEvent e) { field.setBorder(lineBorder); } }); return field; }
public FloorPanel(int floorNumber, String title, int directions) { super(); setBackground(Color.GRAY); setLayout(new GridLayout(1, 2)); Border border = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLACK), title); setBorder(border); if (directions == Constants.DIRECTION_UP || directions == Constants.DIRECTION_BOTH) { // up button up = new JButton(UIUtils.UP_ARROW); add(up); up.addActionListener(this); } if (directions == Constants.DIRECTION_DOWN || directions == Constants.DIRECTION_BOTH) { // down button down = new JButton(UIUtils.DOWN_ARROW); add(down); down.addActionListener(this); } this.floorNumber = floorNumber; }
/** Creates new form display window */ public PZWindow( final PZManager manager, int screenX, int screenY, int width, int height, int drawX, int drawY) { this.manager = manager; java.net.URL url = ClassLoader.getSystemClassLoader().getResource("images/dgu.gif"); if (url != null) setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage(url)); setBounds(screenX, screenY, width, height); setMySize(width, height, 1.0f); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); // setup the canvas for the window to draw final Container cp = getContentPane(); cp.setLayout(null); cp.add(lblCanvas); lblCanvas.setBorder(BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); lblCanvas.setDoubleBuffered(true); lblCanvas.setFocusable(true); initEventListeners(); drawOffset.set(drawX, drawY); }
private JComponent createSettingsPanel() { JPanel result = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0)); result.add(new JLabel(ApplicationBundle.message("label.font.size"))); myFontSizeSlider = new JSlider(JSlider.HORIZONTAL, 0, FontSize.values().length - 1, 3); myFontSizeSlider.setMinorTickSpacing(1); myFontSizeSlider.setPaintTicks(true); myFontSizeSlider.setPaintTrack(true); myFontSizeSlider.setSnapToTicks(true); UIUtil.setSliderIsFilled(myFontSizeSlider, true); result.add(myFontSizeSlider); result.setBorder(BorderFactory.createLineBorder(UIUtil.getBorderColor(), 1)); myFontSizeSlider.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (myIgnoreFontSizeSliderChange) { return; } EditorColorsManager colorsManager = EditorColorsManager.getInstance(); EditorColorsScheme scheme = colorsManager.getGlobalScheme(); scheme.setQuickDocFontSize(FontSize.values()[myFontSizeSlider.getValue()]); applyFontSize(); } }); String tooltipText = ApplicationBundle.message("quickdoc.tooltip.font.size.by.wheel"); result.setToolTipText(tooltipText); myFontSizeSlider.setToolTipText(tooltipText); result.setVisible(false); result.setOpaque(true); myFontSizeSlider.setOpaque(true); return result; }
private void addComponents() { this.setLayout(new BorderLayout()); this.setSize(new Dimension(350, 200)); // set display location Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation((d.width - getWidth()) / 2, (d.height - getHeight()) / 2); textArea = new JTextArea(); textArea.setLineWrap(true); textArea.setEditable(false); textArea.setBorder(BorderFactory.createLineBorder(Color.gray)); JScrollPane scrollPane = new JScrollPane( textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); this.add(scrollPane, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton closeButton = new JButton("Close"); closeButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PopupDialog.this.setVisible(false); } }); buttonPanel.add(closeButton); this.add(buttonPanel, BorderLayout.SOUTH); }
private void initUI() { JPanel infoPanel = new JPanel(); infoPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); infoPanel.setBackground(Color.WHITE); infoPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); infoPanel.add( new JLabel( new ImageIcon( Thread.currentThread().getContextClassLoader().getResource("siw-logo3_2.gif")))); JLabel textLabel = new JLabel("<html>Confirmation</html>"); infoPanel.add(textLabel); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridLayout(0, 1)); buttonPanel.add(reportLabel); this.setLayout(new BorderLayout()); this.add(infoPanel, BorderLayout.NORTH); this.add(buttonPanel, BorderLayout.CENTER); }
public void eventDispatched(AWTEvent event) { if (!isAssertTrigger(event)) { return; } MouseEvent mouse = (MouseEvent) event; GuiComponent guiComponent = factory.find(mouse); if (guiComponent == null) { return; } assertContext.setGuiComponent(guiComponent); assertContext.setPoint(mouse.getPoint()); JPopupMenu menu = dialogManager.newPopupMenu(); for (Iterator iterator = actionManager.actions(); iterator.hasNext(); ) { AbstractAssert assertAction = (AbstractAssert) iterator.next(); String actionId = (String) assertAction.getValue(AbstractAssert.ACTION_ID); ActionViewUtil.connectActionTo(assertAction, menu.add(actionId)); assertAction.update(); if (!guiComponent.isFindable() && AbstractAssert.COMPONENT_ASSERT == assertAction.getAssertType()) { assertAction.setEnabled(false); } } menu.setBorder(BorderFactory.createLineBorder(Color.blue, 5)); menu.show(guiComponent.getSwingComponent(), mouse.getX(), mouse.getY()); }
private void init() { setSize(800, 600); cp = getContentPane(); cp.setLayout(null); btnResize.addActionListener(this); btnResize.setLocation(0, 0); btnResize.setSize(100, 30); sp.setLocation(0, 31); sp.setBorder(BorderFactory.createLineBorder(Color.blue, 2)); editorPane.setBorder(BorderFactory.createLineBorder(Color.red, 2)); step.setLocation(0, 31); step.setSize(100, 100); cp.add(step); // cp.add(sp); cp.add(btnResize); }
@Override public void init() { AdvancedGUIEX1 content = new AdvancedGUIEX1(); content.setBorder(BorderFactory.createLineBorder(Color.GRAY, 2)); setContentPane(content); setJMenuBar(content.getMenuBar()); }
/** * And now for a little assembly. Put together the buttons, progress bar and status text field. */ Example1(String name) { setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), name)); progressBar.setMaximum(NUMLOOPS); startButton = new JButton("Start"); startButton.addActionListener(startListener); startButton.setEnabled(true); interruptButton = new JButton("Cancel"); interruptButton.addActionListener(interruptListener); interruptButton.setEnabled(false); JComponent buttonBox = new JPanel(); buttonBox.add(startButton); buttonBox.add(interruptButton); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); add(buttonBox); add(progressBar); add(statusField); statusField.setAlignmentX(CENTER_ALIGNMENT); buttonBox.setBorder(spaceBelow); Border pbBorder = progressBar.getBorder(); progressBar.setBorder(BorderFactory.createCompoundBorder(spaceBelow, pbBorder)); }
public AddNewStudent() // constructor { // initializing buttons btnok = new JButton("OK"); btnok.addActionListener(this); btnexit = new JButton("Exit"); btnexit.addActionListener(this); btnaddnew = new JButton("AddNew"); btnaddnew.addActionListener(this); // initializing textfields tf1 = new JTextField(12); tf2 = new JTextField(12); // initializing labels lblname = new JLabel("Name:"); lbladd = new JLabel("Address:"); lblmsg = new JLabel("", JLabel.CENTER); // initializing panels p1 = new JPanel(); p2 = new JPanel(); p3 = new JPanel(); psouth = new JPanel(); // adding buttons and label to panel p1 // setting flowlayout p1.setLayout(new FlowLayout()); p1.add(btnok); p1.add(btnexit); p1.add(btnaddnew); // adding lblmsg to panel p3 p3.add(lblmsg); // adding both the panels to new panel,psouth // settin layout 2:1 psouth.setLayout(new GridLayout(2, 1)); psouth.add(p3); psouth.add(p1); // adding label and textfields to panel p2 p2.setLayout(new GridLayout(3, 1)); // setting line and titled border for panel p2 p2.setBorder(BorderFactory.createLineBorder(Color.red)); p2.setBorder(BorderFactory.createTitledBorder("Enter Your Details")); p2.add(lblname); p2.add(tf1); p2.add(lbladd); p2.add(tf2); // adding panel to container this.getContentPane().add(p2, "Center"); this.getContentPane().add(psouth, "South"); this.setSize(300, 300); this.setLocation(100, 200); this.show(); }
public void createColorPanel() { JPanel colorPanel = new JPanel(new GridLayout(0, 1)); int curRow = 0; for (int i = 0; i < colorString.length / 5; i++) { JPanel row = new JPanel(new GridLayout(1, 0, 2, 1)); row.setBorder(new EmptyBorder(2, 2, 2, 2)); for (int j = curRow; j < curRow + 5; j++) { final JLabel colorLabel = new JLabel(null, new ColoredIcon(color[j], 14, 14), JLabel.CENTER); colorLabel.setOpaque(true); final Border emb = BorderFactory.createEmptyBorder(2, 1, 2, 1); final Border lnb = BorderFactory.createLineBorder(Color.black); final Border cmb = BorderFactory.createCompoundBorder(lnb, emb); colorLabel.setBorder(emb); colorLabel.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { JButton btn = (JButton) getTarget(); Color selColor = ((ColoredIcon) colorLabel.getIcon()).getCurrentColor(); btn.setIcon(new ColoredIcon(selColor)); setVisible(false); btn.doClick(); oldLabel.setBackground(null); colorLabel.setBackground(new Color(150, 150, 200)); colorLabel.setBorder(emb); oldLabel = colorLabel; } public void mouseEntered(MouseEvent e) { colorLabel.setBorder(cmb); colorLabel.setBackground(new Color(150, 150, 200)); } public void mouseExited(MouseEvent e) { colorLabel.setBorder(emb); colorLabel.setBackground(null); } }); row.add(colorLabel); } colorPanel.add(row); curRow += row.getComponentCount(); // System.out.println(curRow); } add(colorPanel, BorderLayout.CENTER); // More Colors Button moreColors = new JButton(new ColorChooserAction((JButton) target)); moreColors.setText("More Colors..."); moreColors.setIcon(null); moreColors.setFont(new Font("Verdana", Font.PLAIN, 10)); // JPanel c = new JPanel(new FlowLayout(FlowLayout.CENTER)); c.add(moreColors); add(c, BorderLayout.SOUTH); }
/** * Gets the progress bar border. * * @return the progress bar border */ public static Border getProgressBarBorder() { if (progressBarBorder == null) { progressBarBorder = BorderFactory.createLineBorder( ColorHelper.darker(AbstractLookAndFeel.getBackgroundColor(), 30)); } return progressBarBorder; }