private void initLayout() { displayPanel.setLayout(new BoxLayout(displayPanel, BoxLayout.LINE_AXIS)); JPanel subPanel = new JPanel(); subPanel.setLayout(new BoxLayout(subPanel, BoxLayout.PAGE_AXIS)); robotButton = new JButton("Robot"); robotButton.addActionListener(this); subPanel.add(robotButton); robotMenu = new JPopupMenu(); robotMenu.addPopupMenuListener(this); subPanel.add(robotMenu); subPanel.add(Box.createRigidArea(new Dimension(10, 10))); createUpdateButtons(subPanel); createStreamingButtons(subPanel); displayPanel.add(subPanel); subPanel = new JPanel(); subPanel.setLayout(new BoxLayout(subPanel, BoxLayout.PAGE_AXIS)); subPanel.add(Box.createHorizontalGlue()); subPanel.add(imagePanel); displayPanel.add(subPanel); }
/** * Create the XPath task pane * * @return XPath task pane */ private JPanel createXpathExtractorTasksPanel() { Box xpathActionPanel = Box.createVerticalBox(); Box selectorAndButton = Box.createHorizontalBox(); Border margin = new EmptyBorder(5, 5, 0, 5); xpathActionPanel.setBorder(margin); xpathExpressionField = new JLabeledTextField(JMeterUtils.getResString("xpath_tester_field")); // $NON-NLS-1$ JButton xpathTester = new JButton(JMeterUtils.getResString("xpath_tester_button_test")); // $NON-NLS-1$ xpathTester.setActionCommand(XPATH_TESTER_COMMAND); xpathTester.addActionListener(this); selectorAndButton.add(xpathExpressionField); selectorAndButton.add(xpathTester); xpathActionPanel.add(selectorAndButton); xpathActionPanel.add(xmlConfPanel); xpathActionPanel.add(getFragment); xpathResultField = new JTextArea(); xpathResultField.setEditable(false); xpathResultField.setLineWrap(true); xpathResultField.setWrapStyleWord(true); JPanel xpathTasksPanel = new JPanel(new BorderLayout(0, 5)); xpathTasksPanel.add(xpathActionPanel, BorderLayout.NORTH); xpathTasksPanel.add(GuiUtils.makeScrollPane(xpathResultField), BorderLayout.CENTER); return xpathTasksPanel; }
public void run() { // set the icon image and layout manager of the rootPane f.setIconImage(Program.windowIcon); f.setLayout(new BorderLayout()); // set component borders mainBox.setBorder(new EmptyBorder(new Insets(5, 10, 10, 5))); // set component alignment rawEncLabel.setAlignmentX(Component.LEFT_ALIGNMENT); gapEncLabel.setAlignmentX(Component.LEFT_ALIGNMENT); huffEncLabel.setAlignmentX(Component.LEFT_ALIGNMENT); vbEncLabel.setAlignmentX(Component.LEFT_ALIGNMENT); mainBox.add(rawEncLabel); mainBox.add(gapEncLabel); mainBox.add(vbEncLabel); mainBox.add(huffEncLabel); f.add(mainBox, BorderLayout.CENTER); // final setup and show of the window f.pack(); f.setSize(250, f.getSize().height); f.setLocationByPlatform(true); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setVisible(true); }
public AboutDialog(View view) { super(view, jEdit.getProperty("about.title"), true); JPanel content = new JPanel(new BorderLayout()); content.setBorder(new EmptyBorder(12, 12, 12, 12)); setContentPane(content); content.add(BorderLayout.CENTER, new AboutPanel()); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.setBorder(new EmptyBorder(12, 0, 0, 0)); buttonPanel.add(Box.createGlue()); close = new JButton(jEdit.getProperty("common.close")); close.addActionListener(new ActionHandler()); getRootPane().setDefaultButton(close); buttonPanel.add(close); buttonPanel.add(Box.createGlue()); content.add(BorderLayout.SOUTH, buttonPanel); pack(); setResizable(false); setLocationRelativeTo(view); show(); }
/** * Adds fill components to empty cells in the first row and first column of the grid. This ensures * that the grid spacing will be the same as shown in the designer. * * @param cols an array of column indices in the first row where fill components should be added. * @param rows an array of row indices in the first column where fill components should be added. */ void addFillComponents(Container panel, int[] cols, int[] rows) { Dimension filler = new Dimension(10, 10); boolean filled_cell_11 = false; CellConstraints cc = new CellConstraints(); if (cols.length > 0 && rows.length > 0) { if (cols[0] == 1 && rows[0] == 1) { /** add a rigid area */ panel.add(Box.createRigidArea(filler), cc.xy(1, 1)); filled_cell_11 = true; } } for (int index = 0; index < cols.length; index++) { if (cols[index] == 1 && filled_cell_11) { continue; } panel.add(Box.createRigidArea(filler), cc.xy(cols[index], 1)); } for (int index = 0; index < rows.length; index++) { if (rows[index] == 1 && filled_cell_11) { continue; } panel.add(Box.createRigidArea(filler), cc.xy(1, rows[index])); } }
/** * Create the JMeter tool bar pane containing the running indicator. * * @return a panel containing the running indicator */ protected Component createToolBar() { Box toolPanel = new Box(BoxLayout.X_AXIS); toolPanel.add(Box.createRigidArea(new Dimension(10, 15))); toolPanel.add(Box.createGlue()); toolPanel.add(runningIndicator); return toolPanel; }
Dec newDeclaration( boolean isPointer, boolean isParameter, boolean isArray, int index, int temptype, String tempname, String value) { Dec dec = new Dec( structPanel.struktor.presets, isPointer, isParameter, isArray, index, temptype, tempname, value); decList.addElement(dec); Tracer.out("New Dec set ..."); decListPanel.add(dec); decListPanel.validate(); dec.setVisible(true); revalidate(); return dec; }
public PlayerView(String player) { playerName = new String(player); // Set-Up Top of Score Area namePanel = new JPanel(); nameText = new JLabel(player); nameText.setFont(ScoreFont); namePanel.setLayout(new BorderLayout()); namePanel.add(nameText, BorderLayout.CENTER); scorePanel = new JPanel(); scoreText = new JLabel(" 0"); scoreText.setFont(ScoreFont); scorePanel.setLayout(new BorderLayout()); scorePanel.add(scoreText, BorderLayout.CENTER); topPanel = new JPanel(); BoxLayout layout = new BoxLayout(topPanel, BoxLayout.LINE_AXIS); topPanel.setLayout(layout); topPanel.add(namePanel); topPanel.add(Box.createRigidArea(new Dimension(10, 0))); topPanel.add(scorePanel); topPanel.add(Box.createRigidArea(new Dimension(10, 0))); // Create bordering for top panel Border raisedBevel, loweredBevel, compound; raisedBevel = BorderFactory.createRaisedBevelBorder(); loweredBevel = BorderFactory.createLoweredBevelBorder(); compound = BorderFactory.createCompoundBorder(raisedBevel, loweredBevel); topPanel.setBorder(compound); // Set-Up area to display word list wordPanel = new JPanel(); Border etched = BorderFactory.createEtchedBorder(); TitledBorder etchedTitle = BorderFactory.createTitledBorder(etched, "Word List"); etchedTitle.setTitleJustification(TitledBorder.RIGHT); wordPanel.setBorder(etchedTitle); myWordList = new ExpandableList(); myWordList.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String word = e.getActionCommand(); java.util.List<BoardCell> list = myFinder.cellsForWord(myBoard, word); myBoardPanel.highlightDice(list); } }); wordPanel.add( new JScrollPane( myWordList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); setLayout(new BorderLayout(30, 30)); add(topPanel, BorderLayout.NORTH); add(wordPanel, BorderLayout.CENTER); }
public HelpUI(Frame parent, String title) { sidebar = new Sidebar(); sidebar.setBorder(new EmptyBorder(10, 10, 10, 10)); infoView = new JTextPane(); Dimension d1 = sidebar.getPreferredSize(); infoView.setPreferredSize(new Dimension(d1.width * 3, d1.height - 5)); infoView.setEditable(false); MouseAdapter ma = new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { SidebarOption sopt = (SidebarOption) me.getComponent(); if (sel != null) { sel.setSelected(false); sel.repaint(); } sel = sopt; sel.setSelected(true); sel.repaint(); renderInfo(); } }; general = new SidebarOption("General Info", HELP_GENERAL_LOC); general.addMouseListener(ma); sidebar.add(general); sidebar.add(Box.createVerticalStrut(scy(10))); artifact = new SidebarOption("Artifacts", HELP_ARTIFACTS_LOC); artifact.addMouseListener(ma); sidebar.add(artifact); sidebar.add(Box.createVerticalStrut(scy(10))); net = new SidebarOption("Networking", HELP_NET_LOC); net.addMouseListener(ma); sidebar.add(net); sidebar.add(Box.createVerticalStrut(scy(10))); gpl = new SidebarOption("License", HELP_GPL_LOC); gpl.addMouseListener(ma); sidebar.add(gpl); general.setSelected(true); sel = general; sidebar.add(Box.createVerticalGlue()); add(BorderLayout.WEST, sidebar); add(BorderLayout.CENTER, new JScrollPane(infoView)); setResizable(false); pack(); setLocationRelativeTo(parent); setTitle(title); renderInfo(); }
private Component createOptionsPanel() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); hideButton = new JButton( new AbstractAction("Hide") { public void actionPerformed(ActionEvent e) { hideSelected(); } }); showButton = new JButton( new AbstractAction("Show") { public void actionPerformed(ActionEvent e) { showSelected(); } }); panel.add(showButton); panel.add(Box.createHorizontalStrut(10)); panel.add(hideButton); panel.add(Box.createHorizontalGlue()); panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); return panel; }
public ActionBar(View view, boolean temp) { setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.view = view; this.temp = temp; add(Box.createHorizontalStrut(2)); JLabel label = new JLabel(jEdit.getProperty("view.action.prompt")); add(label); add(Box.createHorizontalStrut(12)); add(action = new ActionTextField()); action.setEnterAddsToHistory(false); Dimension max = action.getPreferredSize(); max.width = Integer.MAX_VALUE; action.setMaximumSize(max); action.addActionListener(new ActionHandler()); action.getDocument().addDocumentListener(new DocumentHandler()); if (temp) { close = new RolloverButton(GUIUtilities.loadIcon("closebox.gif")); close.addActionListener(new ActionHandler()); close.setToolTipText(jEdit.getProperty("view.action.close-tooltip")); add(close); } this.temp = temp; }
/** * Introduce the Scout449 program! * * @param stat the Scout449 responsible for this object */ public Intro(Scout449 stat) { super("Loading Scout449"); setVisible(false); setUndecorated(true); setIconImage(stat.getImage("winicon")); loadImage(); getRootPane().putClientProperty("Window.shadow", Boolean.FALSE); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); Container c = getContentPane(); c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS)); c.add(Box.createVerticalGlue()); Loading load = new Loading(); load.setOpaque(true); load.setAlignmentX(JComponent.CENTER_ALIGNMENT); c.add(load); setCursor(Constants.WAIT); c.add(Box.createVerticalGlue()); // center the window Dimension ss = AppLib.winInfo.getScreenSize(); setBounds( (ss.width - Constants.INTRO_WIDTH) / 2, (ss.height - Constants.INTRO_HEIGHT) / 2, Constants.INTRO_WIDTH, Constants.INTRO_HEIGHT); setVisible(true); }
protected JComponent createCenterPanel() { JPanel contentPanel = new JPanel(new BorderLayout()); Box mainPanel = Box.createHorizontalBox(); myClassFilterEditor = new ClassFilterEditor( myProject, myChooserFilter, "reference.viewBreakpoints.classFilters.newPattern"); myClassFilterEditor.setPreferredSize(new Dimension(400, 200)); myClassFilterEditor.setBorder( IdeBorderFactory.createTitledBorder( DebuggerBundle.message("class.filters.dialog.inclusion.filters.group"), false, false, true)); mainPanel.add(myClassFilterEditor); myClassExclusionFilterEditor = new ClassFilterEditor( myProject, myChooserFilter, "reference.viewBreakpoints.classFilters.newPattern"); myClassExclusionFilterEditor.setPreferredSize(new Dimension(400, 200)); myClassExclusionFilterEditor.setBorder( IdeBorderFactory.createTitledBorder( DebuggerBundle.message("class.filters.dialog.exclusion.filters.group"), false, false, true)); mainPanel.add(myClassExclusionFilterEditor); contentPanel.add(mainPanel, BorderLayout.CENTER); return contentPanel; }
/** Default constructor for the demo. */ public IconDemoApp() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("Icon Demo: Please Select an Image"); // A label for displaying the pictures photographLabel.setVerticalTextPosition(JLabel.BOTTOM); photographLabel.setHorizontalTextPosition(JLabel.CENTER); photographLabel.setHorizontalAlignment(JLabel.CENTER); photographLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // We add two glue components. Later in process() we will add thumbnail buttons // to the toolbar inbetween thease glue compoents. This will center the // buttons in the toolbar. buttonBar.add(Box.createGlue()); buttonBar.add(Box.createGlue()); add(buttonBar, BorderLayout.SOUTH); add(photographLabel, BorderLayout.CENTER); setSize(400, 300); // this centers the frame on the screen setLocationRelativeTo(null); // start the image loading SwingWorker in a background thread loadimages.execute(); }
public UnitListInternalFrame(String Title, Vector<Unit> units, UnitChangeListener ucl) { super(Title, true, true, true, true); m_UnitListPanel = new UnitListPanel(units); m_UnitListPanel.addUnitChangeListener(ucl); getContentPane().setLayout(new BorderLayout()); // m_UnitListPanel.setFocusable(false); getContentPane().add(m_UnitListPanel, BorderLayout.CENTER); m_ButtonPanel.setBorder(BorderFactory.createEtchedBorder()); m_ButtonPanel.setLayout(new BoxLayout(m_ButtonPanel, BoxLayout.X_AXIS)); m_NewButton.setAlignmentY(Component.CENTER_ALIGNMENT); m_NewButton.setActionCommand("New"); m_NewButton.addActionListener(this); m_RemoveButton.setAlignmentY(Component.CENTER_ALIGNMENT); m_RemoveButton.setActionCommand("Remove"); m_RemoveButton.addActionListener(this); m_EditButton.setAlignmentY(Component.CENTER_ALIGNMENT); m_EditButton.setActionCommand("Edit"); m_EditButton.addActionListener(this); m_ButtonPanel.add(m_NewButton); m_ButtonPanel.add(m_EditButton); m_ButtonPanel.add(Box.createHorizontalBox()); m_ButtonPanel.add(m_RemoveButton); m_ButtonPanel.add(Box.createHorizontalGlue()); getContentPane().add(m_ButtonPanel, BorderLayout.SOUTH); }
/** @return A Box for selecting an asset type, the old asset and its replacement asset. */ private Box assetChoiceBox() { TreeSet<String> types = new TreeSet<String>(); types.add(AssetType.CHARACTER.toString()); types.add(AssetType.PROP.toString()); types.add(AssetType.SET.toString()); // JDrawer toReturn; Box hbox = new Box(BoxLayout.X_AXIS); { JCollectionField assetType = UIFactory.createCollectionField(types, diag, sTSize); assetType.setActionCommand("type"); assetType.addActionListener(this); JCollectionField oldAsset = UIFactory.createCollectionField(charList.keySet(), diag, sVSize); JCollectionField newAsset = UIFactory.createCollectionField(charList.keySet(), diag, sVSize); hbox.add(assetType); hbox.add(Box.createHorizontalStrut(10)); hbox.add(oldAsset); hbox.add(Box.createHorizontalStrut(5)); hbox.add(newAsset); // pPotentials.put(oldAsset, newAsset); } list.add(Box.createVerticalStrut(5)); return hbox; // toReturn; } // return assetChoiceBox
public Oczy() { super("Oczy"); setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new BorderLayout()); oczy = new OczyPanel(); add(oczy, BorderLayout.CENTER); JPanel toolBar = new JPanel(); toolBar.setBackground(new Color(0, 200, 0)); toolBar.add(Box.createHorizontalGlue()); JButton b1 = new JButton("Kolor oczu"); b1.setBackground(new Color(0, 150, 0)); b1.setMnemonic('k'); toolBar.add(b1); JButton b2 = new JButton("Kolor źrenic"); b2.setBackground(new Color(0, 150, 0)); b2.setMnemonic('o'); toolBar.add(b2); JButton b3 = new JButton("Kolor tła"); b3.setBackground(new Color(0, 150, 0)); b3.setMnemonic('t'); toolBar.add(b3); toolBar.add(Box.createHorizontalGlue()); add(toolBar, BorderLayout.NORTH); pack(); setVisible(true); addMou }
public ReceiveAddressDialog(JDialog parent) { super(parent, "Receive Addresses", Dialog.ModalityType.DOCUMENT_MODAL); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); tableModel = new AddressTableModel(columnNames, columnClasses); table = new AddressTable(tableModel, columnTypes); table.setRowSorter(new TableRowSorter<>(tableModel)); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scrollPane = new JScrollPane(table); JPanel tablePane = new JPanel(); tablePane.setBackground(Color.WHITE); tablePane.add(Box.createGlue()); tablePane.add(scrollPane); tablePane.add(Box.createGlue()); JPanel buttonPane = new ButtonPane( this, 10, new String[] {"New", "new"}, new String[] {"Copy", "copy"}, new String[] {"Edit", "edit"}, new String[] {"Done", "done"}); buttonPane.setBackground(Color.white); JPanel contentPane = new JPanel(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); contentPane.setOpaque(true); contentPane.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15)); contentPane.setBackground(Color.WHITE); contentPane.add(tablePane); contentPane.add(buttonPane); setContentPane(contentPane); }
/** * Description: <br> * Copyright (C), 2005-2008, Yeeku.H.Lee <br> * This program is protected by copyright laws. <br> * Program Name: <br> * Date: * * @author Yeeku.H.Lee [email protected] * @version 1.0 */ public class TestBoxSpace { private Frame f = new Frame("测试"); // 定义水平摆放组件的Box对象 private Box horizontal = Box.createHorizontalBox(); // 定义垂直摆放组件的Box对象 private Box vertical = Box.createVerticalBox(); public void init() { horizontal.add(new Button("水平按钮一")); horizontal.add(Box.createHorizontalGlue()); horizontal.add(new Button("水平按钮二")); // 水平方向不可拉伸的间距,其宽度为10px horizontal.add(Box.createHorizontalStrut(10)); horizontal.add(new Button("水平按钮三")); vertical.add(new Button("垂直按钮一")); vertical.add(Box.createVerticalGlue()); vertical.add(new Button("垂直按钮二")); // 垂直方向不可拉伸的间距,其高度为10px vertical.add(Box.createVerticalStrut(10)); vertical.add(new Button("垂直按钮三")); f.add(horizontal, BorderLayout.NORTH); f.add(vertical); f.pack(); f.setVisible(true); } public static void main(String[] args) { new TestBoxSpace().init(); } }
private JTabbedPane createTab() { Font mainFont = new Font("Times New Roman", Font.BOLD, 11); tabbedPane.setFont(mainFont); tabbedPane.setBorder(new BevelBorder(BevelBorder.LOWERED)); tabbedPane.add("New application", new NewAppPanel()); JPanel existingApp = new JPanel(); existingApp.setLayout(new BoxLayout(existingApp, BoxLayout.X_AXIS)); JLabel pictureLabel = new JLabel("Configuration:"); JButton pictureChooser = new JButton("Choose"); pictureFileName.setEditable(false); pictureFileName.setMaximumSize(new Dimension(contentPane.getPreferredSize().width, 25)); existingApp.add(Box.createHorizontalStrut(20)); existingApp.add(pictureLabel); existingApp.add(pictureFileName); existingApp.add(Box.createHorizontalStrut(5)); existingApp.add(pictureChooser); existingApp.add(Box.createHorizontalStrut(20)); pictureChooser.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { loadFromFile(); } }); tabbedPane.add("Existing application", existingApp); tabbedPane.setPreferredSize(contentPane.getPreferredSize()); return tabbedPane; }
/** Layout the GUI components of this Folder. */ private void layoutComponents() { // clear the box box.removeAll(); // add the heading if one has been specified if (heading != null) { if (LOG.isDebugEnabled()) { LOG.debug(Messages.getString(BUNDLE_NAME, "Folder.0")); // $NON-NLS-1$ } JLabel p1 = new JLabel(heading); box.add(p1); } // add the tabbed pane if there is more than 1 tab if (dataItems.size() > 1) { box.add(tabbedPane); } else if (dataItems.size() == 1) { // otherwise add the single tab as the main component DataItem item = (DataItem) dataItems.elementAt(0); box.add(item); } validate(); repaint(); }
public Flexible copyToGroup(String group) { String newName; if (group.equals(nullString)) newName = Group.substractObjectName(getName()); else newName = group + Constants.GROUP_SEPARATOR + Group.substractObjectName(getName()); // object with new name already exists, add suffix ///!!! while (Group.getRoot().findObject(newName, true) != null) newName = StringUtils.incrementName(newName, Constants.COPY_SUFFIX); Box grBox = new Box( newName, null, startVertex.getX(), startVertex.getY(), endVertex.getX(), endVertex.getY()); grBox.setColor(getColor()); Group.getRoot().addSubObject(newName, grBox, true); // ViewState view = ViewState.getInstance(); // grBox.move(20 - view.getRx(), 20 - view.getRy()); unconditionalValidation(); return grBox; }
public void setEntity(java.lang.Object ent) { Method[] methods = ent.getClass().getDeclaredMethods(); box.removeAll(); for (Method m : methods) { if (m.getName().toLowerCase().startsWith("get")) { String attName = m.getName().substring(3); Object result; try { result = m.invoke(ent, new Object[] {}); String value = "null"; if (result != null) value = result.toString(); JPanel attPane = new JPanel(new FlowLayout(FlowLayout.LEFT)); attPane.add(new JLabel(attName + " : " + m.getReturnType().getName() + " = " + value)); box.add(attPane); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } }
private Box box(int levelCount, int pixelCount) { Box box = new Box(Y_AXIS); box.add(createVerticalStrut(pixelCount)); // create the nested component recursively box.add(buildNestedScrollPanes(levelCount - 1, pixelCount)); return box; }
public void addLayer(Layer layer, boolean showOnButtonList, String icon) { if (layer instanceof MapViewerLayer) { minZoom = Math.max(((MapViewerLayer) layer).getMinZoomLevel(), getMinZoom()); maxZoom = Math.min(((MapViewerLayer) layer).getMaxZoomLevel(), getMaxZoom()); if (zoomFactor > maxZoom || zoomFactor < minZoom) { zoomFactor = (maxZoom + minZoom) / 2; } zoomTo(center, zoom2Scale(zoomFactor)); } if (showOnButtonList) { JToggleButton b = new JToggleButton(layer.name, LogicConstants.getIcon(icon), layer.visible); // b.setVerticalTextPosition(SwingConstants.BOTTOM); // b.setHorizontalTextPosition(SwingConstants.CENTER); b.setActionCommand(layer.name); b.addActionListener(layerControlListener); layerControls.add(b); layerControlPanel.removeAll(); layerControlPanel.add(Box.createHorizontalStrut(10)); for (JToggleButton bt : layerControls) { layerControlPanel.add(bt); layerControlPanel.add(Box.createHorizontalGlue()); } layerControlPanel.updateUI(); } super.addLayer(layer); }
@Override public Component getTableCellEditorComponent( JTable table, Object value, boolean isSelected, int row, int column) { cellPanel.removeAll(); TableCellUtilities.setToRowBackground(cellPanel, table, row); cellLabel.setForeground(table.getForeground()); cellLabel.setFont(table.getFont()); if (row == levels.getSize() - 1) { cellLabel.setText(value.toString()); cellPanel.add(cellLabel); cellPanel.add(Box.createHorizontalGlue()); cellPanel.add(removeLevelButton); } else if (row == levels.getSize()) { cellLabel.setText("Add Level"); cellPanel.add(Box.createHorizontalGlue()); cellPanel.add(cellLabel); cellPanel.add(Box.createHorizontalStrut(3)); addLevelButton.setEnabled(classComboBox.getSelectedItem() != null); cellPanel.add(addLevelButton); } else { cellLabel.setText(value.toString()); cellPanel.add(cellLabel); } return cellPanel; }
private void generateContent(JPanel buttonJP) { buttonJP.setLayout(new BoxLayout(buttonJP, BoxLayout.LINE_AXIS)); buttonJP.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); JButton save = new JButton("Save"); save.setSize(100, 50); save.setMaximumSize(save.getSize()); save.addMouseListener(generateSaveMouseListener()); save.setFocusable(false); JButton load = new JButton("Load"); load.setSize(100, 50); load.setMaximumSize(load.getSize()); load.addMouseListener(generateLoadMouseListener()); load.setFocusable(false); this.fileNameTF = new JTextField(); this.fileNameTF.setSize(190, 50); this.fileNameTF.setMaximumSize(this.fileNameTF.getSize()); this.fileNameTF.setText("Mr.Freezer"); buttonJP.add(save); buttonJP.add(Box.createRigidArea(new Dimension(10, 0))); buttonJP.add(load); buttonJP.add(Box.createRigidArea(new Dimension(10, 0))); buttonJP.add(this.fileNameTF); }
public LayeredPaneDemo2() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); // Create and load the duke icon. final ImageIcon icon = createImageIcon("images/dukeWaveRed.gif"); // Create and set up the layered pane. layeredPane = new JLayeredPane(); layeredPane.setPreferredSize(new Dimension(300, 310)); layeredPane.setBorder(BorderFactory.createTitledBorder("Move the Mouse to Move Duke")); layeredPane.addMouseMotionListener(this); // Add several labels to the layered pane. layeredPane.setLayout(new GridLayout(2, 3)); for (int i = 0; i < layerStrings.length; i++) { JLabel label = createColoredLabel(layerStrings[i], layerColors[i]); layeredPane.add(label, new Integer(i)); } // Create and add the Duke label to the layered pane. dukeLabel = new JLabel(icon); if (icon == null) { System.err.println("Duke icon not found; using black rectangle instead."); dukeLabel.setOpaque(true); dukeLabel.setBackground(Color.BLACK); } layeredPane.add(dukeLabel, new Integer(2), 0); // Add control pane and layered pane to this JPanel. add(Box.createRigidArea(new Dimension(0, 10))); add(createControlPanel()); add(Box.createRigidArea(new Dimension(0, 10))); add(layeredPane); }
/** * Creates a new wait dialog with the specified information * * @param owner Parent frame of the new dialog * @param title Title of the dialog * @param message Message to be displayed within the dialog. */ public WaitDialog(Frame owner, String title, String message) { super(owner, title, false); this.title = title; this.message = message; this.setSize(300, 150); JPanel contentPanel = new JPanel(); contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS)); contentPanel.add(Box.createVerticalGlue()); JLabel messageLabel = new JLabel(message); messageLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT); contentPanel.add(messageLabel); contentPanel.add(Box.createVerticalStrut(10)); JProgressBar waitBar = new JProgressBar(); waitBar.setIndeterminate(true); waitBar.setAlignmentX(JProgressBar.CENTER_ALIGNMENT); JPanel waitBarPanel = new JPanel(); waitBarPanel.setOpaque(false); waitBarPanel.setLayout(new BoxLayout(waitBarPanel, BoxLayout.X_AXIS)); waitBarPanel.add(Box.createHorizontalGlue()); waitBarPanel.add(waitBar); waitBarPanel.add(Box.createHorizontalGlue()); contentPanel.add(waitBarPanel); contentPanel.add(Box.createVerticalGlue()); this.add(contentPanel); this.setLocationRelativeTo(owner); }
/** * Shows a dialog request to enter text in a multiline text field <br> * Though not all text might be visible, everything entered is delivered with the returned text * <br> * The main purpose for this feature is to allow pasting text from somewhere preserving line * breaks <br> * * @param msg the message to display. * @param title the title for the dialog (default: Sikuli input request) * @param lines the maximum number of lines visible in the text field (default 9) * @param width the maximum number of characters visible in one line (default 20) * @return The user's input including the line breaks. */ public static String inputText(String msg, String title, int lines, int width) { width = Math.max(20, width); lines = Math.max(9, lines); if ("".equals(title)) { title = "Sikuli input request"; } JTextArea ta = new JTextArea(""); int w = width * ta.getFontMetrics(ta.getFont()).charWidth('m'); int h = (int) (lines * ta.getFontMetrics(ta.getFont()).getHeight()); ta.setPreferredSize(new Dimension(w, h)); ta.setMaximumSize(new Dimension(w, 2 * h)); JScrollPane sp = new JScrollPane(ta); sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); JTextArea tm = new JTextArea(msg); tm.setColumns(width); tm.setLineWrap(true); tm.setWrapStyleWord(true); tm.setEditable(false); tm.setBackground(new JLabel().getBackground()); JPanel pnl = new JPanel(); pnl.setLayout(new BoxLayout(pnl, BoxLayout.Y_AXIS)); pnl.add(sp); pnl.add(Box.createVerticalStrut(10)); pnl.add(tm); pnl.add(Box.createVerticalStrut(10)); if (0 == JOptionPane.showConfirmDialog(null, pnl, title, JOptionPane.OK_CANCEL_OPTION)) { return ta.getText(); } else { return ""; } }