protected JXTaskPane getOverviewPane() { if (overviewPane == null) { overviewPane = new JXTaskPane(STLConstants.K1060_OUTLINE.getValue()); overviewPane.setUI(new IntelTaskPaneUI()); Container content = overviewPane.getContentPane(); content.setLayout(new BorderLayout()); graphOutline = new TopologyOutlinePanel(updateService, Fit.WIDTH); graphOutline.setBackground(UIConstants.INTEL_WHITE); graphOutline.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(UIConstants.INTEL_GRAY), BorderFactory.createEmptyBorder(2, 2, 2, 2))); content.add(graphOutline, BorderLayout.CENTER); enlargeBtn = new JXHyperlink( new AbstractAction(STLConstants.K1061_ENLARGE.getValue()) { private static final long serialVersionUID = -4493041735258083928L; @Override public void actionPerformed(ActionEvent e) { if (graph != null) { showOutlineWindow(); } } }); enlargeBtn.setHorizontalAlignment(JButton.TRAILING); enlargeBtn.setUnclickedColor(UIConstants.INTEL_BLUE); content.add(enlargeBtn, BorderLayout.SOUTH); } return overviewPane; }
protected JXTaskPane getResourcesPane() { if (resourcesPane == null) { resourcesPane = new JXTaskPane(STLConstants.K1062_SEL_RESOURCES.getValue()); resourcesPane.setUI(new IntelTaskPaneUI()); // turned off animation because it has some issues with JScrollPane // under our current BorderLayout. Basically we use BorderLayout // because we want the <code>resourcePane</code> takes all the // remainder space. But the animation intends to specify // resourcePane's size (fixed size). The confliction between the the // LayoutManager and the animation causes issues. So we turned // animation off here. resourcesPane.setAnimated(false); JPanel content = (JPanel) resourcesPane.getContentPane(); content.setLayout(new BorderLayout()); resourcesPanel = new JPanel(); resourcesPanel.setBackground(UIConstants.INTEL_WHITE); resourcesPanel.setBorder( BorderFactory.createMatteBorder(2, 2, 2, 2, UIConstants.INTEL_BACKGROUND_GRAY)); resourcesPanel.setLayout(new GridBagLayout()); JScrollPane listScroller = new JScrollPane(resourcesPanel); listScroller.setBorder(null); content.add(listScroller, BorderLayout.CENTER); } return resourcesPane; }
/** * Adds the specified files to the list of import data. * * @param files The files to import. */ private void insertFiles(Map<File, StatusLabel> files) { if (files == null || files.size() == 0) { statusLabel.setText("No files to import."); return; } components = new HashMap<File, FileImportComponent>(); totalFiles = files.size(); String text = "Importing " + totalFiles + " file"; if (totalFiles > 1) text += "s"; statusLabel.setText(text); Entry entry; Iterator i = files.entrySet().iterator(); FileImportComponent c; JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); int index = 0; p.setBorder(BorderFactory.createLineBorder(Color.BLACK)); File f; DatasetData d = dataset; Object node = refNode; if (folderAsContainer) { node = null; d = new DatasetData(); d.setName(file.getName()); } while (i.hasNext()) { entry = (Entry) i.next(); f = (File) entry.getKey(); c = new FileImportComponent(f, folderAsContainer, browsable, group, singleGroup); if (f.isFile()) { c.setLocation(data, d, node); c.setParent(this); } c.showContainerLabel(showContainerLabel); c.setType(getType()); attachListeners(c); c.setStatusLabel((StatusLabel) entry.getValue()); if (index % 2 == 0) c.setBackground(UIUtilities.BACKGROUND_COLOUR_EVEN); else c.setBackground(UIUtilities.BACKGROUND_COLOUR_ODD); components.put((File) entry.getKey(), c); p.add(c); index++; } removeAll(); pane = EditorUtil.createTaskPane(""); pane.setCollapsed(false); setNumberOfImport(); IconManager icons = IconManager.getInstance(); pane.setIcon(icons.getIcon(IconManager.DIRECTORY)); Font font = pane.getFont(); pane.setFont(font.deriveFont(font.getStyle(), font.getSize() - 2)); pane.add(p); double[][] size = {{TableLayout.FILL}, {TableLayout.PREFERRED}}; setLayout(new TableLayout(size)); add(pane, "0, 0"); validate(); repaint(); }
private ScriptGroup(String key) { // taskGroup = new JTaskPaneGroup(); taskGroup = new JXTaskPane(); taskGroup.setFocusable(false); taskGroup.setRequestFocusEnabled(false); taskGroup.setTitle(AppLocal.getIntString(key)); taskGroup.setVisible(false); // Only groups with sons are visible. }
/** Initializes the UI components. */ private void initComponents() { container = new JPanel(); previewPanel.addPropertyChangeListener(this); imagePane = EditorUtil.createTaskPane("OMERO.editor"); // imagePane.setCollapsed(false); imagePane.add(previewPanel); imagePane.addPropertyChangeListener(UIUtilities.COLLAPSED_PROPERTY_JXTASKPANE, this); }
private void addAction(Action act) { if (m_appuser.hasPermission((String) act.getValue(AppUserView.ACTION_TASKNAME))) { // add the action Component c = taskGroup.add(act); c.setFocusable(false); // c.setRequestFocusEnabled(false); taskGroup.setVisible(true); if (m_actionfirst == null) { m_actionfirst = act; } } }
/** Sets the text indicating the number of import. */ private void setNumberOfImport() { if (pane == null) return; String end = " file"; if (totalFiles > 1) end += "s"; String text = file.getName() + ": " + importCount + " of " + totalFiles + end; pane.setTitle(text); }
public void setSpecificTaskPane(JPanel contents, String title, Icon icon) { if (currentSpecificTaskPane != null) { taskPaneContainer.remove(currentSpecificTaskPane); } currentSpecificTaskPane = new JXTaskPane(); currentSpecificTaskPane.setLayout(new BorderLayout()); currentSpecificTaskPane.setTitle(title); currentSpecificTaskPane.setIcon(icon); // contents.setOpaque(false); SwingUtilities.updateComponentTreeUI(contents); // currentSpecificTaskPane.setOpaque(false); currentSpecificTaskPane.add(contents, BorderLayout.CENTER); // this.mainTaskPane.setExpanded(false); taskPaneContainer.add(currentSpecificTaskPane); }
private void fillTaskPane(JXTaskPane first) { first.add( new AbstractActionExt("some") { public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub } }); first.add( new AbstractActionExt("other") { public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub } }); }
@Override public void installDetallesPanel(JXTaskPane detalle) { detalle.add(browser.getTotalesPanel()); }
@Override public void installFiltrosPanel(JXTaskPane filtros) { filtros.add(browser.getFilterPanel()); }
@Override public void instalOperacionesAction(JXTaskPane operaciones) { operaciones.add(browser.getLoadAction()); operaciones.add(browser.getGenerarPolizaAction()); }
/** Static Setup - add fields to parameterPanel */ private void statInit() { labelValue.setText(Msg.getMsg(Env.getCtx(), "Value")); fieldValue.setBackground(AdempierePLAF.getInfoBackground()); fieldValue.addActionListener(this); labelName.setText(Msg.getMsg(Env.getCtx(), "Name")); fieldName.setBackground(AdempierePLAF.getInfoBackground()); fieldName.addActionListener(this); labelUPC.setText(Msg.translate(Env.getCtx(), "UPC")); fieldUPC.setBackground(AdempierePLAF.getInfoBackground()); fieldUPC.addActionListener(this); labelSKU.setText(Msg.translate(Env.getCtx(), "SKU")); fieldSKU.setBackground(AdempierePLAF.getInfoBackground()); fieldSKU.addActionListener(this); labelWarehouse.setText(Msg.getMsg(Env.getCtx(), "Warehouse")); pickWarehouse.setBackground(AdempierePLAF.getInfoBackground()); labelPriceList.setText(Msg.getMsg(Env.getCtx(), "PriceListVersion")); pickPriceList.setBackground(AdempierePLAF.getInfoBackground()); labelProductCategory.setText(Msg.translate(Env.getCtx(), "M_Product_Category_ID")); pickProductCategory.setBackground(AdempierePLAF.getInfoBackground()); // @Trifon labelAS.setText(Msg.translate(Env.getCtx(), "M_AttributeSet_ID")); pickAS.setBackground(AdempierePLAF.getInfoBackground()); m_InfoPAttributeButton.setMargin(new Insets(2, 2, 2, 2)); m_InfoPAttributeButton.setToolTipText(Msg.getMsg(Env.getCtx(), "InfoPAttribute")); m_InfoPAttributeButton.addActionListener(this); labelVendor.setText(Msg.translate(Env.getCtx(), "Vendor")); fieldVendor.setBackground(AdempierePLAF.getInfoBackground()); fieldVendor.addActionListener(this); // Line 1 parameterPanel.setLayout(new ALayout()); parameterPanel.add(labelValue, new ALayoutConstraint(0, 0)); parameterPanel.add(fieldValue, null); parameterPanel.add(labelUPC, null); parameterPanel.add(fieldUPC, null); parameterPanel.add(labelWarehouse, null); parameterPanel.add(pickWarehouse, null); parameterPanel.add(m_InfoPAttributeButton); // Line 2 parameterPanel.add(labelName, new ALayoutConstraint(1, 0)); parameterPanel.add(fieldName, null); parameterPanel.add(labelSKU, null); parameterPanel.add(fieldSKU, null); parameterPanel.add(labelVendor, null); parameterPanel.add(fieldVendor, null); // Line 3 parameterPanel.add(labelPriceList, new ALayoutConstraint(2, 0)); parameterPanel.add(pickPriceList, null); parameterPanel.add(labelProductCategory, null); parameterPanel.add(pickProductCategory, null); parameterPanel.add(labelAS, null); // @Trifon parameterPanel.add(pickAS, null); // @Trifon // Product Attribute Instance m_PAttributeButton = ConfirmPanel.createPAttributeButton(true); confirmPanel.addButton(m_PAttributeButton); m_PAttributeButton.addActionListener(this); m_PAttributeButton.setEnabled(false); // Begin - fer_luck @ centuryon // add taskpane fieldDescription.setBackground(AdempierePLAF.getInfoBackground()); fieldDescription.setEditable(false); fieldDescription.setPreferredSize(new Dimension(INFO_WIDTH - 100, 100)); warehouseStockPanel.setTitle(Msg.translate(Env.getCtx(), "WarehouseStock")); warehouseStockPanel.setUI(new AdempiereTaskPaneUI()); warehouseStockPanel.getContentPane().setBackground(new ColorUIResource(251, 248, 241)); warehouseStockPanel.getContentPane().setForeground(new ColorUIResource(251, 0, 0)); ColumnInfo[] s_layoutWarehouse = new ColumnInfo[] { new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "Warehouse", String.class), new ColumnInfo( Msg.translate(Env.getCtx(), "QtyAvailable"), "sum(QtyAvailable)", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "sum(QtyOnHand)", Double.class), new ColumnInfo( Msg.translate(Env.getCtx(), "QtyReserved"), "sum(QtyReserved)", Double.class), new ColumnInfo( Msg.translate(Env.getCtx(), "QtyAllocated"), "sum(QtyAllocated)", Double.class) }; /** From Clause */ String s_sqlFrom = " M_PRODUCT_STOCK_V "; /** Where Clause */ String s_sqlWhere = "Value = ?"; m_sqlWarehouse = warehouseTbl.prepareTable( s_layoutWarehouse, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_STOCK_V"); m_sqlWarehouse += " Group By Warehouse, documentnote "; warehouseTbl.setRowSelectionAllowed(true); warehouseTbl.setMultiSelection(false); warehouseTbl.addMouseListener(this); warehouseTbl.getSelectionModel().addListSelectionListener(this); warehouseTbl.setShowTotals(true); warehouseTbl.autoSize(); ColumnInfo[] s_layoutSubstitute = new ColumnInfo[] { new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "orgname", String.class), new ColumnInfo( Msg.translate(Env.getCtx(), "Value"), "(Select Value from M_Product p where p.M_Product_ID=M_PRODUCT_SUBSTITUTERELATED_V.Substitute_ID)", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "QtyAvailable", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "QtyOnHand", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "QtyReserved", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "PriceStd", Double.class) }; s_sqlFrom = "M_PRODUCT_SUBSTITUTERELATED_V"; s_sqlWhere = "M_Product_ID = ? AND M_PriceList_Version_ID = ? and RowType = 'S'"; m_sqlSubstitute = substituteTbl.prepareTable( s_layoutSubstitute, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_SUBSTITUTERELATED_V"); substituteTbl.setRowSelectionAllowed(false); substituteTbl.setMultiSelection(false); substituteTbl.addMouseListener(this); substituteTbl.getSelectionModel().addListSelectionListener(this); substituteTbl.autoSize(); ColumnInfo[] s_layoutRelated = new ColumnInfo[] { new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "orgname", String.class), new ColumnInfo( Msg.translate(Env.getCtx(), "Value"), "(Select Value from M_Product p where p.M_Product_ID=M_PRODUCT_SUBSTITUTERELATED_V.Substitute_ID)", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "QtyAvailable", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "QtyOnHand", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "QtyReserved", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "PriceStd", Double.class) }; s_sqlFrom = "M_PRODUCT_SUBSTITUTERELATED_V"; s_sqlWhere = "M_Product_ID = ? AND M_PriceList_Version_ID = ? and RowType = 'R'"; m_sqlRelated = relatedTbl.prepareTable( s_layoutRelated, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_SUBSTITUTERELATED_V"); relatedTbl.setRowSelectionAllowed(false); relatedTbl.setMultiSelection(false); relatedTbl.addMouseListener(this); relatedTbl.getSelectionModel().addListSelectionListener(this); relatedTbl.autoSize(); // Available to Promise Tab m_tableAtp.setRowSelectionAllowed(false); m_tableAtp.setMultiSelection(false); CTabbedPane jTab = new CTabbedPane(); jTab.addTab(Msg.translate(Env.getCtx(), "Warehouse"), new JScrollPane(warehouseTbl)); jTab.setPreferredSize(new Dimension(INFO_WIDTH, SCREEN_HEIGHT > 600 ? 250 : 105)); jTab.addTab(Msg.translate(Env.getCtx(), "Description"), new JScrollPane(fieldDescription)); jTab.addTab(Msg.translate(Env.getCtx(), "Substitute_ID"), new JScrollPane(substituteTbl)); jTab.addTab(Msg.translate(Env.getCtx(), "RelatedProduct_ID"), new JScrollPane(relatedTbl)); jTab.addTab(Msg.getMsg(Env.getCtx(), "ATP"), new JScrollPane(m_tableAtp)); jTab.addChangeListener(this); tablePanel.setPreferredSize(new Dimension(INFO_WIDTH, SCREEN_HEIGHT > 600 ? 255 : 110)); tablePanel.add(jTab); warehouseStockPanel.setCollapsed(true); warehouseStockPanel.add(tablePanel); this.addonPanel.add(warehouseStockPanel); this.p_table.addKeyListener( new KeyAdapter() { public void keyReleased(KeyEvent ke) { int row = ((MiniTable) ke.getSource()).getSelectedRow(); refresh( ((MiniTable) ke.getSource()).getValueAt(row, 2), new BigDecimal(pickWarehouse.getValue().toString()).intValue(), new BigDecimal(pickPriceList.getValue().toString()).intValue()); warehouseStockPanel.setCollapsed(false); } }); this.p_table.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent me) { int row = ((MiniTable) me.getSource()).getSelectedRow(); refresh( ((MiniTable) me.getSource()).getValueAt(row, 2), new BigDecimal(pickWarehouse.getValue().toString()).intValue(), new BigDecimal(pickPriceList.getValue().toString()).intValue()); warehouseStockPanel.setCollapsed(false); } }); // End - fer_luck @ centuryon } // statInit
private void buildMenu() { JXTaskPane editPane = new JXTaskPane(); editPane.setTitle("Bearbeiten"); JXButton filter3k = new JXButton(new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/3k.png"))); filter3k.setToolTipText("Wählt alle Dörfer mit weniger als 3000 Punkten"); filter3k.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { filterByPoints(3000); } }); editPane.getContentPane().add(filter3k); JXButton filter5k = new JXButton(new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/5k.png"))); filter5k.setToolTipText("Wählt alle Dörfer mit weniger als 5000 Punkten"); filter5k.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { filterByPoints(5000); } }); editPane.getContentPane().add(filter5k); JXButton filter7k = new JXButton(new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/7k.png"))); filter7k.setToolTipText("Wählt alle Dörfer mit weniger als 7000 Punkten"); filter7k.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { filterByPoints(7000); } }); editPane.getContentPane().add(filter7k); JXButton filter9k = new JXButton(new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/9k.png"))); filter9k.setToolTipText("Wählt alle Dörfer mit weniger als 9000 Punkten"); filter9k.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { filterByPoints(9000); } }); editPane.getContentPane().add(filter9k); jApplyCustomFilter.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { try { filterByPoints(UIHelper.parseIntFromField(jCustomPointsField, 1500)); } catch (NumberFormatException nfe) { jCustomPointsField.setText(null); } } }); editPane.getContentPane().add(jCustomPointsPanel); JXTaskPane transferPane = new JXTaskPane(); transferPane.setTitle("Übertragen"); JXButton toHtml = new JXButton(new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/att_HTML.png"))); toHtml.setToolTipText("Gewählte Dörfer als HTML Datei exportieren"); toHtml.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { exportAsHTML(); } }); transferPane.getContentPane().add(toHtml); JXTaskPane miscPane = new JXTaskPane(); miscPane.setTitle("Sonstiges"); JXButton structure = new JXButton(new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/branch.png"))); structure.setToolTipText("Wechsel zwischen Baumstruktur und Liste"); structure.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { switchViewType(); } }); miscPane.getContentPane().add(structure); JXButton region = new JXButton( new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/region_select.png"))); region.setToolTipText("Auswahl aller Dörfer innerhalb bestimmter Koordinaten"); region.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { showRegionSelection(); } }); miscPane.getContentPane().add(region); JXButton substract = new JXButton( new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/branch_remove.png"))); substract.setToolTipText( "Abziehen aller Dörfer aus der Zwischenablage von der Liste der ausgewählten Dörfer"); substract.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { substractVillagesFromClipboard(); } }); miscPane.getContentPane().add(substract); centerPanel.setupTaskPane(editPane, transferPane, miscPane); }
public Check() { super( "Substance test with very very very very very very very very very very very very very very long title"); final ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) { setIconImage( SubstanceLogo.getLogoImage( SubstanceLookAndFeel.getCurrentSkin(this.getRootPane()) .getColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE, ColorSchemeAssociationKind.FILL, ComponentState.ENABLED))); } SubstanceLookAndFeel.registerSkinChangeListener( new SkinChangeListener() { @Override public void skinChanged() { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { setIconImage( SubstanceLogo.getLogoImage( SubstanceLookAndFeel.getCurrentSkin(Check.this.getRootPane()) .getColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE, ColorSchemeAssociationKind.FILL, ComponentState.ENABLED))); } }); } }); setLayout(new BorderLayout()); jtp = new JTabbedPane(); try { mainTabPreviewPainter = new MyMainTabPreviewPainter(); jtp.putClientProperty(LafWidget.TABBED_PANE_PREVIEW_PAINTER, mainTabPreviewPainter); } catch (Throwable e) { } jtp.getModel().addChangeListener(new TabSwitchListener()); final JXPanel jxPanel = new JXPanel(new BorderLayout()); toolbar = getToolbar("", 22, true); jxPanel.add(toolbar, BorderLayout.NORTH); JXStatusBar statusBar = getStatusBar(jxPanel, jtp); this.add(statusBar, BorderLayout.SOUTH); taskPaneContainer = new JXTaskPaneContainer() { @Override public boolean getScrollableTracksViewportWidth() { return false; } }; taskPaneContainer.setScrollableTracksViewportHeight(false); taskPaneContainer.setScrollableTracksViewportWidth(false); mainTaskPane = new JXTaskPane(); mainTaskPane.setLayout(new BorderLayout()); JPanel mainControlPanel = ControlPanelFactory.getMainControlPanel(this, jtp, mainTabPreviewPainter, toolbar); // mainControlPanel.setOpaque(false); mainTaskPane.add(mainControlPanel, BorderLayout.CENTER); mainTaskPane.setTitle("General settings"); mainTaskPane.setIcon(getIcon("JFrameColor16")); mainTaskPane.setCollapsed(true); taskPaneContainer.add(mainTaskPane); JPanel dialogControlPanel = ControlPanelFactory.getDialogControlPanel(this); JXTaskPane dialogTaskPane = new JXTaskPane(); dialogTaskPane.setLayout(new BorderLayout()); dialogTaskPane.add(dialogControlPanel, BorderLayout.CENTER); dialogTaskPane.setTitle("Frames & Dialogs"); dialogTaskPane.setIcon(getIcon("JDialogColor16")); dialogTaskPane.setCollapsed(true); // dialogTaskPane.setOpaque(false); taskPaneContainer.add(dialogTaskPane); currentSpecificTaskPane = null; final JScrollPane scrollPane = new JScrollPane( taskPaneContainer, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); SubstanceLookAndFeel.setDecorationType(scrollPane, DecorationAreaType.GENERAL); // scrollPane.setOpaque(false); // scrollPane.getViewport().setOpaque(false); JPanel mainPanel = new JPanel(); mainPanel.add(scrollPane); mainPanel.add(jtp); mainPanel.setLayout( new LayoutManager() { @Override public void addLayoutComponent(String name, Component comp) {} @Override public Dimension minimumLayoutSize(Container parent) { Dimension min1 = scrollPane.getMinimumSize(); Dimension min2 = jtp.getMinimumSize(); return new Dimension(min1.width + min2.width, min1.height + min2.height); } @Override public void layoutContainer(Container parent) { // give 30% width to task pane container and // 70% width to the tabbed pane with controls. int width = parent.getWidth(); int height = parent.getHeight(); scrollPane.setBounds(0, 0, (int) (0.3 * width), height); jtp.setBounds((int) (0.3 * width), 0, width - (int) (0.3 * width), height); } @Override public Dimension preferredLayoutSize(Container parent) { Dimension pref1 = scrollPane.getPreferredSize(); Dimension pref2 = jtp.getPreferredSize(); return new Dimension(pref1.width + pref2.width, pref1.height + pref2.height); } @Override public void removeLayoutComponent(Component comp) {} }); jxPanel.add(mainPanel, BorderLayout.CENTER); this.add(jxPanel, BorderLayout.CENTER); setPreferredSize(new Dimension(400, 400)); this.setSize(getPreferredSize()); setMinimumSize(getPreferredSize()); ButtonsPanel buttonsPanel = new ButtonsPanel(); jtp.addTab("Buttons", getIcon("JButtonColor16"), buttonsPanel); getRootPane().setDefaultButton(buttonsPanel.defaultButton); jtp.addTab("Combo box", getIcon("JComboBoxColor16"), new CombosPanel()); jtp.addTab("Scroll pane", getIcon("JScrollPaneColor16"), new ScrollPanel()); TabCloseCallback closeCallback = new TabCloseCallback() { @Override public TabCloseKind onAreaClick( JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.getButton() != MouseEvent.BUTTON3) return TabCloseKind.NONE; if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } @Override public TabCloseKind onCloseButtonClick( JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.isAltDown()) { return TabCloseKind.ALL_BUT_THIS; } if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } @Override public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) { return null; } @Override public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) { StringBuffer result = new StringBuffer(); result.append("<html><body>"); result.append("Mouse click closes <b>" + tabbedPane.getTitleAt(tabIndex) + "</b> tab"); result.append( "<br><b>Alt</b>-Mouse click closes all tabs but <b>" + tabbedPane.getTitleAt(tabIndex) + "</b> tab"); result.append("<br><b>Shift</b>-Mouse click closes all tabs"); result.append("</body></html>"); return result.toString(); } }; try { TabPanel tp = new TabPanel(); tp.jtp.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallback); jtp.addTab("Tabs", getIcon("JTabbedPaneColor16"), tp); } catch (NoClassDefFoundError ncdfe) { } jtp.addTab("Split", new SplitPanel()); jtp.addTab("Desktop", getIcon("JDesktopPaneColor16"), new DesktopPanel()); jtp.addTab("Text fields", getIcon("JTextPaneColor16"), new TextFieldsPanel()); jtp.addTab("Table", getIcon("JTableColor16"), new TablePanel()); try { jtp.addTab("List", getIcon("JListColor16"), new ListPanel()); } catch (NoClassDefFoundError ncdfe) { } jtp.addTab("Slider", getIcon("JSliderColor16"), new SliderPanel()); jtp.addTab("Progress bar", getIcon("JProgressBarColor16"), new ProgressBarPanel()); jtp.addTab("Spinner", getIcon("JSpinnerColor16"), new SpinnerPanel()); jtp.addTab("Tree", getIcon("JTreeColor16"), new TreePanel()); jtp.addTab("File tree", getIcon("JTreeColor16"), new FileTreePanel()); jtp.addTab("Cards", new CardPanel()); JPanel verticalButtonPanel = new JPanel(); verticalButtonPanel.setLayout(new GridLayout(1, 3)); verticalButtonPanel.add(new JButton("Vert button 1")); verticalButtonPanel.add(new JButton("Vert button 2")); JPanel smallVerticalButtonPanel = new JPanel(); smallVerticalButtonPanel.setLayout(new GridLayout(4, 4)); for (int row = 0; row < 4; row++) { for (int col = 0; col < 4; col++) { JButton vertButton = new JButton("vert"); vertButton.setToolTipText("Vertical button " + row + ":" + col); smallVerticalButtonPanel.add(vertButton); } } verticalButtonPanel.add(smallVerticalButtonPanel); jtp.addTab("V-Buttons", verticalButtonPanel); jtp.addTab("Colored", new ColoredControlsPanel()); jtp.addTab("Colorized", new ColorizedControlsPanel()); jtp.addTab("Cells", new CellsPanel()); jtp.addTab("Sizes", new SizesPanel()); jtp.addTab("H-Align", new HAlignmentPanel()); jtp.addTab("V-Align", new VAlignmentPanel()); // sample menu bar JMenuBar jmb = new JMenuBar(); if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) { jmb.add(SampleMenuFactory.getSkinMenu()); jmb.add(SampleMenuFactory.getTransformMenu()); } JMenu coloredMenu = new JMenu("Colors"); coloredMenu.setMnemonic('0'); JMenuItem coloredMI = new JMenuItem("Italic red"); coloredMI.setFont(coloredMI.getFont().deriveFont(Font.ITALIC)); coloredMI.setForeground(Color.red); coloredMenu.add(coloredMI); JRadioButtonMenuItem coloredRBMI = new JRadioButtonMenuItem("Bold green"); coloredRBMI.setFont(coloredRBMI.getFont().deriveFont(Font.BOLD)); coloredRBMI.setForeground(Color.green); coloredMenu.add(coloredRBMI); JCheckBoxMenuItem coloredCBMI = new JCheckBoxMenuItem("Big blue"); coloredCBMI.setFont(coloredCBMI.getFont().deriveFont(32f)); coloredCBMI.setForeground(Color.blue); coloredMenu.add(coloredCBMI); JMenu coloredM = new JMenu("Always big magenta"); coloredM.setForeground(Color.magenta); coloredM.setFont(coloredM.getFont().deriveFont(24f)); coloredMenu.add(coloredM); jmb.add(coloredMenu); JMenu testMenu = SampleMenuFactory.getTestMenu(); jmb.add(testMenu); JMenu jm4 = new JMenu("Disabled"); jm4.add(new JMenuItem("dummy4")); jm4.setMnemonic('4'); jmb.add(jm4); jm4.setEnabled(false); // LAF changing jmb.add(SampleMenuFactory.getLookAndFeelMenu(this)); setJMenuBar(jmb); TabCloseCallback closeCallbackMain = new TabCloseCallback() { @Override public TabCloseKind onAreaClick( JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.getButton() != MouseEvent.BUTTON2) return TabCloseKind.NONE; if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } @Override public TabCloseKind onCloseButtonClick( JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.isAltDown()) { return TabCloseKind.ALL_BUT_THIS; } if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } @Override public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) { return null; } @Override public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) { StringBuffer result = new StringBuffer(); result.append("<html><body>"); result.append("Mouse click closes <b>" + tabbedPane.getTitleAt(tabIndex) + "</b> tab"); result.append( "<br><b>Alt</b>-Mouse click closes all tabs but <b>" + tabbedPane.getTitleAt(tabIndex) + "</b> tab"); result.append("<br><b>Shift</b>-Mouse click closes all tabs"); result.append("</body></html>"); return result.toString(); } }; jtp.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallbackMain); SubstanceLookAndFeel.registerTabCloseChangeListener( new TabCloseListener() { @Override public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) { out("Closed tab"); } @Override public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) { out("Closing tab"); } }); SubstanceLookAndFeel.registerTabCloseChangeListener( jtp, new VetoableTabCloseListener() { @Override public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) { out("Closed tab - specific"); } @Override public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) { out("Closing tab - specific"); } @Override public boolean vetoTabClosing(JTabbedPane tabbedPane, Component tabComponent) { int userCloseAnswer = JOptionPane.showConfirmDialog( Check.this, "Are you sure you want to close '" + tabbedPane.getTitleAt(tabbedPane.indexOfComponent(tabComponent)) + "' tab?", "Confirm dialog", JOptionPane.YES_NO_OPTION); return (userCloseAnswer == JOptionPane.NO_OPTION); } }); SubstanceLookAndFeel.registerTabCloseChangeListener( jtp, new VetoableMultipleTabCloseListener() { @Override public void tabsClosed(JTabbedPane tabbedPane, Set<Component> tabComponents) { out("Closed " + tabComponents.size() + " tabs - specific"); } @Override public void tabsClosing(JTabbedPane tabbedPane, Set<Component> tabComponents) { out("Closing " + tabComponents.size() + " tabs - specific"); } @Override public boolean vetoTabsClosing(JTabbedPane tabbedPane, Set<Component> tabComponents) { int userCloseAnswer = JOptionPane.showConfirmDialog( Check.this, "Are you sure you want to close " + tabComponents.size() + " tabs?", "Confirm dialog", JOptionPane.YES_NO_OPTION); return (userCloseAnswer == JOptionPane.NO_OPTION); } }); addComponentListener( new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { System.out.println("Size " + getSize()); } }); }
/** * Refreshes the title of the {@link #imagePane} from the model. Should be called when the model * changes. * * @param title The value to set. */ void setTitle(String title) { imagePane.setTitle(title); }