public ViewHolder(String id, String loc, JSplitPane sp) { this.loc = loc; this.splitPane = sp; setLayout(new BorderLayout()); // setMinimumSize(new Dimension(5, 5)); addContainerListener( new ContainerListener() { public void componentAdded(ContainerEvent e) { if (getComponentCount() == 1) { splitPane.add(ViewHolder.this, ViewHolder.this.loc); } } public void componentRemoved(ContainerEvent e) { if (getComponentCount() == 0) { splitPane.remove(ViewHolder.this); } } }); createHolder(); setBorder( BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(1, 1, 1, 1, Color.LIGHT_GRAY), BorderFactory.createEmptyBorder(2, 2, 2, 2))); }
/** * 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)); }
private JPanel createCentrePanel(YDataStateException exception) { JPanel centrePanel = new JPanel(new GridLayout(1, 2)); JPanel msgPanel = new JPanel(new BorderLayout()); msgPanel.setBackground(YAdminGUI._apiColour); msgPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Schema for completing task"), BorderFactory.createEmptyBorder(10, 10, 10, 10))); JTextPane msgTextPane = new JTextPane(); msgTextPane.setContentType("text/plain"); msgTextPane.setFont(new Font("courier", Font.PLAIN, 12)); msgTextPane.setForeground(Color.RED); msgTextPane.setText(exception.getMessage()); msgTextPane.setEditable(false); msgTextPane.setBackground(Color.LIGHT_GRAY); JPanel noWrapPanel = new JPanel(); noWrapPanel.setLayout(new BorderLayout()); noWrapPanel.add(msgTextPane); msgPanel.add(new JScrollPane(noWrapPanel)); centrePanel.add(msgPanel, BorderLayout.NORTH); return centrePanel; }
/** @param frameName title name for frame */ public ShowSavedResults(String frameName) { super(frameName); aboutRes = new JTextArea( "Select a result set from" + "\nthose listed and details" + "\nof that analysis will be" + "\nshown here. Then you can" + "\neither delete or view those" + "\nresults using the buttons below."); aboutScroll = new JScrollPane(aboutRes); ss = new JScrollPane(sp); ss.getViewport().setBackground(Color.white); // resMenu.setLayout(new FlowLayout(FlowLayout.LEFT,10,1)); ClassLoader cl = getClass().getClassLoader(); rfii = new ImageIcon(cl.getResource("images/Refresh_button.gif")); // results status resButtonStatus = new JPanel(new BorderLayout()); Border loweredbevel = BorderFactory.createLoweredBevelBorder(); Border raisedbevel = BorderFactory.createRaisedBevelBorder(); Border compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel); statusField = new JTextField(); statusField.setBorder(compound); statusField.setEditable(false); }
private JComponent createLabelsPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridLayout(0, 2, 10, 1)); // Creates a StyledLabel to warn up so that we don't include class loading time into the // performance test. // This is the same for all three cases. new JLabel("Bold Italic Underlined"); long start = System.currentTimeMillis(); for (int i = 0; i < COUNT; i++) { JLabel label = new JLabel("Bold Italic Underlined"); panel.add(label); } panel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( new PartialLineBorder(Color.gray, 1, true), " JLabel (Plain) Examples - use " + (System.currentTimeMillis() - start) + " ms ", TitledBorder.CENTER, TitledBorder.CENTER, null, Color.RED), BorderFactory.createEmptyBorder(6, 4, 4, 4))); return panel; }
protected void init(JPanel customPanel) { setTitle(LanguageBundle.getInstance().getMessage("label.copy")); setModal(true); setResizable(false); JPanel optionPanel = createOptionPanel(); // generic panels JPanel conPanel1 = createConnectionPanel( details1, LanguageBundle.getInstance().getMessage("copy.confirm.source")); JPanel conPanel2 = createConnectionPanel( details2, LanguageBundle.getInstance().getMessage("copy.confirm.target")); JPanel sourceP = createPathPanel(details1.getCurrentPath()); JPanel toP = createToPanel(); JPanel targetP = createPathPanel(details2.getCurrentPath()); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); addLeftToPanel(mainPanel, customPanel); mainPanel.add(Box.createVerticalStrut(3)); addLeftToPanel(mainPanel, conPanel1); addLeftToPanel(mainPanel, sourceP); mainPanel.add(Box.createVerticalStrut(3)); addLeftToPanel(mainPanel, toP); mainPanel.add(Box.createVerticalStrut(3)); addLeftToPanel(mainPanel, conPanel2); addLeftToPanel(mainPanel, targetP); addLeftToPanel(mainPanel, optionPanel); mainPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(2, 5, 2, 5), BorderFactory.createCompoundBorder( BorderFactory.createEtchedBorder(), BorderFactory.createEmptyBorder(5, 5, 5, 5)))); JPanel buttonPanel = createButtonPanel(); getContentPane().add(mainPanel, BorderLayout.CENTER); getContentPane().add(buttonPanel, BorderLayout.SOUTH); pack(); setLocationRelativeTo(parent); okB.requestFocus(); }
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); }
public TeacherManagePasswords() { super(new BorderLayout()); setBackground(FWCConfigurator.bgColor); // Build title and north panel pnNorth = new JPanel(new FlowLayout(FlowLayout.CENTER)); pnNorth.setBackground(FWCConfigurator.bgColor); lblTitle = new TitleLabel("Reset Passwords", FWCConfigurator.RESET_PASSW_TITLE_IMG); pnNorth.add(lblTitle); // Build center panel pnCenter = new JPanel(new BorderLayout()); pnCenter.setBackground(FWCConfigurator.bgColor); // Build table of students tableModel = new DisabledTableModel(); tableModel.setColumnIdentifiers( new String[] {"First Name", " Last " + "Name", "Username", "Class"}); studentsTable = new JTable(tableModel); studentsTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); studentsTable.setFillsViewportHeight(true); studentsTable.getTableHeader().setFont(new Font("Calibri", Font.PLAIN, 18)); studentsTable.setFont(new Font("Calibri", Font.PLAIN, 18)); studentsTable.setRowHeight(studentsTable.getRowHeight() + 12); // Populate the table only with students that need a password reset students = FWCConfigurator.getTeacher().getStudentsRequestedReset(); populateTable(); tableScroll = new JScrollPane( studentsTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); tableScroll.setBackground(FWCConfigurator.bgColor); tableScroll.setBorder( BorderFactory.createCompoundBorder( new EmptyBorder(10, 100, 10, 100), new LineBorder(Color.black, 1))); pnCenter.add(tableScroll, BorderLayout.CENTER); // Build south panel pnButtons = new JPanel(new FlowLayout(FlowLayout.CENTER)); pnButtons.setBackground(FWCConfigurator.bgColor); pnButtons.setBorder(BorderFactory.createEmptyBorder(0, 100, 20, 100)); btnReset = new ImageButton("Reset Selected", FWCConfigurator.RESET_SELECTED_IMG, 150, 50); btnReset.addActionListener(new ResetListener()); btnResetAll = new ImageButton("Reset All", FWCConfigurator.RESET_ALL_IMG, 150, 50); btnResetAll.addActionListener(new ResetListener()); pnButtons.add(btnReset); pnButtons.add(btnResetAll); this.add(pnNorth, BorderLayout.NORTH); this.add(pnCenter, BorderLayout.CENTER); this.add(pnButtons, BorderLayout.SOUTH); }
public RowPanel(String name) { super(); Border empty = BorderFactory.createEmptyBorder(10, 10, 10, 10); Border line = BorderFactory.createLineBorder(Color.GRAY); Border title = BorderFactory.createTitledBorder(line, name); Border compound = BorderFactory.createCompoundBorder(title, empty); setBorder(compound); setLayout(new RowLayout()); }
public MessageLabel() { // setMinimumSize(new Dimension(16, 16)); setFont(getFont().deriveFont(Font.PLAIN)); setText(" "); Border empty = BorderFactory.createEmptyBorder(2, 2, 2, 2); Border bevel = new SoftBevelBorder(SoftBevelBorder.LOWERED); setBorder(BorderFactory.createCompoundBorder(bevel, empty)); setMessage(MessageLabel.INFO, "To begin, click on \"New Block\" to create blocks."); }
@Override protected void inicializarPantalla(JFrame pantalla) { // ~~----------------------------------------------------- Panel principal JPanel panel = new JPanel(); panel.setOpaque(true); panel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Pruebas"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); // ~~----------------------------------------------------- Botón de avance JButton avanzar = new JButton("Avanzar Tiempo"); avanzar.addActionListener(new AvanzarTiempo(this.jugador)); avanzar.setAlignmentX(Component.CENTER_ALIGNMENT); JButton avanzarRapido = new JButton("Avanzar Tiempo Rápido"); // ToDo hacer que el avanze sea configurable con un slider avanzarRapido.addActionListener(new AvanzarTiempo(this.jugador, FACTOR_DE_MULTIPLICACION)); avanzarRapido.setAlignmentX(Component.CENTER_ALIGNMENT); JButton terremoto = new JButton("Terremoto"); terremoto.addActionListener(new GenerarTerremoto(jugador.getMapa(), mensajero)); terremoto.setAlignmentX(Component.CENTER_ALIGNMENT); JButton godzilla = new JButton("Godzilla Lineal"); godzilla.addActionListener( new GenerarGodzilla(new GodzillaLineal(jugador.getMapa(), new AzarReal()), mensajero)); godzilla.setAlignmentX(Component.CENTER_ALIGNMENT); JButton godzillaZigZag = new JButton("Godzilla ZigZag"); godzillaZigZag.addActionListener( new GenerarGodzilla(new GodzillaZigZag(jugador.getMapa(), new AzarReal()), mensajero)); godzillaZigZag.setAlignmentX(Component.CENTER_ALIGNMENT); JButton godzillaDiagonal = new JButton("Godzilla Diagonal"); godzillaDiagonal.addActionListener( new GenerarGodzilla(new GodzillaDiagonal(jugador.getMapa(), new AzarReal()), mensajero)); godzillaDiagonal.setAlignmentX(Component.CENTER_ALIGNMENT); JButton bomberos = new JButton("Bomberos"); bomberos.addActionListener(new LlamarBomberos(jugador, mensajero)); bomberos.setAlignmentX(Component.CENTER_ALIGNMENT); panel.add(avanzar); panel.add(avanzarRapido); panel.add(terremoto); panel.add(godzilla); panel.add(godzillaDiagonal); panel.add(godzillaZigZag); panel.add(bomberos); pantalla.getContentPane().add(panel); pantalla.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); }
public ComboBoxDemo2() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z", "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" }; currentPattern = patternExamples[0]; // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); JComboBox patternList = new JComboBox(patternExamples); patternList.setEditable(true); patternList.addActionListener(this); // Create the UI for displaying result. JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); // == LEFT result = new JLabel(" "); result.setForeground(Color.black); result.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything. JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); patternPanel.add(patternList); JPanel resultPanel = new JPanel(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT); resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(patternPanel); add(Box.createRigidArea(new Dimension(0, 10))); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); } // constructor
@Nullable protected final JComponent createTitlePane() { final String description = myChooserDescriptor.getDescription(); if (StringUtil.isEmptyOrSpaces(description)) return null; final JLabel label = new JLabel(description); label.setBorder( BorderFactory.createCompoundBorder( new SideBorder(UIUtil.getPanelBackground().darker(), SideBorder.BOTTOM), JBUI.Borders.empty(0, 5, 10, 5))); return label; }
public PlayButton(String name) { super(name); myBorder = BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.black), BorderFactory.createLineBorder(Color.blue)), BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.cyan), BorderFactory.createLineBorder(Color.white))); addMouseListener( new MouseAdapter() { public void mouseEntered(MouseEvent e) { setBorder(myBorder); } public void mouseExited(MouseEvent e) { setBorder(null); } }); }
public static void main(String[] args) { JFrame frame = new JFrame("Demo of Additional Borders"); frame.setIconImage(JideIconsFactory.getImageIcon(JideIconsFactory.JIDE32).getImage()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new BorderLayout()); JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS, 10)); JTextArea textField = new JTextArea(); JPanel border = new JPanel(new BorderLayout()); border.setPreferredSize(new Dimension(100, 100)); border.add(new JScrollPane(textField), BorderLayout.CENTER); border.setBorder( new JideTitledBorder( new PartialEtchedBorder(PartialEtchedBorder.LOWERED, PartialSide.NORTH), "PartialEtchedBorder")); JTextArea textField2 = new JTextArea(); JPanel border2 = new JPanel(new BorderLayout()); border2.setPreferredSize(new Dimension(100, 100)); border2.add(new JScrollPane(textField2), BorderLayout.CENTER); border2.setBorder( new JideTitledBorder( new PartialLineBorder(Color.darkGray, 1, PartialSide.NORTH), "PartialLineBorder")); JTextArea textField3 = new JTextArea(); JPanel border3 = new JPanel(new BorderLayout()); border3.setPreferredSize(new Dimension(100, 100)); border3.add(new JScrollPane(textField3), BorderLayout.CENTER); border3.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( new PartialLineBorder(Color.gray, 1, true), "Rounded Corners Border"), BorderFactory.createEmptyBorder(0, 6, 4, 6))); panel.add(border, JideBoxLayout.FLEXIBLE); panel.add(Box.createVerticalStrut(12)); panel.add(border2, JideBoxLayout.FLEXIBLE); panel.add(Box.createVerticalStrut(12)); panel.add(border3, JideBoxLayout.FLEXIBLE); panel.add(Box.createGlue(), JideBoxLayout.VARY); panel.setPreferredSize(new Dimension(500, 400)); frame.getContentPane().add(panel, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }
private JPanel createTopPanel(YWorkItem item) { JPanel topPanel = new JPanel(new BorderLayout()); topPanel.setBackground(YAdminGUI._apiColour); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); JTextArea explanatoryText = new JTextArea(); explanatoryText.setText( "The data you submitted for this work item was \n" + "validated against a schema (see below). For some reason the\n" + "this data did not succeed in passing the constrainst set\n" + "inside the schema.\n" + "Usage Note: If this is causing problems try using the Web server\n" + "version of YAWL, which supports automatic forms generation.\n" + "Otherwise you could copy the schema from this page and use it\n " + "to create a valid output document using an XML development tool."); explanatoryText.setEditable(false); explanatoryText.setFont(new Font("Arial", Font.BOLD, 12)); explanatoryText.setForeground(Color.DARK_GRAY); explanatoryText.setBackground(YAdminGUI._apiColour); leftPanel.add(explanatoryText); topPanel.add(leftPanel, BorderLayout.WEST); JPanel rightPanel = new JPanel(new GridLayout(4, 2)); rightPanel.setBackground(YAdminGUI._apiColour); rightPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Work Item Details"), BorderFactory.createEmptyBorder(10, 10, 10, 10))); YTask task = YEngine.getInstance().getTaskDefinition(item.getSpecificationID(), item.getTaskID()); String taskName = task.getName(); String[] text = { item.getSpecificationID().toString(), taskName, item.getIDString(), item.getStartTimeStr() }; String[] labels = {"Specification ID", "Task Name", "WorkItem ID", "Task Started"}; for (int i = 0; i < text.length; i++) { String s = text[i]; rightPanel.add(new JLabel(labels[i])); JTextField t = new JTextField(s); t.setEditable(false); rightPanel.add(t); } topPanel.add(rightPanel, BorderLayout.CENTER); return topPanel; }
public PerceptronMain() { setPreferredSize(new java.awt.Dimension(250, 200)); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setLocation(screenSize.width / 2, screenSize.height / 2); // Establecemos el tipo de layout setLayout(new BorderLayout()); // Etiqueta de informacion labelInfo = new JLabel("Elija una de las dos opciones a ejecutar"); erreTrabajo.setDocument(new controlarLontigud(2, true)); // Crea el panel de botones buttonPanel = createButtonPanel(); /* Creamos un layout propio para los controles anteriores */ GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); // Establecemos la rejilla textControlsPane.setLayout(gridbag); // Por comodidad, creamos una funcion que aniada los controles a la rejilla // y al panel que la contiene... c.gridwidth = GridBagConstraints.REMAINDER; // last c.anchor = GridBagConstraints.EAST; c.weightx = 10.0; // Agregamos la etiqueta labelInfo al panel. textControlsPane.add(labelInfo, c); JLabel[] labels = {erreTrabajoLbl}; JTextField[] textFields = {erreTrabajo}; // Colocamos en el panel las etiquetas y los textfields. addLabelTextRows(labels, textFields, gridbag, textControlsPane); // Agregamos al panel los botones. textControlsPane.add(buttonPanel, c); // Situados los demas elementos, colocamos la etiqueta informativa textControlsPane.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("RNAG - Perceptrón | Adaline"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // A�adimos el panel en la zona "LINE_START" al principio... add(textControlsPane, BorderLayout.LINE_START); } // fin_MiLogin()
protected JPanel makeControlPanel() { JPanel innerPanel = new JPanel(new GridLayout(8, 1)); innerPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Go To"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); for (PathAction pa : pathActions) { JButton btn = new JButton(pa); innerPanel.add(btn); } JPanel cp = new JPanel(new BorderLayout()); cp.add(innerPanel, BorderLayout.CENTER); return cp; }
public CustomizableComboBox() { super(new BorderLayout()); myThemedCombo.setEditable(true); PopupMouseListener listener = new PopupMouseListener(); // GTK always draws a border on the textbox. It cannot be removed, // so to compensate, we remove our own border so we don't have a double border. if (UIUtil.isUnderGTKLookAndFeel()) { this.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); } else { this.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createLineBorder(getBorderColor(), 1))); } // Try to turn off the border on the JTextField. myTextField = new JBTextField() { @Override public void setBorder(Border border) { super.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); } }; myTextField.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); myTextField.addMouseListener(listener); myTextField.addFocusListener( new FocusListener() { @Override public void focusGained(FocusEvent e) { myTextField.selectAll(); } @Override public void focusLost(FocusEvent e) { // no-op } }); JButton popupButton = createArrowButton(); popupButton.addMouseListener(listener); this.add(popupButton, BorderLayout.EAST); this.add(myTextField, BorderLayout.CENTER); }
private JPanel createPredefinedSizesPanel() { JPanel panel = new JPanel(); Border border = BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(0, 20, 0, 0), BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Predefined Sizes")); panel.setBorder(border); panel.setLayout(new GridLayout(predefinedSizeButtons.length, 1)); for (SizeButton button : predefinedSizeButtons) { panel.add(button); } return panel; }
/** * Creates one thumbnail checkbox combination as a component surrounded by a {@link JPanel} * * @param setSelected decides whether or not the {@link JCheckBoxWithUserObject} shall be selected * or not. * @param jpegFile is the file that shall be shown as thumbnail in this component. * @return a {@link JPanel} that contains a {@link JLabel} with an icon (the image thumbnail) and * a {@link JCheckBoxWithUserObject}. */ private JPanel createThumbnailAndCheckBoxContainer(boolean setSelected, File jpegFile) { JPanel thumbnailAndCheckBoxPanel = new JPanel(new BorderLayout()); thumbnailAndCheckBoxPanel.setBorder( BorderFactory.createCompoundBorder(new TitledBorder(""), new EmptyBorder(2, 2, 2, 2))); JPEGThumbNail tn = JPEGThumbNailRetriever.getInstance().retrieveThumbNailFrom(jpegFile); JLabel thumbNail = new JLabel(new ImageIcon(tn.getThumbNailData())); JCheckBoxWithUserObject<File> checkBox = new JCheckBoxWithUserObject<File>(jpegFile); checkBox.setSelected(setSelected); thumbnailAndCheckBoxPanel.add(thumbNail, BorderLayout.CENTER); thumbnailAndCheckBoxPanel.add(checkBox, BorderLayout.SOUTH); checkBoxes.add(checkBox); return thumbnailAndCheckBoxPanel; }
public CompoundTreeCellRenderer() { super(); Color bsColor = getBorderSelectionColor(); Color focusBGColor = new Color(~getBackgroundSelectionColor().getRGB()); hasFocusBorder = BorderFactory.createCompoundBorder(new DotBorder(focusBGColor, bsColor), innerBorder); icon.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); text.setBorder(emptyBorder); text.setOpaque(true); p.setOpaque(false); p.add(icon, BorderLayout.WEST); JPanel wrap = new JPanel(new GridBagLayout()); wrap.setOpaque(false); wrap.add(text); p.add(wrap); }
private JPanel createPanel2() { JPanel panel = new JPanel(); panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS)); panel.setBorder( BorderFactory.createCompoundBorder( new JideTitledBorder( new PartialEtchedBorder(PartialEtchedBorder.LOWERED, PartialSide.NORTH), "AutoCompletion with list and tree", JideTitledBorder.LEADING, JideTitledBorder.ABOVE_TOP), BorderFactory.createEmptyBorder(0, 0, 0, 0))); // create tree combobox final JTextField treeTextField = new JTextField(); treeTextField.setName("AutoCompletion JTextField with JTree"); SelectAllUtils.install(treeTextField); final JTree tree = new JTree(); tree.setVisibleRowCount(10); final TreeSearchable searchable = new TreeSearchable(tree); searchable.setRecursive(true); new AutoCompletion(treeTextField, searchable); panel.add(new JLabel("AutoCompletion JTextField with JTree")); panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX); panel.add(treeTextField); panel.add(Box.createVerticalStrut(2), JideBoxLayout.FIX); panel.add(new JScrollPane(tree)); panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX); // create font name combobox final JTextField fontNameTextField = new JTextField(); fontNameTextField.setName("AutoCompletion JTextField with JList"); SelectAllUtils.install(fontNameTextField); final JList fontNameList = new JList(_fontNames); fontNameList.setVisibleRowCount(10); new AutoCompletion(fontNameTextField, new ListSearchable(fontNameList)); panel.add(new JLabel("AutoCompletion JTextField with JList")); panel.add(Box.createVerticalStrut(3), JideBoxLayout.FIX); panel.add(fontNameTextField); panel.add(Box.createVerticalStrut(2), JideBoxLayout.FIX); panel.add(new JScrollPane(fontNameList)); panel.add(Box.createVerticalStrut(12), JideBoxLayout.FIX); return panel; }
protected void setUpSRSFrame(URL url, String search) throws IOException { if (BigPane.srsFrame == null) { BigPane.setUpSRSFrame((2 * desktop.getHeight()) / 3, desktop); Border loweredbevel = BorderFactory.createLoweredBevelBorder(); Border raisedbevel = BorderFactory.createRaisedBevelBorder(); Border compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel); JTextField statusField = new JTextField(); statusField.setBorder(compound); statusField.setEditable(false); BigPane.srsFrame.getContentPane().add(statusField, BorderLayout.SOUTH); } Annotation edPane = new Annotation(url); JScrollPane jsp = new JScrollPane(edPane); JTabbedPane jtab = (JTabbedPane) BigPane.srsFrame.getContentPane().getComponent(0); jtab.insertTab(search, null, jsp, null, 0); BigPane.srsFrame.setVisible(true); }
public FindProf() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Search your campus!"); JLabel patternLabel2 = new JLabel(""); patternList = new JComboBox<Object>(searchNames); patternList.setEditable(true); patternList.setMaximumRowCount(5); patternList.addActionListener(this); // Create the UI for displaying result. JLabel resultLabel = new JLabel("Building Initials & Room Number:", JLabel.LEADING); // == LEFT result = new JLabel(" "); result.setHorizontalAlignment(SwingConstants.CENTER); result.setForeground(Color.black); result.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything. JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); patternPanel.add(patternList); JPanel resultPanel = new JPanel(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT); resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(patternPanel); add(Box.createRigidArea(new Dimension(0, 10))); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); } // constructor
private JComponent createStyledLabelsPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridLayout(0, 2, 10, 1)); // Creates a StyledLabel to warn up so that we don't include class loading time into the // performance test. // This is the same for all three cases. StyledLabel label = new StyledLabel("Bold Italic Underlined"); // we could pub the creation of StyleRange[] outside the loop. // But to make the comparison fair, we kept it inside. label.setStyleRanges( new StyleRange[] { new StyleRange(0, 4, Font.BOLD), new StyleRange(5, 6, Font.ITALIC), new StyleRange(12, 10, Font.PLAIN, StyleRange.STYLE_UNDERLINED) }); long start = System.currentTimeMillis(); for (int i = 0; i < COUNT; i++) { label = new StyledLabel("Bold Italic Underlined"); // we could pub the creation of StyleRange[] outside the loop. // But to make the comparison fair, we kept it inside. label.setStyleRanges( new StyleRange[] { new StyleRange(0, 4, Font.BOLD), new StyleRange(5, 6, Font.ITALIC), new StyleRange(12, 10, Font.PLAIN, StyleRange.STYLE_UNDERLINED) }); panel.add(label); } panel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( new PartialLineBorder(Color.gray, 1, true), " StyledLabel Examples - use " + (System.currentTimeMillis() - start) + " ms ", TitledBorder.CENTER, TitledBorder.CENTER, null, Color.RED), BorderFactory.createEmptyBorder(6, 4, 4, 4))); return panel; }
public static void main(String[] args) { final JFrame jFrame = new JFrame(); jFrame.getContentPane().setLayout(new BorderLayout()); jFrame.getContentPane().setBackground(Color.white); final JPanel jPanel = new JPanel(new BorderLayout()); jPanel.setBackground(Color.white); jPanel.setOpaque(true); jPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(10, 10, 10, 10), new BlockBorder(new Insets(5, 5, 5, 5), new Insets(5, 5, 5, 5)))); jFrame.getContentPane().add(jPanel); jFrame.setBounds(100, 100, 200, 200); jFrame.setVisible(true); }
private JPanel createBattlefieldSizePanel() { JPanel panel = new JPanel(); panel.addAncestorListener(eventHandler); Border border = BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Battlefield Size"), BorderFactory.createEmptyBorder(10, 10, 10, 10)); panel.setBorder(border); panel.setLayout(new BorderLayout()); JPanel sliderPanel = createBattlefieldSlidersPanel(); panel.add(sliderPanel, BorderLayout.CENTER); JPanel buttonsPanel = createPredefinedSizesPanel(); panel.add(buttonsPanel, BorderLayout.EAST); return panel; }
public EventLogPanel() { sc = new StyleContext(); doc = new DefaultStyledDocument(sc); logsPanel = new JTextPane(doc); logsPanel.setEditable(false); cal = Calendar.getInstance(); sdf = new SimpleDateFormat("HH:mm:ss"); this.setLayout(new GridLayout(0, 1)); JScrollPane scrollPanel = new JScrollPane(logsPanel); scrollPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollPanel.setPreferredSize(new Dimension(840, 90)); scrollPanel.setMinimumSize(new Dimension(10, 10)); this.add(scrollPanel); this.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(1, 1, 1, 1), BorderFactory.createTitledBorder("Event Log"))); }
public static void main(String[] args) { // create a JFrame to hold everything JFrame frame = new JFrame("Borders"); // Create labels with borders. int center = SwingConstants.CENTER; JLabel labelOne = new JLabel("raised BevelBorder", center); labelOne.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); JLabel labelTwo = new JLabel("EtchedBorder", center); labelTwo.setBorder(BorderFactory.createEtchedBorder()); JLabel labelThree = new JLabel("MatteBorder", center); labelThree.setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink)); JLabel labelFour = new JLabel("TitledBorder", center); Border etch = BorderFactory.createEtchedBorder(); labelFour.setBorder(BorderFactory.createTitledBorder(etch, "Title")); JLabel labelFive = new JLabel("TitledBorder", center); Border low = BorderFactory.createLoweredBevelBorder(); labelFive.setBorder( BorderFactory.createTitledBorder(low, "Title", TitledBorder.RIGHT, TitledBorder.BOTTOM)); JLabel labelSix = new JLabel("CompoundBorder", center); Border one = BorderFactory.createEtchedBorder(); Border two = BorderFactory.createMatteBorder(4, 4, 4, 4, Color.blue); labelSix.setBorder(BorderFactory.createCompoundBorder(one, two)); // add components to the content pane Container c = frame.getContentPane(); // unecessary in 1.5+ c.setLayout(new GridLayout(3, 2)); c.add(labelOne); c.add(labelTwo); c.add(labelThree); c.add(labelFour); c.add(labelFive); c.add(labelSix); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }