// Component initialization private void jbInit() throws Exception { image1 = new ImageIcon(com.worldwizards.nwn.resbrowse.MainFrame.class.getResource("about.png")); imageLabel.setIcon(image1); this.setTitle("About"); panel1.setLayout(borderLayout1); panel2.setLayout(borderLayout2); insetsPanel1.setLayout(flowLayout1); insetsPanel2.setLayout(flowLayout1); insetsPanel2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); gridLayout1.setRows(4); gridLayout1.setColumns(1); label1.setText(product); label2.setText(version); label3.setText(copyright); label4.setText(comments); insetsPanel3.setLayout(gridLayout1); insetsPanel3.setBorder(BorderFactory.createEmptyBorder(10, 60, 10, 10)); button1.setText("Ok"); button1.addActionListener(this); insetsPanel2.add(imageLabel, null); panel2.add(insetsPanel2, BorderLayout.WEST); this.getContentPane().add(panel1, null); insetsPanel3.add(label1, null); insetsPanel3.add(label2, null); insetsPanel3.add(label3, null); insetsPanel3.add(label4, null); panel2.add(insetsPanel3, BorderLayout.CENTER); insetsPanel1.add(button1, null); panel1.add(insetsPanel1, BorderLayout.SOUTH); panel1.add(panel2, BorderLayout.NORTH); setResizable(true); }
@Override protected void changeBorder() { int flags; Border empty = BorderFactory.createEmptyBorder(); int iInsets = bSmallTitle ? 0 : 2; if (getOrientation().isHorizontal()) { flags = CEclipseBorder.TOP_RIGHT | CEclipseBorder.BOTTOM_RIGHT; empty = new EmptyBorder(iInsets, 2, iInsets, 4); } else { flags = CEclipseBorder.BOTTOM_LEFT | CEclipseBorder.BOTTOM_RIGHT; empty = new EmptyBorder(2, iInsets, 4, iInsets); } Border border = new CEclipseBorder(getOrigin().getController(), 6, flags); Insets ins = getOutsideInsets(); Border b = new CompoundBorder( BorderFactory.createEmptyBorder(ins.top, ins.left, ins.bottom, ins.right), new CompoundBorder(border, empty)); setBorder(ThemeManager.BORDER_MODIFIER + ".title.eclipse.button.flat", b); }
protected void initComponents() { int border = 2; this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); // Description label JPanel descriptionPanel = new JPanel(new GridLayout(0, 1, 0, 0)); descriptionPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); String text = thread.getRetrievable().getName(); text = text.length() > 40 ? text.substring(0, 37) + "..." : text; descriptionLabel = new JLabel(text); descriptionPanel.add(descriptionLabel); this.add(descriptionPanel); // Progrees and cancel button JPanel progressPanel = new JPanel(); progressPanel.setLayout(new BoxLayout(progressPanel, BoxLayout.X_AXIS)); progressPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); progressBar = new JProgressBar(0, 100); progressBar.setPreferredSize(new Dimension(100, 16)); progressPanel.add(progressBar); progressPanel.add(Box.createHorizontalStrut(8)); cancelButton = new JButton("Cancel"); cancelButton.setBackground(Color.RED); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { cancelButtonActionPerformed(event); } }); progressPanel.add(cancelButton); this.add(progressPanel); }
public FileNameRenderer(JTable table) { Border b = UIManager.getBorder("Table.noFocusBorder"); if (Objects.isNull(b)) { // Nimbus??? Insets i = focusCellHighlightBorder.getBorderInsets(textLabel); b = BorderFactory.createEmptyBorder(i.top, i.left, i.bottom, i.right); } noFocusBorder = b; p.setOpaque(false); panel.setOpaque(false); // http://www.icongalore.com/ XP Style Icons - Windows Application Icon, Software XP Icons nicon = new ImageIcon(getClass().getResource("wi0063-16.png")); sicon = new ImageIcon( p.createImage( new FilteredImageSource(nicon.getImage().getSource(), new SelectedImageFilter()))); iconLabel = new JLabel(nicon); iconLabel.setBorder(BorderFactory.createEmptyBorder()); p.add(iconLabel, BorderLayout.WEST); p.add(textLabel); panel.add(p, BorderLayout.WEST); Dimension d = iconLabel.getPreferredSize(); dim.setSize(d); table.setRowHeight(d.height); }
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
public AppFrame() { // Create the WorldWindow. this.wwjPanel = new ApplicationTemplate.AppPanel(this.canvasSize, true); this.wwjPanel.setPreferredSize(canvasSize); ApplicationTemplate.insertBeforePlacenames(this.wwjPanel.getWwd(), layer); JPanel shapesPanel = makeShapeSelectionPanel(); shapesPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel attrsPanel = makeAttributesPanel(); attrsPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // Put the pieces together. JPanel controlPanel = new JPanel(new BorderLayout()); controlPanel.add(shapesPanel, BorderLayout.CENTER); JPanel p = new JPanel(new BorderLayout(6, 6)); p.add(attrsPanel, BorderLayout.CENTER); controlPanel.add(p, BorderLayout.SOUTH); this.getContentPane().add(wwjPanel, BorderLayout.CENTER); this.getContentPane().add(controlPanel, BorderLayout.WEST); this.pack(); // Center the application on the screen. Dimension prefSize = this.getPreferredSize(); Dimension parentSize; java.awt.Point parentLocation = new java.awt.Point(0, 0); parentSize = Toolkit.getDefaultToolkit().getScreenSize(); int x = parentLocation.x + (parentSize.width - prefSize.width) / 2; int y = parentLocation.y + (parentSize.height - prefSize.height) / 2; this.setLocation(x, y); this.setResizable(true); wwjPanel .getWwd() .addRenderingListener( new RenderingListener() { public void stageChanged(RenderingEvent event) { if (!event.getStage().equals(RenderingEvent.BEFORE_BUFFER_SWAP)) return; if (currentShape instanceof Polyline) { Polyline p = (Polyline) currentShape; String length = Double.toString(p.getLength()); textRenderer.beginRendering(wwjPanel.getWidth(), wwjPanel.getHeight()); textRenderer.draw(length, 100, 100); textRenderer.endRendering(); } } }); // Enable dragging and other selection responses this.setupSelection(); }
public DisplayUserDirectory() { GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); setLayout(gbl); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; hmlabel.setForeground(Color.black); add(hmlabel, gbc); add(Box.createHorizontalStrut(10), gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; add(hmdir, gbc); add(Box.createVerticalStrut(15), gbc); gbc.gridwidth = 1; vjlabel.setForeground(Color.black); add(vjlabel, gbc); add(Box.createHorizontalStrut(10), gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; add(vjdir, gbc); add(Box.createVerticalStrut(0), gbc); gbc.gridwidth = 1; vjlabel2.setForeground(Color.black); add(vjlabel2, gbc); setBorder( new CompoundBorder( // i18n // BorderFactory.createTitledBorder(" User_Directories "), BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
/** * public MutableStatusBar(String s1, String s2, String s3) { super(); status_1 = new JLabel(s1); * status_2 = new JLabel(s2); status_3 = new JLabel(s3); this.init(); }. */ protected void init() { this.setLayout(new GridBagLayout()); this.setBorder(BorderFactory.createEmptyBorder(3, 2, 1, 1)); final GridBagConstraints constraints = new GridBagConstraints(); // status_1.setHorizontalAlignment(JLabel.CENTER); status_1.setBorder( new CompoundBorder( new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2))); status_1.setPreferredSize(new Dimension(180, 16)); status_2.setBorder( new CompoundBorder( new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2))); status_2.setPreferredSize(new Dimension(200, 16)); status_3.setBorder( new CompoundBorder( new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2))); status_3.setPreferredSize(new Dimension(300, 16)); greenStatusIcon = new MutableImageLabel(resource.getIcon("green_off.gif"), resource.getIcon("green_on.gif")); greenStatusIcon.setBorder(new EmptyBorder(2, 2, 2, 1)); redStatusIcon = new MutableImageLabel(resource.getIcon("red_off.gif"), resource.getIcon("red_on.gif")); redStatusIcon.setBorder(new EmptyBorder(2, 1, 2, 3)); // ===================================================================== constraints.insets = new Insets(0, 0, 0, 4); constraints.anchor = GridBagConstraints.EAST; constraints.fill = GridBagConstraints.VERTICAL; constraints.weightx = 1.0; constraints.weighty = 1.0; constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; this.add(status_1, constraints); constraints.weightx = 0.0; constraints.gridx++; this.add(status_2, constraints); constraints.gridx = 2; this.add(status_3, constraints); constraints.gridx++; if (greenStatusIcon != null) { this.add(greenStatusIcon, constraints); } constraints.insets = new Insets(0, 0, 0, 0); constraints.gridx++; if (redStatusIcon != null) { this.add(redStatusIcon, constraints); } }
public DisplayResults() { GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); setLayout(gbl); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; text.setForeground(Color.black); add(text, gbc); gbc.gridy = 0; gbc.gridwidth = GridBagConstraints.REMAINDER; add(emptyLabel, gbc); add(Box.createVerticalStrut(0), gbc); add(emptyLabel, gbc); /* gbc.gridy = 1; VTextMsg result = new VTextMsg(sshare, vnmrif, null); result.setPreferredSize(new Dimension(300, 30)); result.setForeground(Color.black); add( result, gbc ); */ setBorder( new CompoundBorder( BorderFactory.createTitledBorder(" Results "), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
private void jbInit() throws Exception { border1 = BorderFactory.createEmptyBorder(20, 20, 20, 20); contentPane.setBorder(border1); contentPane.setLayout(borderLayout1); controlsPane.setLayout(gridLayout1); gridLayout1.setColumns(1); gridLayout1.setHgap(10); gridLayout1.setRows(0); gridLayout1.setVgap(10); okButton.setVerifyInputWhenFocusTarget(true); okButton.setMnemonic('O'); okButton.setText("OK"); buttonsPane.setLayout(flowLayout1); flowLayout1.setAlignment(FlowLayout.CENTER); messagePane.setEditable(false); messagePane.setText(""); borderLayout1.setHgap(10); borderLayout1.setVgap(10); this.setTitle("Subscription Authorization"); this.getContentPane().add(contentPane, BorderLayout.CENTER); contentPane.add(controlsPane, BorderLayout.SOUTH); controlsPane.add(responsesComboBox, null); controlsPane.add(buttonsPane, null); buttonsPane.add(okButton, null); contentPane.add(messageScrollPane, BorderLayout.CENTER); messageScrollPane.getViewport().add(messagePane, null); }
private MainPanel() { super(new GridLayout(3, 1, 5, 5)); final JTree tree = new JTree(); final JCheckBox c = new JCheckBox("CheckBox", true); c.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { tree.setEnabled(c.isSelected()); } }); c.setFocusPainted(false); JScrollPane l1 = new JScrollPane(tree); l1.setBorder(new ComponentTitledBorder(c, l1, BorderFactory.createEtchedBorder())); JLabel icon = new JLabel(new ImageIcon(getClass().getResource("16x16.png"))); JLabel l2 = new JLabel("<html>aaaaaaaaaaaaaaaa<br>bbbbbbbbbbbbbbbbb"); l2.setBorder(new ComponentTitledBorder(icon, l2, BorderFactory.createEtchedBorder())); JButton b = new JButton("Button"); b.setFocusPainted(false); JLabel l3 = new JLabel("ccccccccccccccc"); l3.setBorder(new ComponentTitledBorder(b, l3, BorderFactory.createEtchedBorder())); add(l1); add(l2); add(l3); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setPreferredSize(new Dimension(320, 240)); }
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 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 ColorPane() { super(); Font font = new Font("Monospaced", Font.PLAIN, 12); FontMetrics fm = getFontMetrics(font); lineHeight = fm.getHeight(); setFont(font); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); }
protected RolloverBooleanRenderer(HighlightListener highlighter) { super(); this.highlighter = highlighter; setHorizontalAlignment(SwingConstants.CENTER); setBorderPainted(true); setRolloverEnabled(true); setOpaque(true); setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); }
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."); }
private JTabbedPane buildProblemsConsole() { // build the problems/console editor JTabbedPane tp = new JTabbedPane(); ImageIcon consoleIcon = makeImageIcon("stock_print-layout-16.png"); tp.addTab("Problems", addScrollers(problemsView)); tp.addTab("Console", consoleIcon, addScrollers(consoleView)); // empty border to give padding around tab pane tp.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); return tp; }
void initComponents() { JPanel mainPanel = new JPanel(new BorderLayout()); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); Color bgColor = Color.getHSBColor(0.58f, 0.17f, 0.95f); buttonPanel.setBackground(bgColor); Border empty = BorderFactory.createEmptyBorder(5, 5, 5, 5); buttonPanel.setBorder(empty); textField = new JTextField(75); buttonPanel.add(textField); buttonPanel.add(Box.createHorizontalStrut(10)); searchPHI = new JButton("Search PHI"); searchPHI.addActionListener(this); buttonPanel.add(searchPHI); buttonPanel.add(Box.createHorizontalStrut(10)); searchTrial = new JButton("Search Trial IDs"); searchTrial.addActionListener(this); buttonPanel.add(searchTrial); buttonPanel.add(Box.createHorizontalStrut(20)); buttonPanel.add(Box.createHorizontalGlue()); saveAs = new JCheckBox("Save As..."); saveAs.setBackground(bgColor); buttonPanel.add(saveAs); mainPanel.add(buttonPanel, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(); textPane = new ColorPane(); // textPane.setEditable(false); scrollPane.setViewportView(textPane); mainPanel.add(scrollPane, BorderLayout.CENTER); JPanel footerPanel = new JPanel(); footerPanel.setLayout(new BoxLayout(footerPanel, BoxLayout.X_AXIS)); footerPanel.setBackground(bgColor); message = new JLabel("Ready..."); footerPanel.add(message); mainPanel.add(footerPanel, BorderLayout.SOUTH); setTitle(windowTitle); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); getContentPane().add(mainPanel, BorderLayout.CENTER); pack(); centerFrame(); }
private void jbInit() throws Exception { titledBorder1 = new TitledBorder(""); this.setLayout(borderLayout1); this.setBorder(titledBorder1); titledBorder1.setTitleColor(Color.blue); titledBorder1.setTitle( ClientSettings.getInstance().getResources().getResource("documents filter")); this.add(sp, BorderLayout.CENTER); sp.setBorder(BorderFactory.createEmptyBorder()); sp.getViewport().add(innerPanel, null); sp.setAutoscrolls(true); innerPanel.setLayout(gridBagLayout1); }
protected void layoutUIComponents(String strPath, boolean bDefaultFile) { JLabel label = null; // i18n // label = new JLabel( "File names can be constructed from a template. The LABEL field is " ); label = new JLabel( Util.getAdmLabel( "_admin_File_names_can_be_constructed_from_a_template._The_LABEL_field_is_")); label.setForeground(Color.black); // m_gbc.weightx = 0.5; showInstruction(m_gbl, m_gbc, 0, 0, 7, label); // i18n // label = new JLabel( "presented as the choice to the user in the \"Data save\" pop-up." ); label = new JLabel( Util.getAdmLabel( "_admin_presented_as_the_choice_to_the_user_in_the_Data_save_pop-up.")); showInstruction(m_gbl, m_gbc, 0, 1, 7, label); showInstruction(m_gbl, m_gbc, 0, 2, 1, new JLabel("")); label = new JLabel(Util.getAdmLabel("_adm_LABEL")); label.setForeground(Color.black); m_gbc.gridx = 1; m_gbc.gridy = 2; m_gbc.ipadx = 10; m_gbl.setConstraints(label, m_gbc); m_pnlDisplay.add(label); label = new JLabel(" "); m_gbc.gridx = 2; m_gbc.gridy = 2; m_gbc.ipadx = 0; // reset to default m_gbc.gridwidth = 5; m_gbl.setConstraints(label, m_gbc); // add( label ); showInstruction(m_gbl, m_gbc, 2, 2, 1, new JLabel(Util.getAdmLabel("_admin_TEMPLATE"))); m_nRow = 3; m_bDefaultFile = bDefaultFile; m_objTxfValue.clearArrays(); displayNewTxf(strPath); m_pnlDisplay.setBorder( new CompoundBorder( BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
/** * Add a border of a particular style to a component * * @param c : JComponent to add border to * @param borderType : type of border, BD_x * @param label : if not null, string to display at top of border * @param labelAlignment : if label defined, this determines its horizontal alignment */ public static void addBorder(JComponent c, int borderType, String label, int labelAlignment) { final Border[] b = { // #0: empty, spacing of 2 BorderFactory.createEmptyBorder(2, 2, 2, 2), // #1: lowered etched, interior spacing of 2 BorderFactory.createCompoundBorder( BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), BorderFactory.createEmptyBorder(2, 2, 2, 2)), // BorderFactory.createLineBorder(Color.red,3), }; Tools.ASSERT(!(label != null && borderType < 0)); if (label != null) { TitledBorder t = BorderFactory.createTitledBorder(b[borderType], label); int tbAlign = 0; switch (labelAlignment) { default: tbAlign = TitledBorder.LEFT; break; case SwingConstants.CENTER: tbAlign = TitledBorder.CENTER; break; case SwingConstants.RIGHT: tbAlign = TitledBorder.RIGHT; break; } t.setTitleJustification(tbAlign); c.setBorder(t); } else { if (borderType >= 0) { c.setBorder(b[borderType]); } } }
protected void layoutUIComponents(String strPath, boolean bDefaultFile) { // gbc.weightx = 0.5; showInstructions(m_gbl, m_gbc, 0, 0, 7, infoLabel1); showInstructions(m_gbl, m_gbc, 0, 1, 7, infoLabel2); showInstructions(m_gbl, m_gbc, 0, 2, 7, infoLabel3); /*showInstructions( gbl, gbc, 0, 3, 7, infoLabel4 ); showInstructions( gbl, gbc, 0, 4, 7, infoLabel5 );*/ showInstructions(m_gbl, m_gbc, 0, 5, 1, new JLabel("")); // i18n // label = new JLabel( "LABEL" ); label = new JLabel(Util.getAdmLabel("_adm_LABEL")); label.setForeground(Color.black); m_gbc.gridx = 1; m_gbc.gridy = 5; // gbc.ipadx = 10; m_gbl.setConstraints(label, m_gbc); m_pnlDisplay.add(label); label = new JLabel(" "); m_gbc.gridx = 2; m_gbc.gridy = 5; m_gbc.ipadx = 0; m_gbc.gridwidth = 5; m_gbc.weightx = 0; m_gbl.setConstraints(label, m_gbc); // add( label ); // i18n // showInstructions( m_gbl, m_gbc, 2, 5, 1, new JLabel( "DIRECTORY" )); showInstructions(m_gbl, m_gbc, 2, 5, 1, new JLabel(Util.getAdmLabel("_adm_DIRECTORY"))); m_nRow = 5; m_bDefaultFile = bDefaultFile; m_objTxfValue.clearArrays(); displayNewTxf(strPath); m_pnlDisplay.setBorder( new CompoundBorder( // i18n // BorderFactory.createTitledBorder( " Parent Directories "), BorderFactory.createTitledBorder(Util.getAdmLabel("_adm_Parent_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
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); }
protected void initComponents() { this.setLayout(new BorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); // Check + name this.selectCheckBox = new JCheckBox(this.retrievable.getName()); this.selectCheckBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (((JCheckBox) e.getSource()).isSelected() && sector != null) updateDescription(sector); } }); this.add(this.selectCheckBox, BorderLayout.WEST); // Description (size...) this.descriptionLabel = new JLabel(); this.add(this.descriptionLabel, BorderLayout.EAST); }
public void setUseFlatUI(boolean b) { main.setContentAreaFilled(!b); main.setFocusPainted(!b); main.setBorderPainted(!b); main.setMargin(new Insets(1, 1, 1, 1)); popper.setContentAreaFilled(!b); popper.setFocusPainted(!b); popper.setBorderPainted(!b); popper.setMargin(new Insets(1, 1, 1, 1)); setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); setOpaque(false); MouseAdapter ma = new MouseAdapter() { public void mouseEntered(MouseEvent e) { main.setContentAreaFilled(true); main.setBackground(new Color(216, 240, 254)); // m.getMainButton().setForeground( Color.black ); setBorder(new LineBorder(new Color(200, 200, 200), 1)); setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); popper.setBackground(new Color(242, 242, 242)); popper.setContentAreaFilled(true); popper.setBorder(menu.getBorder()); } public void mouseExited(MouseEvent e) { main.setContentAreaFilled(false); // c.setForeground( Color.black ); setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); setCursor(Cursor.getDefaultCursor()); popper.setContentAreaFilled(false); popper.setBorder(null); } }; main.addMouseListener(ma); popper.addMouseListener(ma); }
private void initButton() { int actionCommandId = 1; for (int i = 0; i < 6; i++) { for (int j = 0; j < 7; j++) { JButton numberButton = new JButton(); numberButton.setBorder(BorderFactory.createEmptyBorder()); numberButton.setHorizontalAlignment(SwingConstants.CENTER); numberButton.setActionCommand(String.valueOf(actionCommandId)); numberButton.addMouseListener(this); numberButton.setBackground(palletTableColor); numberButton.setForeground(dateFontColor); numberButton.setText(String.valueOf(actionCommandId)); numberButton.setPreferredSize(new Dimension(25, 25)); daysButton[i][j] = numberButton; actionCommandId++; } } }
protected JPanel makeDetailHintControlPanel() { JPanel controlPanel = new JPanel(new BorderLayout(0, 10)); controlPanel.setBorder( new CompoundBorder( BorderFactory.createEmptyBorder(9, 9, 9, 9), new TitledBorder("Detail Hint"))); JPanel elevationSliderPanel = new JPanel(new BorderLayout(0, 5)); { int MIN = -10; int MAX = 10; int cur = 0; JSlider slider = new JSlider(MIN, MAX, cur); slider.setMajorTickSpacing(10); slider.setMinorTickSpacing(1); slider.setPaintTicks(true); Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>(); labelTable.put(-10, new JLabel("-1.0")); labelTable.put(0, new JLabel("0.0")); labelTable.put(10, new JLabel("1.0")); slider.setLabelTable(labelTable); slider.setPaintLabels(true); slider.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { double hint = ((JSlider) e.getSource()).getValue() / 10d; setWedgeDetailHint(hint); getWwd().redraw(); } }); elevationSliderPanel.add(slider, BorderLayout.SOUTH); } JPanel sliderPanel = new JPanel(new GridLayout(2, 0)); sliderPanel.add(elevationSliderPanel); controlPanel.add(sliderPanel, BorderLayout.SOUTH); return controlPanel; }
public void init() { jf.setLayout(new GridLayout(2, 4)); // 使用静态工厂方法创建BevelBorder Border bb = BorderFactory.createBevelBorder( BevelBorder.RAISED, Color.RED, Color.GREEN, Color.BLUE, Color.GRAY); jf.add(getPanelWithBorder(bb, "BevelBorder")); // 使用静态工厂方法创建LineBorder Border lb = BorderFactory.createLineBorder(Color.ORANGE, 10); jf.add(getPanelWithBorder(lb, "LineBorder")); // 使用静态工厂方法创建EmptyBorder,EmptyBorder就是在组件四周留空 Border eb = BorderFactory.createEmptyBorder(20, 5, 10, 30); jf.add(getPanelWithBorder(eb, "EmptyBorder")); // 使用静态工厂方法创建EtchedBorder Border etb = BorderFactory.createEtchedBorder(EtchedBorder.RAISED, Color.RED, Color.GREEN); jf.add(getPanelWithBorder(etb, "EtchedBorder")); // 直接创建TitledBorder,TitledBorder边框就是为原有的边框增加标题 TitledBorder tb = new TitledBorder( lb, "测试标题", TitledBorder.LEFT, TitledBorder.BOTTOM, new Font("StSong", Font.BOLD, 18), Color.BLUE); jf.add(getPanelWithBorder(tb, "TitledBorder")); // 直接创建MatteBorder,MatteBorder边框是EmptyBorder的子类, // 它可以指定留空区域的颜色或背景,此处是指定颜色 MatteBorder mb = new MatteBorder(20, 5, 10, 30, Color.GREEN); jf.add(getPanelWithBorder(mb, "MatteBorder")); // 直接创建CompoundBorder,CompoundBorder边框将两个边框组合成新边框 CompoundBorder cb = new CompoundBorder(new LineBorder(Color.RED, 8), tb); jf.add(getPanelWithBorder(cb, "CompoundBorder")); jf.pack(); jf.setVisible(true); }
private Border createTitleBorder(String title) { TitledBorder b = BorderFactory.createTitledBorder(title); // b.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); return new CompoundBorder(b, BorderFactory.createEmptyBorder(10, 10, 10, 10)); }