List of usage examples for javax.swing SwingConstants LEFT
int LEFT
To view the source code for javax.swing SwingConstants LEFT.
Click Source Link
From source file:edu.ku.brc.specify.tasks.subpane.ESResultsTablePanel.java
/** * Constructor of a results "table" which is really a panel * @param esrPane the parent/*from w w w. j a va 2s. co m*/ * @param erTableInfo the info describing the results * @param installServices indicates whether services should be installed * @param isExpandedAtStartUp enough said * @param inclCloseBtn whether to include the close button on the bar */ public ESResultsTablePanel(final ExpressSearchResultsPaneIFace esrPane, final QueryForIdResultsIFace results, final boolean installServices, final boolean isExpandedAtStartUp, final boolean inclCloseBtn) { super(new BorderLayout()); this.esrPane = esrPane; this.results = results; this.bannerColor = results.getBannerColor(); this.isEditable = results.isEditingEnabled(); table = new JTable(); table.setShowVerticalLines(false); table.setRowSelectionAllowed(true); table.setSelectionMode(results.isMultipleSelection() ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION : ListSelectionModel.SINGLE_SELECTION); setBackground(table.getBackground()); if (isEditable) { addContextMenu(); } topTitleBar = new GradiantLabel(results.getTitle(), SwingConstants.LEFT); topTitleBar.setBGBaseColor(bannerColor); topTitleBar.setTextColor(Color.WHITE); topTitleBar.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { expandBtn.doClick(); } } }); String description = results.getDescription(); if (StringUtils.isNotEmpty(description)) { topTitleBar.setToolTipText(description); } expandBtn = new TriangleButton(); expandBtn.setToolTipText(getResourceString("CollapseTBL")); expandBtn.setForeground(bannerColor); expandBtn.setTextColor(Color.WHITE); showTopNumEntriesBtn = new GradiantButton( String.format(getResourceString("ShowTopEntries"), new Object[] { topNumEntries })); showTopNumEntriesBtn.setForeground(bannerColor); showTopNumEntriesBtn.setTextColor(Color.WHITE); showTopNumEntriesBtn.setVisible(false); showTopNumEntriesBtn.setCursor(handCursor); List<ServiceInfo> services = installServices ? getServices() : null; //System.out.println("["+tableInfo.getTableId()+"]["+services.size()+"]"); StringBuffer colDef = new StringBuffer("p,0px,p:g,0px,p,0px,"); int numCols = (installServices ? services.size() : 0) + (inclCloseBtn ? 1 : 0); colDef.append(UIHelper.createDuplicateJGoodiesDef("p", "0px", numCols)); // add additional col defs for services PanelBuilder builder = new PanelBuilder(new FormLayout(colDef.toString(), "f:p:g")); CellConstraints cc = new CellConstraints(); int col = 1; builder.add(expandBtn, cc.xy(col, 1)); col += 2; builder.add(topTitleBar, cc.xy(col, 1)); col += 2; builder.add(showTopNumEntriesBtn, cc.xy(col, 1)); col += 2; if (installServices && services.size() > 0) { serviceBtns = new Hashtable<ServiceInfo, JButton>(); //IconManager.IconSize size = IconManager. int iconSize = AppPreferences.getLocalPrefs().getInt("banner.icon.size", 20); // Install the buttons on the banner with available services for (ServiceInfo serviceInfo : services) { GradiantButton btn = new GradiantButton(serviceInfo.getIcon(iconSize)); // XXX PREF btn.setToolTipText(serviceInfo.getTooltip()); btn.setForeground(bannerColor); builder.add(btn, cc.xy(col, 1)); ESTableAction esta = new ESTableAction(serviceInfo.getCommandAction(), table, serviceInfo.getTooltip()); esta.setProperty("gridtitle", results.getTitle()); btn.addActionListener(esta); serviceBtns.put(serviceInfo, btn); col += 2; } } GradiantButton closeBtn = null; if (inclCloseBtn) { closeBtn = new GradiantButton(IconManager.getIcon("Close")); closeBtn.setToolTipText(getResourceString("ESCloseTable")); closeBtn.setForeground(bannerColor); closeBtn.setRolloverEnabled(true); closeBtn.setRolloverIcon(IconManager.getIcon("CloseHover")); closeBtn.setPressedIcon(IconManager.getIcon("CloseHover")); builder.add(closeBtn, cc.xy(col, 1)); col += 2; } add(builder.getPanel(), BorderLayout.NORTH); tablePane = new JPanel(new BorderLayout()); setupTablePane(); if (isEditable) { //delRSItems = UIHelper.createI18NButton("RESTBL_DEL_ITEMS"); delRSItems = UIHelper.createIconBtn("DelRec", "ESDelRowsTT", null); delRSItems.addActionListener(createRemoveItemAL()); delRSItems.setEnabled(false); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { delRSItems.setEnabled(table.getSelectedRowCount() > 0); } } }); } add(tablePane, BorderLayout.CENTER); moveToRSCmd = new DragSelectedRowsBtn(IconManager.getIcon("Record_Set", IconManager.IconSize.Std16)); if (installServices) { PanelBuilder bottomBar = new PanelBuilder( new FormLayout("4px,p,4px,p,4px,p," + (delRSItems != null ? "4px,p," : "") + "f:p:g", "p")); bottomBar.add(moveToRSCmd, cc.xy(2, 1)); bottomBar.add(selectAllBtn, cc.xy(4, 1)); bottomBar.add(deselectAllBtn, cc.xy(6, 1)); if (delRSItems != null) { bottomBar.add(delRSItems, cc.xy(8, 1)); } botBtnPanel = bottomBar.getPanel(); deselectAllBtn.setEnabled(false); selectAllBtn.setEnabled(true); moveToRSCmd.setEnabled(true); deselectAllBtn.setToolTipText(getResourceString("SELALLTOOLTIP")); selectAllBtn.setToolTipText(getResourceString("DESELALLTOOLTIP")); moveToRSCmd.setToolTipText(getResourceString("MOVEROWSTOOLTIP")); selectAllBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { table.selectAll(); } }); deselectAllBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { table.clearSelection(); } }); moveToRSCmd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { RecordSetIFace src = (RecordSetIFace) moveToRSCmd.getData(); CommandDispatcher .dispatch(new CommandAction(RecordSetTask.RECORD_SET, "AskForNewRS", src, null, null)); } }); add(botBtnPanel, BorderLayout.SOUTH); } else { botBtnPanel = null; } expandBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { expandTable(false); } }); if (!isExpandedAtStartUp) { expandTable(true); } showTopNumEntriesBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { morePanel.setVisible(true); showTopNumEntriesBtn.setVisible(false); showingAllRows = false; setDisplayRows(rowCount, topNumEntries); // If it is collapsed then expand it if (!expandBtn.isDown()) { tablePane.setVisible(true); expandBtn.setDown(true); } // Make sure the layout is updated invalidate(); doLayout(); esrPane.revalidateScroll(); } }); if (closeBtn != null) { closeBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { removeMe(); } }); } }); } ResultSetTableModel rsm = createModel(); rsm.setPropertyListener(this); resultSetTableModel = rsm; table.setRowSorter(new TableRowSorter<ResultSetTableModel>(resultSetTableModel)); table.setRowSelectionAllowed(true); table.setModel(rsm); configColumns(); rowCount = rsm.getRowCount(); if (rowCount > topNumEntries + 2) { buildMorePanel(); setDisplayRows(rowCount, topNumEntries); } else { setDisplayRows(rowCount, Integer.MAX_VALUE); } invalidate(); doLayout(); UIRegistry.forceTopFrameRepaint(); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (botBtnPanel != null) { deselectAllBtn.setEnabled(table.getSelectedRowCount() > 0); selectAllBtn.setEnabled(table.getSelectedRowCount() != table.getRowCount()); moveToRSCmd.setEnabled(table.getSelectedRowCount() > 0); } } if (propChangeListener != null) { if (!e.getValueIsAdjusting()) { propChangeListener.propertyChange( new PropertyChangeEvent(this, "selection", table.getSelectedRowCount(), 0)); } else { propChangeListener.propertyChange( new PropertyChangeEvent(this, "selection", table.getSelectedRowCount(), 0)); } } } }); table.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { //synchronized (((JTable)e.getSource()).getTreeLock()) //{ doDoubleClickOnRow(e); //} } }); // Horizontal Alignment is set later TableColumnModel tableColModel = table.getColumnModel(); for (int i = 0; i < tableColModel.getColumnCount(); i++) { tableColModel.getColumn(i).setCellRenderer(new BiColorTableCellRenderer()); } }
From source file:gda.gui.beans.BeanBase.java
protected JLabel getLblUnits() { if (lblUnits == null) { lblUnits = new JLabel(); lblUnits.setText("units"); lblUnits.setHorizontalTextPosition(SwingConstants.LEFT); lblUnits.setHorizontalAlignment(SwingConstants.LEFT); }//from w w w .ja v a 2s . co m return lblUnits; }
From source file:edu.ku.brc.specify.utilapps.ERDTable.java
/** * @param font/*from w ww.ja v a 2 s.com*/ */ public void build(final Font font) { int numRows = 7; switch (displayType) { case All: numRows = 7; break; case MainFields: numRows = 7; break; case Title: numRows = 1; break; case TitleAndRel: numRows = 4; break; } Font bold = new Font(font.getFamily(), Font.BOLD, font.getSize()); Font italic = new Font(font.getFamily(), Font.ITALIC, font.getSize()); PanelBuilder pb = new PanelBuilder( new FormLayout("f:p:g", UIHelper.createDuplicateJGoodiesDef("p", "2px", numRows))); CellConstraints cc = new CellConstraints(); String className = StringUtils.substringAfterLast(table.getClassName(), "."); DBTableInfo tblInfo = DBTableIdMgr.getInstance().getByShortClassName(className); if (tblInfo == null) { throw new RuntimeException("Couldn't find table for className[" + className + "]"); } String tblName = tblInfo.getTitle(); int y = 1; pb.add(ERDVisualizer.mkLabel(bold, tblName, SwingConstants.CENTER), cc.xy(1, y)); y += 2; boolean doingAll = displayType == DisplayType.All; if (displayType == DisplayType.All || displayType == DisplayType.MainFields) { pb.addSeparator("", cc.xy(1, y)); y += 2; pb.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_FIELDS"), SwingConstants.CENTER), cc.xy(1, y)); y += 2; String colsDef = "p:g,4px,p:g,4px" + (doingAll ? ",p:g,4px,p:g,4px" : "") + ",f:p:g"; PanelBuilder fieldsPB = new PanelBuilder(new FormLayout(colsDef, UIHelper.createDuplicateJGoodiesDef("p", "2px", table.getFields().size() + 2))); int yy = 1; fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_FIELD"), SwingConstants.LEFT), cc.xy(1, yy)); fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_TYPE"), SwingConstants.CENTER), cc.xy(3, yy)); fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_LENGTH"), SwingConstants.CENTER), cc.xy(5, yy)); if (doingAll) { fieldsPB.add( ERDVisualizer.mkLabel(italic, getResourceString("ERD_REQUIRED"), SwingConstants.CENTER), cc.xy(7, yy)); fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_UNIQUE"), SwingConstants.CENTER), cc.xy(9, yy)); } yy += 2; if (StringUtils.isNotEmpty(table.getIdColumnName())) { build(fieldsPB, table, font, yy, doingAll); // does ID yy += 2; } for (DBFieldInfo f : table.getFields()) { build(fieldsPB, f, font, yy, doingAll); yy += 2; } pb.add(fieldsPB.getPanel(), cc.xy(1, y)); y += 2; } if ((displayType == DisplayType.All || displayType == DisplayType.TitleAndRel) && table.getRelationships().size() > 0) { pb.addSeparator("", cc.xy(1, y)); y += 2; pb.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_RELATIONSHIPS"), SwingConstants.CENTER), cc.xy(1, y)); y += 2; String colsDef = "p:g,4px,p:g,4px" + (doingAll ? ",p:g,4px" : "") + ",f:p:g"; PanelBuilder relsPB = new PanelBuilder(new FormLayout(colsDef, UIHelper.createDuplicateJGoodiesDef("p", "2px", table.getRelationships().size() + 1))); int yy = 1; relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_TABLE"), SwingConstants.LEFT), cc.xy(1, yy)); relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_NAME"), SwingConstants.CENTER), cc.xy(3, yy)); relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_TYPE"), SwingConstants.CENTER), cc.xy(5, yy)); if (doingAll) { relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_REQUIRED"), SwingConstants.CENTER), cc.xy(7, yy)); } yy += 2; Vector<DBRelationshipInfo> orderedList = new Vector<DBRelationshipInfo>(table.getRelationships()); Collections.sort(orderedList, new Comparator<DBRelationshipInfo>() { public int compare(DBRelationshipInfo o1, DBRelationshipInfo o2) { String name1 = ((DBRelationshipInfo) o1).getClassName(); if (name1.startsWith("Sp")) { name1 = name1.substring(2, name1.length()); } String name2 = ((DBRelationshipInfo) o2).getClassName(); if (name2.startsWith("Sp")) { name2 = name2.substring(2, name2.length()); } return name1.compareTo(name2); } }); for (DBRelationshipInfo r : orderedList) { //System.out.println(r.getName()+" "+r.getType()); if (!r.getName().toLowerCase().endsWith("iface")) { JComponent p = build(relsPB, r, font, yy, doingAll); relUIHash.put(r, p); yy += 2; } } pb.add(relsPB.getPanel(), cc.xy(1, y)); y += 2; //fieldsPB.getPanel().setBackground(Color.GREEN); //relsPB.getPanel().setBackground(Color.BLUE); } inner = pb.getPanel(); //inner.setBorder(BorderFactory.createEmptyBorder(BRD_GAP, BRD_GAP, BRD_GAP, BRD_GAP)); inner.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK), BorderFactory.createEmptyBorder(BRD_GAP, BRD_GAP, BRD_GAP, BRD_GAP))); setBackground(Color.WHITE); add(inner, BorderLayout.CENTER); }
From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.table.JTableInfoForCMFolder.java
synchronized public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);/*from w ww .j av a 2 s . com*/ if (value == null) { comp.setToolTipText(null); return comp; } comp.setToolTipText(String.valueOf(value)); if (row >= table.getRowCount()) { log.debug("row > table.getRowCount()"); return comp; } switch (column) { case TableModelForCMFolder.COL_COMPONENT_NAME: case TableModelForCMFolder.COL_LICENSE_NAME: setHorizontalAlignment(SwingConstants.LEFT); break; case TableModelForCMFolder.COL_VERSION_NAME: case TableModelForCMFolder.COL_IDENTIFIED: case TableModelForCMFolder.COL_STATUS: case TableModelForCMFolder.COL_PENDING: setHorizontalAlignment(SwingConstants.CENTER); break; } int pendingHits = 0; int identifiedHits = 0; if (table.getValueAt(row, TableModelForCMFolder.COL_PENDING) != null) { pendingHits = Tools .transStringToInteger(table.getValueAt(row, TableModelForCMFolder.COL_PENDING).toString()); } if (table.getValueAt(row, TableModelForCMFolder.COL_IDENTIFIED) != null) { identifiedHits = Tools .transStringToInteger(table.getValueAt(row, TableModelForCMFolder.COL_IDENTIFIED).toString()); } if (identifiedHits > 0 && pendingHits == 0) { comp.setFont(new Font("Arial", Font.BOLD, 12)); comp.setForeground(NORMAL_COLOR); } else if (identifiedHits == 0 && pendingHits == 0) { comp.setForeground(GRAY_COLOR); } else { comp.setForeground(NORMAL_COLOR); } return comp; }
From source file:dpcs.About.java
public About() { setIconImage(Toolkit.getDefaultToolkit().getImage(About.class.getResource("/graphics/Icon.png"))); setResizable(false);/*from w w w . j av a2 s .c o m*/ setType(Type.UTILITY); setTitle("About"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(100, 100, 540, 400); contentPane = new JPanel(); contentPane.setBackground(Color.WHITE); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); try { InputStreamReader reader2 = new InputStreamReader( getClass().getResourceAsStream("/others/app-version.txt")); String tmp = IOUtils.toString(reader2); AppVersion = Double.parseDouble(tmp); } catch (IOException e1) { e1.printStackTrace(); } JButton btnGitHub = new JButton("GitHub"); btnGitHub.setToolTipText("Access Droid PC Suite github repository"); btnGitHub.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { Desktop.getDesktop().browse(new URL("https://github.com/kvsjxd/Droid-PC-Suite/").toURI()); } catch (Exception e) { e.printStackTrace(); } } }); btnGitHub.setBounds(369, 295, 111, 25); contentPane.add(btnGitHub); JLabel lblMyFriend4 = new JLabel("Gulati-kun"); lblMyFriend4.setFont(new Font("Dialog", Font.PLAIN, 15)); lblMyFriend4.setBounds(25, 266, 242, 24); contentPane.add(lblMyFriend4); JLabel lblMyFriend3 = new JLabel("Anil-kun"); lblMyFriend3.setFont(new Font("Dialog", Font.PLAIN, 15)); lblMyFriend3.setBounds(25, 242, 242, 24); contentPane.add(lblMyFriend3); JLabel lblMyFriend2 = new JLabel("Suri-kun"); lblMyFriend2.setFont(new Font("Dialog", Font.PLAIN, 15)); lblMyFriend2.setBounds(25, 217, 242, 24); contentPane.add(lblMyFriend2); JLabel lblApplicationVersion = new JLabel("Version: " + AppVersion); lblApplicationVersion.setFont(new Font("Dialog", Font.BOLD, 14)); lblApplicationVersion.setBounds(382, 16, 132, 18); contentPane.add(lblApplicationVersion); JLabel lblForMyOther = new JLabel("For my other Android stuff visit me on XDA - Developers (@kvsjxd)"); lblForMyOther.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { try { Desktop.getDesktop().browse(new URL( "http://forum.xda-developers.com/member.php?s=82fb1dacfee601c8f79084b30d57d5a2&u=5640594") .toURI()); } catch (Exception e) { e.printStackTrace(); } } @Override public void mouseEntered(MouseEvent e) { lblForMyOther.setForeground(Color.BLUE); } @Override public void mouseExited(MouseEvent e) { lblForMyOther.setForeground(Color.BLACK); } }); lblForMyOther.setFont(new Font("Dialog", Font.PLAIN, 15)); lblForMyOther.setBounds(25, 321, 502, 24); contentPane.add(lblForMyOther); JLabel lblMySensei2 = new JLabel("Karun Sensei"); lblMySensei2.setFont(new Font("Dialog", Font.PLAIN, 15)); lblMySensei2.setBounds(25, 120, 242, 24); contentPane.add(lblMySensei2); JLabel lblMySensei1 = new JLabel("Prashotam Sensei"); lblMySensei1.setFont(new Font("Dialog", Font.PLAIN, 15)); lblMySensei1.setBounds(25, 98, 242, 24); contentPane.add(lblMySensei1); JLabel lblDaretobe = new JLabel("D4r3T0B3"); lblDaretobe.setFont(new Font("Dialog", Font.PLAIN, 15)); lblDaretobe.setBounds(25, 194, 242, 24); contentPane.add(lblDaretobe); JLabel label_9 = new JLabel(""); label_9.setToolTipText("This variation of android robot is created using Androidify"); label_9.setIcon(new ImageIcon(About.class.getResource("/graphics/Droidrobot.png"))); label_9.setBounds(334, 50, 180, 270); contentPane.add(label_9); JLabel lblDeveloper = new JLabel("Developer"); lblDeveloper.setFont(new Font("Dialog", Font.BOLD, 16)); lblDeveloper.setBounds(25, 12, 233, 24); contentPane.add(lblDeveloper); JLabel lblMrAleksandarDespotovski_shi = new JLabel("Aleksandar Despotovski-shi"); lblMrAleksandarDespotovski_shi.setFont(new Font("Dialog", Font.PLAIN, 15)); lblMrAleksandarDespotovski_shi.setBounds(25, 169, 242, 24); contentPane.add(lblMrAleksandarDespotovski_shi); JLabel lblMyname = new JLabel("Karanvir Singh"); lblMyname.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { try { Desktop.getDesktop().browse(new URL( "http://forum.xda-developers.com/member.php?s=82fb1dacfee601c8f79084b30d57d5a2&u=5640594") .toURI()); } catch (Exception e1) { e1.printStackTrace(); } } @Override public void mouseEntered(MouseEvent e) { lblMyname.setForeground(Color.BLUE); } @Override public void mouseExited(MouseEvent e) { lblMyname.setForeground(Color.RED); } }); lblMyname.setForeground(Color.RED); lblMyname.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 16)); lblMyname.setBounds(25, 36, 242, 24); contentPane.add(lblMyname); JLabel lblMyFriend1 = new JLabel("My friend - Chetan-kun"); lblMyFriend1.setFont(new Font("Dialog", Font.PLAIN, 15)); lblMyFriend1.setBounds(25, 145, 242, 24); contentPane.add(lblMyFriend1); JLabel label_6 = new JLabel("Special thanks to"); label_6.setForeground(UIManager.getColor("OptionPane.questionDialog.titlePane.shadow")); label_6.setFont(new Font("Dialog", Font.BOLD, 16)); label_6.setBounds(25, 71, 240, 25); contentPane.add(label_6); JLabel lblGoogle = new JLabel( "Android, android green colored robot are trademarks of Google, Inc. We are not affliated with Google, Inc. in any way."); lblGoogle.setHorizontalAlignment(SwingConstants.LEFT); lblGoogle.setFont(new Font("Dialog", Font.PLAIN, 8)); lblGoogle.setBounds(25, 341, 514, 24); contentPane.add(lblGoogle); }
From source file:edu.ku.brc.stats.StatGroupTable.java
/** * Constructor with the localized name of the Group * @param name name of the group (already been localized) * @param useSeparator use non-border separator titles *///from ww w. ja v a 2s. c o m public StatGroupTable(final String name, final String[] columnNames, final boolean useSeparator, final int numRows) { this.name = name; this.useSeparator = useSeparator; this.skinItem = SkinsMgr.getSkinItem("StatGroup"); if (progressIcon == null) { progressIcon = IconManager.getIcon("Progress", IconManager.IconSize.Std16); } setLayout(new BorderLayout()); setBackground(Color.WHITE); model = new StatGroupTableModel(this, columnNames); //table = numRows > SCROLLPANE_THRESOLD ? (new SortableJTable(new SortableTableModel(model))) : (new JTable(model)); if (numRows > SCROLLPANE_THRESOLD) { table = new SortableJTable(new SortableTableModel(model)) { protected void configureEnclosingScrollPane() { Container p = getParent(); if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; // Make certain we are the viewPort's view and not, for // example, the rowHeaderView of the scrollPane - // an implementor of fixed columns might do this. JViewport viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) { return; } // scrollPane.setColumnHeaderView(getTableHeader()); //scrollPane.getViewport().setBackingStoreEnabled(true); scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder")); } } } }; } else { table = new JTable(model) { protected void configureEnclosingScrollPane() { Container p = getParent(); if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; // Make certain we are the viewPort's view and not, for // example, the rowHeaderView of the scrollPane - // an implementor of fixed columns might do this. JViewport viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) { return; } // scrollPane.setColumnHeaderView(getTableHeader()); //scrollPane.getViewport().setBackingStoreEnabled(true); scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder")); } } } }; } table.setShowVerticalLines(false); table.setShowHorizontalLines(false); if (SkinsMgr.shouldBeOpaque(skinItem)) { table.setOpaque(false); setOpaque(false); } else { table.setOpaque(true); setOpaque(true); } table.addMouseMotionListener(new TableMouseMotion()); table.addMouseListener(new LinkListener()); if (table.getColumnModel().getColumnCount() == 1) { table.getColumnModel().getColumn(0) .setCellRenderer(new StatGroupTableCellRenderer(SwingConstants.CENTER, 1)); } else { table.getColumnModel().getColumn(0) .setCellRenderer(new StatGroupTableCellRenderer(SwingConstants.LEFT, 2)); table.getColumnModel().getColumn(1) .setCellRenderer(new StatGroupTableCellRenderer(SwingConstants.RIGHT, 2)); } //table.setRowSelectionAllowed(true); if (numRows > SCROLLPANE_THRESOLD) { scrollPane = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); if (table instanceof SortableJTable) { ((SortableJTable) table).installColumnHeaderListeners(); } scrollPane.setOpaque(false); scrollPane.getViewport().setOpaque(false); scrollPane.setBorder(BorderFactory.createEmptyBorder()); //scrollPane.getViewport().setBorder(BorderFactory.createEmptyBorder()); } if (useSeparator) { setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); CellConstraints cc = new CellConstraints(); if (StringUtils.isNotEmpty(name)) { builder.addSeparator(name, cc.xy(1, 1)); } builder.add(scrollPane != null ? scrollPane : table, cc.xy(1, 2)); builder.getPanel().setOpaque(false); add(builder.getPanel()); } else { setBorder(BorderFactory.createEmptyBorder(15, 2, 2, 2)); setBorder(BorderFactory.createCompoundBorder(new CurvedBorder(new Color(160, 160, 160)), getBorder())); add(scrollPane != null ? scrollPane : table, BorderLayout.CENTER); } }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRInputController.java
/** * Get conditions according to selection in list and add to the * dose-response analysis group//from w w w . j a va2s . co m */ @Override protected void addToDRAnalysis() { List<PlateCondition> selectedConditions = getSelectedConditions(); if (selectedConditions != null) { for (PlateCondition selectedCondition : selectedConditions) { //only add to list if list does not contain this condition already if (!plateConditionsList.contains(selectedCondition)) { plateConditionsList.add(selectedCondition); AreaAnalysisResults areaAnalysisResults = doseResponseController.getLinearResultsAnalysisMap() .get(selectedCondition); areaAnalysisResultsList.add(areaAnalysisResults); } } // make a new analysis group, with those conditions and those results // override variable if one existed already doseResponseController.setdRAnalysisGroup( new AreaDoseResponseAnalysisGroup(plateConditionsList, areaAnalysisResultsList)); // check treatments, dialog pops up if necessary checkTreatments(doseResponseController.getdRAnalysisGroup(), chooseTreatmentDialog); // populate bottom table with the analysis group slopesTable.setModel(createTableModel(doseResponseController.getdRAnalysisGroup())); slopesTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT)); } }
From source file:edu.ku.brc.specify.plugins.sgr.SGRResultsDisplay.java
/** * From http://www.pikopong.com/blog/2008/08/13/auto-resize-jtable-column-width/ * /* w ww. jav a 2 s .c o m*/ * @param table * @param model * @return */ private JTable autoResizeColWidth(JTable table, DefaultTableModel model) { table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.setModel(model); int margin = 5; for (int i = 0; i < table.getColumnCount(); i++) { int vColIndex = i; DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel(); TableColumn col = colModel.getColumn(vColIndex); int width = 0; // Get width of column header TableCellRenderer renderer = col.getHeaderRenderer(); if (renderer == null) { renderer = table.getTableHeader().getDefaultRenderer(); } Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0, 0); width = comp.getPreferredSize().width; // Get maximum width of column data for (int r = 0; r < table.getRowCount(); r++) { renderer = table.getCellRenderer(r, vColIndex); comp = renderer.getTableCellRendererComponent(table, table.getValueAt(r, vColIndex), false, false, r, vColIndex); width = Math.max(width, comp.getPreferredSize().width); } // Add margin width += 2 * margin; // Set the width col.setPreferredWidth(width); } ((DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer()) .setHorizontalAlignment(SwingConstants.LEFT); // table.setAutoCreateRowSorter(true); //table.getTableHeader().setReorderingAllowed(false); return table; }
From source file:be.ac.ua.comp.scarletnebula.gui.ServerCellRenderer.java
private Component getNewServerServer(final JList list, final int index, final boolean isSelected) { final JPanel p = createServerPanel(null, list, index, isSelected); final JLabel label = new JLabel("Start a new server", new ImageIcon(getClass().getResource("/images/add.png")), SwingConstants.LEFT); label.setFont(new Font(label.getFont().getName(), Font.PLAIN, 16)); // Border for better horizontal alignment label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 12)); p.add(label);//w ww . j a va2s. com return p; }
From source file:com.simplexrepaginator.RepaginateFrame.java
protected JButton creatOutputButton() { JButton b = new JButton("Click or drag to set output file", PDF_1234); b.setHorizontalTextPosition(SwingConstants.LEFT); b.setIconTextGap(25);//www.j a v a 2s . com b.setTransferHandler(new OutputButtonTransferHandler()); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); if (chooser.showOpenDialog(RepaginateFrame.this) != JFileChooser.APPROVE_OPTION) return; repaginator.setOutputFiles(Arrays.asList(chooser.getSelectedFiles())); output.setText("<html><center>" + StringUtils.join(repaginator.getOutputFiles(), "<br>")); } }); return b; }