public HeaderPanel(String heading) { super(); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.setBackground(background); JLabel panelLabel = new JLabel(" " + heading, SwingConstants.LEFT); Font labelFont = new Font("Dialog", Font.BOLD, 18); panelLabel.setFont(labelFont); this.add(panelLabel); this.add(Box.createHorizontalGlue()); refresh = new JButton("Refresh"); refresh.addActionListener(this); this.add(refresh); this.add(Box.createHorizontalStrut(5)); root = new JComboBox(); Dimension d = root.getPreferredSize(); d.width = 90; root.setPreferredSize(d); root.setMaximumSize(d); File[] roots = directoryPane.getRoots(); for (int i = 0; i < roots.length; i++) root.addItem(roots[i].getAbsolutePath()); this.add(root); root.setSelectedIndex(directoryPane.getCurrentRootIndex()); root.addActionListener(this); this.add(Box.createHorizontalStrut(17)); }
private void createComponents(JPanel p) { String tt = "Any of these: 45.5 -120.2 or 45 30 0 n 120 12 0 w or Seattle"; JComboBox field = new JComboBox(); field.setOpaque(false); field.setEditable(true); field.setLightWeightPopupEnabled(false); field.setPreferredSize(new Dimension(200, field.getPreferredSize().height)); field.setToolTipText(tt); JLabel label = new JLabel(ImageLibrary.getIcon("gov/nasa/worldwindow/images/safari-24x24.png")); // new // ImageIcon(getClass().getResource("gov/nasa/worldwindow/images/safari-24x24.png"))); label.setOpaque(false); label.setToolTipText(tt); p.add(label, BorderLayout.WEST); p.add(field, BorderLayout.CENTER); field.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { performGazeteerAction(actionEvent); } }); }
public GlobalControls() { setLayout(new GridBagLayout()); setBorder(new TitledBorder(new EtchedBorder(), "Global Controls")); aliasCB = createCheckBox("Anti-Aliasing", true, 0); renderCB = createCheckBox("Rendering Quality", false, 1); textureCB = createCheckBox("Texture", false, 2); compositeCB = createCheckBox("AlphaComposite", false, 3); screenCombo = new JComboBox(); screenCombo.setPreferredSize(new Dimension(120, 18)); screenCombo.setLightWeightPopupEnabled(true); screenCombo.setFont(font); for (int i = 0; i < screenNames.length; i++) { screenCombo.addItem(screenNames[i]); } screenCombo.addItemListener(this); Java2Demo.addToGridBag(this, screenCombo, 0, 4, 1, 1, 0.0, 0.0); toolBarCB = createCheckBox("Tools", false, 5); slider = new JSlider(JSlider.HORIZONTAL, 0, 200, 30); slider.addChangeListener(this); TitledBorder tb = new TitledBorder(new EtchedBorder()); tb.setTitleFont(font); tb.setTitle("Anim delay = 30 ms"); slider.setBorder(tb); slider.setMinimumSize(new Dimension(80, 46)); Java2Demo.addToGridBag(this, slider, 0, 6, 1, 1, 1.0, 1.0); texturechooser = new TextureChooser(0); Java2Demo.addToGridBag(this, texturechooser, 0, 7, 1, 1, 1.0, 1.0); }
public ReferencePropertyWidget(boolean containedByListReferenceGUI) { this.containedByListReferenceGUI = containedByListReferenceGUI; // get Options m_comboBox = new JComboBox(); m_comboBox.setEditable(false); m_comboBox.setPreferredSize(new Dimension(300, 20)); // m_comboBox.setMinimumSize(new Dimension(260, 20)); m_comboBox.setMaximumSize(new Dimension(Short.MAX_VALUE, 20)); KeyStroke controlT = KeyStroke.getKeyStroke("control SPACE"); getTextField().getInputMap().put(controlT, controlT); getTextField().getActionMap().put(controlT, new CodeCompleteAction()); ToolTipManager.sharedInstance().registerComponent(m_comboBox); }
// 构造器,用于初始化的登录对话框 public LoginFrame(LanTalk parent, String msg) { super(parent, "输入名字后登录", true); this.chatFrame = parent; setLayout(new GridLayout(5, 1)); JPanel jp = new JPanel(); tip = new JLabel(msg); tip.setFont(new Font("Serif", Font.BOLD, 16)); jp.add(tip); add(jp); add(getPanel("用户名", userField)); iconList.setPreferredSize(new Dimension(224, 20)); add(getPanel("图 标", iconList)); JPanel bp = new JPanel(); loginBn.addActionListener(new MyActionListener(this)); bp.add(loginBn); add(bp); pack(); setVisible(true); }
@Inject public ProblemSelectionPanel(qcevolutionbackend be) { this.setLayout(new BorderLayout()); backend = be; Set<String> probs = backend.getProbmanager().getAvailableProblems(); String[] options = new String[probs.size() + 1]; options[0] = "Please Select Problem"; int index = 1; Iterator<String> iter = probs.iterator(); while (iter.hasNext()) { options[index++] = iter.next(); } selection_model = new DefaultComboBoxModel(options); description = new JTextPane(); description.setEditable(false); description_scroller = new JScrollPane(description); description_scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); description_scroller.setPreferredSize(new Dimension(250, 155)); description_scroller.setMinimumSize(new Dimension(10, 10)); if (backend.getCurrentse() != null) { String key = backend.getQproblem().getName(); selection_model.setSelectedItem(key); description.setText(backend.getProbmanager().getSearchEngineDesc(key)); } Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); selection = new JComboBox(selection_model); selection.addActionListener(this); selection.setPreferredSize(new Dimension((int) (screenSize.width * MainPanel.right_perc), 30)); selection.setMaximumSize(new Dimension((int) (screenSize.width * MainPanel.right_perc), 30)); be.addObserver(this); be.getProbmanager().addObserver(this); if (null != backend.getCurrentse()) { backend.getCurrentse().addObserver(this); } this.add(selection, BorderLayout.NORTH); this.add(description_scroller, BorderLayout.CENTER); }
public void createGUI() { typeSelection = new JComboBox(MappingTypes.values()); fieldSelection = new JComboBox(columnsToBeMappedTo); literalEntry = new RoundedJTextField(10); literalEntry.setText("-"); // set the appearance for ach of the fields! UIHelper.renderComponent(typeSelection, UIHelper.VER_10_PLAIN, UIHelper.GREY_COLOR, false); UIHelper.setJComboBoxAsHeavyweight(typeSelection); UIHelper.renderComponent(fieldSelection, UIHelper.VER_10_PLAIN, UIHelper.GREY_COLOR, false); UIHelper.setJComboBoxAsHeavyweight(fieldSelection); UIHelper.renderComponent(literalEntry, UIHelper.VER_10_PLAIN, UIHelper.GREY_COLOR, false); typeSelection.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { if (typeSelection.getSelectedIndex() == -1) { typeSelection.setSelectedIndex(0); } showHideFields(); } }); fieldSelection.setPreferredSize(new Dimension(130, 25)); fieldDrop = createTableBrowseDropdown(fieldSelection); fieldDrop.setPreferredSize(new Dimension(160, 25)); changeableContentContainer = new JPanel(); changeableContentContainer.setLayout( new BoxLayout(changeableContentContainer, BoxLayout.LINE_AXIS)); changeableContentContainer.setPreferredSize(new Dimension(160, 25)); add(typeSelection); add(changeableContentContainer); if (preExistingMapping != null) { typeSelection.setSelectedItem(preExistingMapping.getType()); // check if columns available contains the item it is to be set to. if (preExistingMapping.getType() == MappingTypes.LITERAL) { literalEntry.setText(preExistingMapping.getMapping()); } else { if (checkFieldExists(preExistingMapping.getMapping())) { fieldSelection.setSelectedItem(preExistingMapping.getMapping()); } } } showHideFields(); ImageIcon imageToUse = (lastInList) ? addButtonIcon : removeButtonIcon; addRemoveMappingChoice = new JLabel(imageToUse); addRemoveMappingChoice.addMouseListener( new MouseAdapter() { @Override public void mouseExited(MouseEvent mouseEvent) { if (addRemoveMappingChoice.isEnabled()) { addRemoveMappingChoice.setIcon(lastInList ? addButtonIcon : removeButtonIcon); } } @Override public void mouseEntered(MouseEvent mouseEvent) { if (addRemoveMappingChoice.isEnabled()) { addRemoveMappingChoice.setIcon(lastInList ? addButtonIconOver : removeButtonIconOver); } } public void mousePressed(MouseEvent mouseEvent) { if (addRemoveMappingChoice.isEnabled()) { if (lastInList) { // tell the parent to add a new mapping addRemoveMappingChoice.setIcon(addButtonIcon); firePropertyChange("addNewMapping", "1", "2"); } else { // tell the parent to remove this mapping! firePropertyChange("removeThisMapping", "1", getCurrentInstance()); } } } }); add(addRemoveMappingChoice); }
void jbInit() throws Exception { border1 = BorderFactory.createEmptyBorder(10, 10, 5, 5); panel1.setLayout(borderLayout1); jPanel1.setLayout(borderLayout2); jScrollPane1.getViewport().setBackground(Color.white); jPanel2.setLayout(gridBagLayout1); jLabel1.setText("Profile Name : "); nameTextField.setMinimumSize(new Dimension(4, 18)); nameTextField.setPreferredSize(new Dimension(63, 18)); jLabel2.setText("Profile Type : "); openButton.setMaximumSize(new Dimension(73, 24)); openButton.setMinimumSize(new Dimension(73, 24)); openButton.setPreferredSize(new Dimension(73, 24)); openButton.setText("Open"); openButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { openButton_actionPerformed(e); } }); cancelButton.setMaximumSize(new Dimension(73, 24)); cancelButton.setMinimumSize(new Dimension(73, 24)); cancelButton.setPreferredSize(new Dimension(73, 24)); cancelButton.setMargin(new Insets(0, 5, 0, 5)); cancelButton.setText("Cancel"); cancelButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { cancelButton_actionPerformed(e); } }); profileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); profileList.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { profileList_mouseClicked(e); } }); jPanel2.setBorder(border1); typeComboBox.setMaximumSize(new Dimension(32767, 18)); typeComboBox.setMinimumSize(new Dimension(122, 18)); typeComboBox.setPreferredSize(new Dimension(176, 18)); getContentPane().add(panel1); panel1.add(jPanel1, BorderLayout.CENTER); jPanel1.add(jScrollPane1, BorderLayout.CENTER); panel1.add(jPanel2, BorderLayout.SOUTH); jPanel2.add( jLabel1, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 7, 0), 0, 0)); jPanel2.add( nameTextField, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 11, 7, 0), 0, 0)); jPanel2.add( jLabel2, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 17, 0), 0, 0)); jScrollPane1.getViewport().add(profileList, null); jPanel2.add( openButton, new GridBagConstraints( 3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 11, 2, 10), 0, 0)); jPanel2.add( cancelButton, new GridBagConstraints( 3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 11, 9, 10), 0, 0)); jPanel2.add( typeComboBox, new GridBagConstraints( 1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 11, 17, 0), 0, 0)); }
public CPLayersPalette(CPCommonController controller) { super(controller); title = "Layers"; // Widgets creation Image icons = controller.loadImage("smallicons.png"); addButton = new CPIconButton(icons, 16, 16, 0, 1); addButton.addController(this); addButton.setCPActionCommand(CPCommandId.AddLayer); removeButton = new CPIconButton(icons, 16, 16, 1, 1); removeButton.addController(this); removeButton.setCPActionCommand(CPCommandId.RemoveLayer); alphaSlider = new CPAlphaSlider(); blendCombo = new JComboBox<String>(modeNames); blendCombo.addActionListener(this); lw = new CPLayerWidget(); renameField = new CPRenameField(); lw.add(renameField); scrollPane = new JScrollPane(lw); cbSampleAllLayers = new JCheckBox("Sample All Layers"); cbSampleAllLayers.setSelected(controller.artwork.isSampleAllLayers()); cbSampleAllLayers.addItemListener(this); cbLockAlpha = new JCheckBox("Lock Alpha"); cbLockAlpha.setSelected(controller.artwork.isLockAlpha()); cbLockAlpha.addItemListener(this); // Layout // Add/Remove Layer Box hb = Box.createHorizontalBox(); hb.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); hb.add(addButton); hb.add(Box.createRigidArea(new Dimension(5, 0))); hb.add(removeButton); hb.add(Box.createHorizontalGlue()); // blend mode blendCombo.setPreferredSize(new Dimension(100, 16)); Box hb2 = Box.createHorizontalBox(); hb2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); hb2.add(blendCombo); hb2.add(Box.createHorizontalGlue()); // layer opacity alphaSlider.setPreferredSize(new Dimension(100, 16)); alphaSlider.setMaximumSize(new Dimension(100, 16)); Box hb3 = Box.createHorizontalBox(); hb3.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); hb3.add(alphaSlider); hb3.add(Box.createRigidArea(new Dimension(0, 16))); hb3.add(Box.createHorizontalGlue()); Box hb4 = Box.createHorizontalBox(); hb4.add(cbSampleAllLayers); hb4.add(Box.createHorizontalGlue()); Box hb5 = Box.createHorizontalBox(); hb5.add(cbLockAlpha); hb5.add(Box.createHorizontalGlue()); Box vb = Box.createVerticalBox(); vb.add(hb2); vb.add(hb3); vb.add(hb4); vb.add(hb5); setLayout(new BorderLayout()); add(scrollPane, BorderLayout.CENTER); add(vb, BorderLayout.PAGE_START); add(hb, BorderLayout.PAGE_END); // Set initial values CPArtwork artwork = controller.getArtwork(); alphaSlider.setValue(artwork.getActiveLayer().getAlpha()); // add listeners addListener(); // validate(); // pack(); }
/** * Конструктор * * @param mediator Посредник родитьельского окна */ public ButtonToolBar(final IGuiMediator mediator) { this.mediator = mediator; try { locale = ((WBDrawing) mediator).getLocalizer(); } catch (Exception e) { logger.debug(e.getMessage(), e); } mouseMenu = new JPopupMenu(); imagePanel = new JPanel(); imagePanel.setLayout(new GridLayout(4, 2)); mouseMenu.add(imagePanel); imagePanel.addFocusListener( new FocusListener() { public void focusGained(FocusEvent e) { System.out.println("Focus Gained"); } public void focusLost(FocusEvent e) { mouseMenu.setVisible(false); System.out.println("Focus Lost"); } }); URL url = ClassLoader.getSystemResource("img/open.gif"); Icon iconOpen = new ImageIcon(url); JButton btnOpen = new JButton(iconOpen); btnOpen.setToolTipText(locale.getString("btntoolbar.open")); url = ClassLoader.getSystemResource("img/save.gif"); Icon iconSave = new ImageIcon(url); JButton btnSave = new JButton(iconSave); btnSave.setToolTipText(locale.getString("btntoolbar.save")); url = ClassLoader.getSystemResource("img/undo.gif"); Icon iconUndo = new ImageIcon(url); btnUndo = new JButton(iconUndo); btnUndo.setToolTipText(locale.getString("btntoolbar.undo")); url = ClassLoader.getSystemResource("img/redo.gif"); Icon iconRedo = new ImageIcon(url); btnRedo = new JButton(iconRedo); btnRedo.setToolTipText(locale.getString("btntoolbar.redo")); url = ClassLoader.getSystemResource("img/draw.gif"); Icon iconDraw = new ImageIcon(url); btnDraw = new JToggleButton(iconDraw, true); btnDraw.setToolTipText(locale.getString("btntoolbar.draw")); url = ClassLoader.getSystemResource("img/pen.gif"); Icon iconPen = new ImageIcon(url); btnPen = new JToggleButton(iconPen); btnPen.setToolTipText(locale.getString("btntoolbar.pen")); url = ClassLoader.getSystemResource("img/calibrate.gif"); Icon iconCalibrate = new ImageIcon(url); btnCalibrate = new JToggleButton(iconCalibrate); btnCalibrate.setToolTipText(locale.getString("btntoolbar.calibration")); url = ClassLoader.getSystemResource("img/gridMove.gif"); Icon iconGridMove = new ImageIcon(url); JToggleButton btnGrigMove = new JToggleButton(iconGridMove); url = ClassLoader.getSystemResource("img/hand.gif"); Icon iconHand = new ImageIcon(url); JToggleButton btnHand = new JToggleButton(iconHand); btnHand.setToolTipText(locale.getString("btntoolbar.hand")); url = ClassLoader.getSystemResource("img/selTool.gif"); Icon iconSelTool = new ImageIcon(url); JToggleButton btnSelTool = new JToggleButton(iconSelTool); url = ClassLoader.getSystemResource("img/spline.gif"); Icon iconQuadTool = new ImageIcon(url); btnSpline = new JToggleButton(iconQuadTool); btnSpline.setToolTipText(locale.getString("btntoolbar.spline")); btnTools = new JToggleButton("T"); btnTextTool = new JToggleButton("A"); url = ClassLoader.getSystemResource("img/ruler.gif"); Icon iconRulerTool = new ImageIcon(url); btnRulerTool = new JToggleButton(iconRulerTool); url = ClassLoader.getSystemResource("img/sendFile.gif"); Icon iconSendFile = new ImageIcon(url); JToggleButton btnFileTransmit = new JToggleButton(iconSendFile); btnFileTransmit.setToolTipText(locale.getString("btntoolbar.fileTransmit")); url = ClassLoader.getSystemResource("img/nodesEdit.gif"); Icon iconNodesEdit = new ImageIcon(url); JToggleButton btnNodesEdit = new JToggleButton(iconNodesEdit); btnNodesEdit.setToolTipText(locale.getString("btntoolbar.nodeEdit")); JButton btnTest = new JButton(locale.getString("btntoolbar.button.Test")); btnTest.setEnabled(false); url = ClassLoader.getSystemResource("img/send.gif"); Icon iconSend = new ImageIcon(url); JButton btnSendArq = new JButton(iconSend); btnSendArq.setToolTipText(locale.getString("btntoolbar.send")); url = ClassLoader.getSystemResource("img/clear.gif"); Icon iconClear = new ImageIcon(url); JButton btnClearTab = new JButton(iconClear); btnClearTab.setToolTipText(locale.getString("btntoolbar.clear")); JButton btnRequestModel = new JButton(locale.getString("btntoolbar.button.RequestModel")); btnRequestModel.setEnabled(false); JComboBox cmbTools = new JComboBox(); cmbTools.addItem("Thick Line"); cmbTools.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean selected = btnTools.getModel().isSelected(); if (selected) { mode = getToolsMode(); guiChanged(); } } }); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(btnDraw); buttonGroup.add(btnPen); buttonGroup.add(btnCalibrate); buttonGroup.add(btnGrigMove); buttonGroup.add(btnHand); buttonGroup.add(btnSelTool); buttonGroup.add(btnSpline); buttonGroup.add(btnTextTool); buttonGroup.add(btnRulerTool); buttonGroup.add(btnNodesEdit); // buttonGroup.add( btnTools ); btnDraw.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_DRAWING; } guiChanged(); } }); btnPen.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_PEN; } guiChanged(); } }); btnCalibrate.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_CALIBRATING; } guiChanged(); } }); btnGrigMove.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_GRID_MOVING; } guiChanged(); } }); btnHand.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_HAND_MAP; } guiChanged(); } }); btnSelTool.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_SELECT_TOOL; } guiChanged(); } }); btnSpline.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_QUAD_TOOL; } guiChanged(); } }); btnTextTool.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_TEXT_TOOL; } guiChanged(); } }); btnRulerTool.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_RULER_TOOL; } guiChanged(); } }); btnNodesEdit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_NODES_EDIT; } guiChanged(); } }); btnTools.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mode = getToolsMode(); guiChanged(); } }); btnOpen.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnOpenPressed(); } }); btnSave.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnSavePressed(); } }); btnUndo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnUndoPressed(); } }); btnRedo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnRedoPressed(); } }); btnTest.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnTestPressed(); } }); btnSendArq.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnSendModelPressed(); } }); btnSendArq.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnSendArqModelPressed(); } }); btnClearTab.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnClearTabPressed(); } }); btnRequestModel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnFileTransmitPressed(); } }); btnFileTransmit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnFileTransmitPressed(); } }); add(btnOpen); add(btnSave); // add( btnUndo ); // add( btnRedo ); addSeparator(); // add(lblMode); actionButton = new JToggleButton(btnDraw.getIcon()); actionButton.setToolTipText(btnDraw.getToolTipText()); actionButton.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { mouseMenu.show(e.getComponent(), e.getX(), e.getY()); } }); addButton(btnDraw); addButton(btnPen); addButton(btnCalibrate); // add( btnGrigMove ); addButton(btnHand); // add(btnSelTool); addButton(btnSpline); addButton(btnNodesEdit); // add( btnTextTool ); addButton(btnRulerTool); // addSeparator(); // add(cmbTools); add(actionButton); cmbScale = new JComboBox(); cmbScale.setEditable(true); cmbScale.addItem("1:1000"); cmbScale.addItem("1:2000"); cmbScale.addItem("1:5000"); cmbScale.addItem("1:10000"); cmbScale.addItem("1:25000"); cmbScale.addItem("1:50000"); cmbScale.addItem("1:100000"); cmbScale.setSelectedIndex(3); cmbScale.setToolTipText(locale.getString("btntoolbar.scale")); cmbScale.setPreferredSize(cmbScale.getMinimumSize()); cmbScale.setMaximumSize(cmbScale.getMinimumSize()); cmbScale.addItemListener(new ZoomListener()); addSeparator(); chbVisibleGrid = new JCheckBox(); chbVisibleGrid.setSelected(true); chbVisibleGrid.setToolTipText(locale.getString("btntoolbar.grid")); // addSeparator(); chbVisibleGrid.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { guiChanged(); } }); add(btnFileTransmit); add(btnSendArq); add(btnClearTab); add(chbVisibleGrid); add(cmbScale); // addSeparator(); // add( lblControl ); // add( btnSend ); // add( btnRequestModel ); // add( btnTest ); }
/** * Creates and lays out components in the container. See the comments below for an organizational * overview by panel. */ private void initComponents(Container c) { // +=c=====================================================+ // ++=gcPanel==============================================+ // ++ [gcSelection] + // ++=capsPanel============================================+ // +++=imageCapsPanel======================================+ // +++ [imageAccelerated] + // +++ [imageTrueVolatile] + // +++=bufferCapsPanel=====================================+ // ++++=bufferAccessCapsPanel==============================+ // +++++=flippingPanel=====================================+ // +++++ [flipping] + // +++++=fsPanel===========================================+ // +++++ [indentPanel][fullScreen] + // +++++=mbPanel===========================================+ // +++++ [indentPanel][multiBuffer] + // ++++=buffersPanel=======================================+ // +++++=fbPanel===============+=bbPanel===================+ // +++++ + + // +++++ [fbAccelerated] + [bbAccelerated] + // +++++ + + // +++++ [fbTrueVolatile] + [bbTrueVolatile] + // +++++ + + // +=======================================================+ c.setLayout(new BorderLayout()); // Graphics Config JPanel gcPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); c.add(gcPanel, BorderLayout.NORTH); gcSelection.setPreferredSize(new Dimension(400, 30)); gcPanel.add(gcSelection); // Capabilities JPanel capsPanel = new JPanel(new BorderLayout()); c.add(capsPanel, BorderLayout.CENTER); // Image Capabilities JPanel imageCapsPanel = new JPanel(new GridLayout(2, 1)); capsPanel.add(imageCapsPanel, BorderLayout.NORTH); imageCapsPanel.setBorder(BorderFactory.createTitledBorder("Image Capabilities")); imageAccelerated.setEnabled(false); imageCapsPanel.add(imageAccelerated); imageTrueVolatile.setEnabled(false); imageCapsPanel.add(imageTrueVolatile); // Buffer Capabilities JPanel bufferCapsPanel = new JPanel(new BorderLayout()); capsPanel.add(bufferCapsPanel, BorderLayout.CENTER); bufferCapsPanel.setBorder(BorderFactory.createTitledBorder("Buffer Capabilities")); // Buffer Access JPanel bufferAccessCapsPanel = new JPanel(new GridLayout(3, 1)); bufferAccessCapsPanel.setPreferredSize(new Dimension(300, 88)); bufferCapsPanel.add(bufferAccessCapsPanel, BorderLayout.NORTH); // Flipping JPanel flippingPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); bufferAccessCapsPanel.add(flippingPanel); flippingPanel.add(flipping); flipping.setEnabled(false); flippingPanel.add(flippingMethod); // Full-screen JPanel fsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); bufferAccessCapsPanel.add(fsPanel); JPanel indentPanel = new JPanel(); indentPanel.setPreferredSize(new Dimension(30, 30)); fsPanel.add(indentPanel); fsPanel.add(fullScreen); fullScreen.setEnabled(false); // Multi-buffering JPanel mbPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); bufferAccessCapsPanel.add(mbPanel); indentPanel = new JPanel(); indentPanel.setPreferredSize(new Dimension(30, 30)); mbPanel.add(indentPanel); mbPanel.add(multiBuffer); multiBuffer.setEnabled(false); // Front and Back Buffer Capabilities JPanel buffersPanel = new JPanel(new GridLayout(1, 2)); bufferCapsPanel.add(buffersPanel, BorderLayout.CENTER); // Front Buffer JPanel fbPanel = new JPanel(new GridLayout(2, 1)); fbPanel.setBorder(BorderFactory.createTitledBorder("Front Buffer")); buffersPanel.add(fbPanel); fbPanel.add(fbAccelerated); fbAccelerated.setEnabled(false); fbPanel.add(fbTrueVolatile); fbTrueVolatile.setEnabled(false); // Back Buffer JPanel bbPanel = new JPanel(new GridLayout(2, 1)); bbPanel.setPreferredSize(new Dimension(250, 80)); bbPanel.setBorder(BorderFactory.createTitledBorder("Back and Intermediate Buffers")); buffersPanel.add(bbPanel); bbPanel.add(bbAccelerated); bbAccelerated.setEnabled(false); bbPanel.add(bbTrueVolatile); bbTrueVolatile.setEnabled(false); }
public DiameterCutOptionsTargetPanel() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel.add(GUIFactory.createLabel("Lungime:", 100)); JFormattedTextField length = GUIFactory.createNumberInput(4100L, 0L, 1000000L, 80); panel.add(length); JComboBox<String> mCombo = new JComboBox<String>(GUIUtil.metric); mCombo.addItemListener(this); mCombo = new JComboBox<String>(GUIUtil.metric); mCombo.setPreferredSize(new Dimension(50, mCombo.getPreferredSize().height)); panel.add(mCombo); add(panel); panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel.add(GUIFactory.createLabel("Diametru 1:", 100)); JFormattedTextField smallRadius = GUIFactory.createNumberInput(200L, 0L, 1000000L, 80); panel.add(smallRadius); mCombo = new JComboBox<String>(GUIUtil.metric); mCombo.addItemListener(this); mCombo = new JComboBox<String>(GUIUtil.metric); mCombo.setPreferredSize(new Dimension(50, mCombo.getPreferredSize().height)); panel.add(mCombo); add(panel); panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel.add(GUIFactory.createLabel("Diametru 2:", 100)); JFormattedTextField bigRadius = GUIFactory.createNumberInput(600L, 0L, 1000000L, 80); panel.add(bigRadius); mCombo = new JComboBox<String>(GUIUtil.metric); mCombo.addItemListener(this); mCombo = new JComboBox<String>(GUIUtil.metric); mCombo.setPreferredSize(new Dimension(50, mCombo.getPreferredSize().height)); panel.add(mCombo); add(panel); panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); label2 = GUIFactory.createLabel("Produse:", 100); panel.add(label2); products = ProductDAO.getProducts(); JPanel productsPanel = new JPanel(); productsPanel.setLayout(new BoxLayout(productsPanel, BoxLayout.Y_AXIS)); for (Product product : products) { JPanel row = new JPanel(new FlowLayout(FlowLayout.LEFT)); JCheckBox chk = new JCheckBox(); row.add(chk); selection.add(chk); chk.setName("length" + (long) product.getLength()); row.add(new JLabel(product.getName())); productsPanel.add(row); } JScrollPane scrollPane = new JScrollPane(productsPanel); scrollPane.setPreferredSize(new Dimension(productsPanel.getPreferredSize().width + 20, 215)); panel.add(scrollPane); add(panel); JPanel filtru = new JPanel(new FlowLayout(FlowLayout.LEADING)); filtru.add(filtru2m); filtru.add(filtru3m); filtru.add(filtru4m); filtru2m.setActionCommand("FILTRU2"); filtru3m.setActionCommand("FILTRU3"); filtru4m.setActionCommand("FILTRU4"); filtru2m.addActionListener(this); filtru3m.addActionListener(this); filtru4m.addActionListener(this); panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); JLabel label1 = GUIFactory.createLabel("Filtru", 100); panel.add(label1); panel.add(filtru); add(panel); cancel.setActionCommand("CANCEL_DIALOG"); cancel.addActionListener(GUIUtil.main); see.addActionListener(this); }
public void initializeMainView( final SuperAdapter superAdapter, Container contentPane, Dimension bigPanelDim, Dimension panelDim) { contentPane.setLayout(new BorderLayout()); final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); contentPane.add(mainPanel, BorderLayout.CENTER); mainPanel.setBackground(Color.white); final JPanel toolbarPanel = new JPanel(); toolbarPanel.setBorder(null); toolbarPanel.setLayout(new GridBagLayout()); mainPanel.add(toolbarPanel, BorderLayout.NORTH); JPanel bigPanel = new JPanel(); bigPanel.setLayout(new BorderLayout()); bigPanel.setBackground(Color.white); bigPanel.setPreferredSize(new Dimension(bigPanelDim)); bigPanel.setMaximumSize(new Dimension(bigPanelDim)); bigPanel.setMinimumSize(new Dimension(bigPanelDim)); JPanel bottomPanel = new JPanel(); bottomPanel.setBackground(Color.white); JMenuBar menuBar = null; try { menuBar = superAdapter.createMenuBar(); } catch (Exception e) { e.printStackTrace(); } assert menuBar != null; contentPane.add(menuBar, BorderLayout.NORTH); GridBagConstraints toolbarConstraints = new GridBagConstraints(); toolbarConstraints.anchor = GridBagConstraints.LINE_START; toolbarConstraints.fill = GridBagConstraints.HORIZONTAL; toolbarConstraints.gridx = 0; toolbarConstraints.gridy = 0; toolbarConstraints.weightx = 0.1; // --- Chromosome panel --- JPanel chrSelectionPanel = new JPanel(); toolbarPanel.add(chrSelectionPanel, toolbarConstraints); chrSelectionPanel.setBorder(LineBorder.createGrayLineBorder()); chrSelectionPanel.setLayout(new BorderLayout()); JPanel chrLabelPanel = new JPanel(); JLabel chrLabel = new JLabel("Chromosomes"); chrLabel.setHorizontalAlignment(SwingConstants.CENTER); chrLabelPanel.setBackground(HiCGlobals.backgroundColor); chrLabelPanel.setLayout(new BorderLayout()); chrLabelPanel.add(chrLabel, BorderLayout.CENTER); chrSelectionPanel.add(chrLabelPanel, BorderLayout.PAGE_START); JPanel chrButtonPanel = new JPanel(); chrButtonPanel.setBackground(new Color(238, 238, 238)); chrButtonPanel.setLayout(new BoxLayout(chrButtonPanel, BoxLayout.X_AXIS)); // ---- chrBox1 ---- chrBox1 = new JComboBox<Chromosome>(); chrBox1.setModel( new DefaultComboBoxModel<Chromosome>(new Chromosome[] {new Chromosome(0, "All", 0)})); chrBox1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { chrBox1ActionPerformed(e); } }); chrBox1.setPreferredSize(new Dimension(95, 70)); chrButtonPanel.add(chrBox1); // ---- chrBox2 ---- chrBox2 = new JComboBox<Chromosome>(); chrBox2.setModel( new DefaultComboBoxModel<Chromosome>(new Chromosome[] {new Chromosome(0, "All", 0)})); chrBox2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { chrBox2ActionPerformed(e); } }); chrBox2.setPreferredSize(new Dimension(95, 70)); chrButtonPanel.add(chrBox2); // ---- refreshButton ---- refreshButton = new JideButton(); refreshButton.setIcon( new ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Refresh24.gif"))); refreshButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { superAdapter.safeRefreshButtonActionPerformed(); } }); refreshButton.setPreferredSize(new Dimension(24, 24)); chrButtonPanel.add(refreshButton); chrBox1.setEnabled(false); chrBox2.setEnabled(false); refreshButton.setEnabled(false); chrSelectionPanel.add(chrButtonPanel, BorderLayout.CENTER); chrSelectionPanel.setMinimumSize(new Dimension(200, 70)); chrSelectionPanel.setPreferredSize(new Dimension(210, 70)); // ======== Display Option Panel ======== JPanel displayOptionPanel = new JPanel(); displayOptionPanel.setBackground(new Color(238, 238, 238)); displayOptionPanel.setBorder(LineBorder.createGrayLineBorder()); displayOptionPanel.setLayout(new BorderLayout()); JPanel displayOptionLabelPanel = new JPanel(); displayOptionLabelPanel.setBackground(HiCGlobals.backgroundColor); displayOptionLabelPanel.setLayout(new BorderLayout()); JLabel displayOptionLabel = new JLabel("Show"); displayOptionLabel.setHorizontalAlignment(SwingConstants.CENTER); displayOptionLabelPanel.add(displayOptionLabel, BorderLayout.CENTER); displayOptionPanel.add(displayOptionLabelPanel, BorderLayout.PAGE_START); JPanel displayOptionButtonPanel = new JPanel(); displayOptionButtonPanel.setBorder(new EmptyBorder(0, 10, 0, 10)); displayOptionButtonPanel.setLayout(new GridLayout(1, 0, 20, 0)); displayOptionComboBox = new JComboBox<MatrixType>(); displayOptionComboBox.setModel( new DefaultComboBoxModel<MatrixType>(new MatrixType[] {MatrixType.OBSERVED})); displayOptionComboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { superAdapter.safeDisplayOptionComboBoxActionPerformed(); normalizationComboBox.setEnabled(!isWholeGenome()); } }); displayOptionButtonPanel.add(displayOptionComboBox); displayOptionPanel.add(displayOptionButtonPanel, BorderLayout.CENTER); displayOptionPanel.setMinimumSize(new Dimension(140, 70)); displayOptionPanel.setPreferredSize(new Dimension(140, 70)); displayOptionPanel.setMaximumSize(new Dimension(140, 70)); toolbarConstraints.gridx = 1; toolbarConstraints.weightx = 0.1; toolbarPanel.add(displayOptionPanel, toolbarConstraints); displayOptionComboBox.setEnabled(false); // ======== Normalization Panel ======== JPanel normalizationPanel = new JPanel(); normalizationPanel.setBackground(new Color(238, 238, 238)); normalizationPanel.setBorder(LineBorder.createGrayLineBorder()); normalizationPanel.setLayout(new BorderLayout()); JPanel normalizationLabelPanel = new JPanel(); normalizationLabelPanel.setBackground(HiCGlobals.backgroundColor); normalizationLabelPanel.setLayout(new BorderLayout()); JLabel normalizationLabel = new JLabel("Normalization"); normalizationLabel.setHorizontalAlignment(SwingConstants.CENTER); normalizationLabelPanel.add(normalizationLabel, BorderLayout.CENTER); normalizationPanel.add(normalizationLabelPanel, BorderLayout.PAGE_START); JPanel normalizationButtonPanel = new JPanel(); normalizationButtonPanel.setBorder(new EmptyBorder(0, 10, 0, 10)); normalizationButtonPanel.setLayout(new GridLayout(1, 0, 20, 0)); normalizationComboBox = new JComboBox<String>(); normalizationComboBox.setModel( new DefaultComboBoxModel<String>(new String[] {NormalizationType.NONE.getLabel()})); normalizationComboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { superAdapter.safeNormalizationComboBoxActionPerformed(e); } }); normalizationButtonPanel.add(normalizationComboBox); normalizationPanel.add(normalizationButtonPanel, BorderLayout.CENTER); normalizationPanel.setPreferredSize(new Dimension(180, 70)); normalizationPanel.setMinimumSize(new Dimension(140, 70)); toolbarConstraints.gridx = 2; toolbarConstraints.weightx = 0.1; toolbarPanel.add(normalizationPanel, toolbarConstraints); normalizationComboBox.setEnabled(false); // ======== Resolution Panel ======== hiCPanel = new JPanel(); hiCPanel.setBackground(Color.white); hiCPanel.setLayout(new HiCLayout()); bigPanel.add(hiCPanel, BorderLayout.CENTER); JPanel wrapGapPanel = new JPanel(); wrapGapPanel.setBackground(Color.white); wrapGapPanel.setMaximumSize(new Dimension(5, 5)); wrapGapPanel.setMinimumSize(new Dimension(5, 5)); wrapGapPanel.setPreferredSize(new Dimension(5, 5)); wrapGapPanel.setBorder(LineBorder.createBlackLineBorder()); bigPanel.add(wrapGapPanel, BorderLayout.EAST); // splitPanel.insertPane(hiCPanel, 0); // splitPanel.setBackground(Color.white); // ---- rulerPanel2 ---- JPanel topPanel = new JPanel(); topPanel.setBackground(Color.green); topPanel.setLayout(new BorderLayout()); hiCPanel.add(topPanel, BorderLayout.NORTH); trackLabelPanel = new TrackLabelPanel(superAdapter.getHiC()); trackLabelPanel.setBackground(Color.white); hiCPanel.add(trackLabelPanel, HiCLayout.NORTH_WEST); trackPanelX = new TrackPanel(superAdapter, superAdapter.getHiC(), TrackPanel.Orientation.X); trackPanelX.setMaximumSize(new Dimension(4000, 50)); trackPanelX.setPreferredSize(new Dimension(1, 50)); trackPanelX.setMinimumSize(new Dimension(1, 50)); trackPanelX.setVisible(false); topPanel.add(trackPanelX, BorderLayout.NORTH); rulerPanelX = new HiCRulerPanel(superAdapter.getHiC()); rulerPanelX.setMaximumSize(new Dimension(4000, 50)); rulerPanelX.setMinimumSize(new Dimension(1, 50)); rulerPanelX.setPreferredSize(new Dimension(1, 50)); rulerPanelX.setBorder(null); topPanel.add(rulerPanelX, BorderLayout.SOUTH); // ---- rulerPanel1 ---- JPanel leftPanel = new JPanel(); leftPanel.setBackground(Color.white); leftPanel.setLayout(new BorderLayout()); hiCPanel.add(leftPanel, BorderLayout.WEST); trackPanelY = new TrackPanel(superAdapter, superAdapter.getHiC(), TrackPanel.Orientation.Y); trackPanelY.setMaximumSize(new Dimension(50, 4000)); trackPanelY.setPreferredSize(new Dimension(50, 1)); trackPanelY.setMinimumSize(new Dimension(50, 1)); trackPanelY.setVisible(false); leftPanel.add(trackPanelY, BorderLayout.WEST); rulerPanelY = new HiCRulerPanel(superAdapter.getHiC()); rulerPanelY.setMaximumSize(new Dimension(50, 4000)); rulerPanelY.setPreferredSize(new Dimension(50, 800)); rulerPanelY.setBorder(null); rulerPanelY.setMinimumSize(new Dimension(50, 1)); leftPanel.add(rulerPanelY, BorderLayout.EAST); // ---- heatmapPanel ---- // Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); // int panelSize = screenDimension.height - 210; int panelWidth = (int) panelDim.getWidth(); int panelHeight = (int) panelDim.getHeight(); System.err.println("Window W: " + panelWidth + " H" + panelHeight); JPanel wrapHeatmapPanel = new JPanel(new BorderLayout()); wrapHeatmapPanel.setMaximumSize(new Dimension(panelDim)); wrapHeatmapPanel.setMinimumSize(new Dimension(panelDim)); wrapHeatmapPanel.setPreferredSize(new Dimension(panelDim)); wrapHeatmapPanel.setBackground(Color.BLUE); wrapHeatmapPanel.setVisible(true); heatmapPanel = new HeatmapPanel(superAdapter); heatmapPanel.setMaximumSize(new Dimension(panelWidth - 5, panelHeight - 5)); heatmapPanel.setMinimumSize(new Dimension(panelWidth - 5, panelHeight - 5)); heatmapPanel.setPreferredSize(new Dimension(panelWidth - 5, panelHeight - 5)); heatmapPanel.setBackground(Color.white); wrapHeatmapPanel.add(heatmapPanel, BorderLayout.CENTER); // hiCPanel.setMaximumSize(new Dimension(panelWidth, panelHeight)); // hiCPanel.setMinimumSize(new Dimension(panelWidth, panelHeight)); // hiCPanel.setPreferredSize(new Dimension(panelWidth, panelHeight)); hiCPanel.add(wrapHeatmapPanel, BorderLayout.CENTER); // ======== Resolution Slider Panel ======== // Resolution panel resolutionSlider = new ResolutionControl(superAdapter); resolutionSlider.setPreferredSize(new Dimension(200, 70)); resolutionSlider.setMinimumSize(new Dimension(150, 70)); toolbarConstraints.gridx = 3; toolbarConstraints.weightx = 0.1; toolbarPanel.add(resolutionSlider, toolbarConstraints); // ======== Color Range Panel ======== colorRangePanel = new JColorRangePanel(superAdapter, heatmapPanel, preDefMapColor); toolbarConstraints.gridx = 4; toolbarConstraints.weightx = 0.5; toolbarPanel.add(colorRangePanel, toolbarConstraints); goPanel = new GoToPanel(superAdapter); toolbarConstraints.gridx = 5; toolbarConstraints.weightx = 0.25; toolbarPanel.add(goPanel, toolbarConstraints); // not sure this is working // toolbarPanel.setPreferredSize(new Dimension(panelHeight,100)); toolbarPanel.setEnabled(false); // ======== Right side panel ======== JPanel rightSidePanel = new JPanel(new BorderLayout()); // (new BorderLayout()); rightSidePanel.setBackground(Color.white); rightSidePanel.setPreferredSize(new Dimension(210, 1000)); rightSidePanel.setMaximumSize(new Dimension(10000, 10000)); // ======== Bird's view mini map ======== JPanel thumbPanel = new JPanel(); thumbPanel.setLayout(new BorderLayout()); // ---- thumbnailPanel ---- thumbnailPanel = new ThumbnailPanel(superAdapter); thumbnailPanel.setBackground(Color.white); thumbnailPanel.setMaximumSize(new Dimension(210, 210)); thumbnailPanel.setMinimumSize(new Dimension(210, 210)); thumbnailPanel.setPreferredSize(new Dimension(210, 210)); // JPanel gapPanel = new JPanel(); // gapPanel.setMaximumSize(new Dimension(1, 1)); // rightSidePanel.add(gapPanel,BorderLayout.WEST); thumbPanel.add(thumbnailPanel, BorderLayout.CENTER); thumbPanel.setBackground(Color.white); rightSidePanel.add(thumbPanel, BorderLayout.NORTH); // ========= mouse hover text ====== JPanel tooltipPanel = new JPanel(new BorderLayout()); tooltipPanel.setBackground(Color.white); tooltipPanel.setPreferredSize(new Dimension(210, 490)); mouseHoverTextPanel = new JEditorPane(); mouseHoverTextPanel.setEditable(false); mouseHoverTextPanel.setContentType("text/html"); mouseHoverTextPanel.setFont(new Font("sans-serif", 0, 20)); mouseHoverTextPanel.setBackground(Color.white); mouseHoverTextPanel.setBorder(null); int mouseTextY = rightSidePanel.getBounds().y + rightSidePanel.getBounds().height; // *Dimension prefSize = new Dimension(210, 490); Dimension prefSize = new Dimension(210, 390); mouseHoverTextPanel.setPreferredSize(prefSize); JScrollPane tooltipScroller = new JScrollPane(mouseHoverTextPanel); tooltipScroller.setBackground(Color.white); tooltipScroller.setBorder(null); tooltipPanel.setPreferredSize(new Dimension(210, 500)); tooltipPanel.add(tooltipScroller); tooltipPanel.setBounds(new Rectangle(new Point(0, mouseTextY), prefSize)); tooltipPanel.setBackground(Color.white); tooltipPanel.setBorder(null); rightSidePanel.add(tooltipPanel, BorderLayout.CENTER); // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < rightSidePanel.getComponentCount(); i++) { Rectangle bounds = rightSidePanel.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = rightSidePanel.getInsets(); preferredSize.width += insets.right + 20; preferredSize.height += insets.bottom; rightSidePanel.setMinimumSize(preferredSize); rightSidePanel.setPreferredSize(preferredSize); mainPanel.add(bigPanel, BorderLayout.CENTER); mainPanel.add(rightSidePanel, BorderLayout.EAST); }
public void objektAnlegen() { frame = new JFrame("anlegen"); JPanel anlegenPanel = new JPanel(); GridBagLayout gbl = new GridBagLayout(); anlegenPanel.setLayout(gbl); GridBagConstraints constraints = new GridBagConstraints(); listelabel = new JLabel("<html>Was möchten sie neu anlegen?<br/>Bitte wählen:"); listelabel.setFont(new Font("Arial", 18, 18)); constraints.insets = new Insets(16, 16, 16, 16); constraints.anchor = GridBagConstraints.WEST; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.weightx = 0; anlegenPanel.add(listelabel, constraints); // Vector erstellen und Jcombobox mit diesen Daten füllen Vector<String> anlegenvector = new Vector<String>(); anlegenvector.add("Zitat anlegen"); anlegenvector.add("Person anlegen"); anlegenvector.add("Sammelwerk anlegen"); anlegenvector.add("Werk anlegen"); anlegenvector.add("Verlag anlegen"); boxanlegen = new JComboBox(anlegenvector); Dimension groesseObjekt = new Dimension(300, 25); boxanlegen.setPreferredSize(groesseObjekt); constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.weightx = 1; constraints.fill = GridBagConstraints.NONE; anlegenPanel.add(boxanlegen, constraints); anlegen = new JButton("anlegen"); constraints.insets = new Insets(56, 16, 0, 0); constraints.gridwidth = 1; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.NONE; anlegenPanel.add(anlegen, constraints); anlegen.addActionListener(new anlegenListener()); abbrechen = new JButton("abbrechen"); constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.NONE; anlegenPanel.add(abbrechen, constraints); abbrechen.addActionListener(new abbrechenListener()); frame.getContentPane().add(anlegenPanel); // die Größe des frames wird festgelegt frame.setSize(400, 300); frame.setResizable(false); // der frame wird sichtbar gemacht frame.setVisible(true); }
public CustomDialog(Frame name) { super(name, "Customize Text Properties", true); this.setResizable(false); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fontList = ge.getAvailableFontFamilyNames(); fontCombo = new JComboBox(fontList); italic = new JCheckBox("Italic"); bold = new JCheckBox("Bold"); sizeCombo = new JComboBox(stringSize); ((JLabel) sizeCombo.getRenderer()).setHorizontalAlignment(SwingConstants.CENTER); sizeCombo.setSelectedIndex(4); sizeCombo.setPreferredSize(new Dimension(45, 21)); // tweek size example = new JTextField(" Preview "); example.setHorizontalAlignment(SwingConstants.CENTER); example.setFont(new Font("sanserif", Font.PLAIN, 28)); example.setEditable(false); ok = new JButton("Apply"); cancel = new JButton("Cancel"); ok.setPreferredSize(cancel.getPreferredSize()); foreground = new JButton("Edit Color"); foreground.setPreferredSize(new Dimension(100, 50)); // add the listeners fontCombo.addActionListener(this); italic.addItemListener(this); bold.addItemListener(this); sizeCombo.addActionListener(this); ok.addActionListener(this); cancel.addActionListener(this); foreground.addActionListener(this); JPanel p0 = new JPanel(); p0.add(fontCombo); p0.setBorder(new TitledBorder(new EtchedBorder(), "Font family")); JPanel p1a = new JPanel(); p1a.add(italic); p1a.add(bold); p1a.setBorder(new TitledBorder(new EtchedBorder(), "Font style")); JPanel p1b = new JPanel(); p1b.add(sizeCombo); p1b.add(new JLabel("pt.")); p1b.setBorder(new TitledBorder(new EtchedBorder(), "Font size")); JPanel p1 = new JPanel(); p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS)); p1.add(p1a); p1.add(p1b); p1.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel p2 = new JPanel(); // use FlowLayout p2.add(foreground); p2.setBorder(new TitledBorder(new EtchedBorder(), "Message color")); p2.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel p3 = new JPanel(); p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS)); p3.add(example); p3.setPreferredSize(new Dimension(250, 60)); p3.setMaximumSize(new Dimension(250, 60)); p3.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel p4 = new JPanel(); p4.add(ok); p4.add(cancel); p4.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.add(p0); p.add(Box.createRigidArea(new Dimension(0, 10))); p.add(p1); p.add(Box.createRigidArea(new Dimension(0, 10))); p.add(p2); p.add(Box.createRigidArea(new Dimension(0, 10))); p.add(p3); p.add(Box.createRigidArea(new Dimension(0, 10))); p.add(p4); p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); Dimension d1 = p3.getPreferredSize(); Dimension d2 = p1.getPreferredSize(); p1.setPreferredSize(new Dimension(d1.width, d2.height)); p1.setMaximumSize(new Dimension(d1.width, d2.height)); d2 = p2.getPreferredSize(); p2.setPreferredSize(new Dimension(d1.width, d2.height)); p2.setMaximumSize(new Dimension(d1.width, d2.height)); this.setContentPane(p); this.pack(); }