List of usage examples for javax.swing SwingConstants SOUTH
int SOUTH
To view the source code for javax.swing SwingConstants SOUTH.
Click Source Link
From source file:Main.java
public static void validateDirection(int direction) { if (direction != SwingConstants.NORTH && direction != SwingConstants.EAST && direction != SwingConstants.SOUTH && direction != SwingConstants.WEST) { throw new IllegalArgumentException("invalid direction"); }//from w ww.ja va 2 s . c o m }
From source file:Main.java
public static Window showBelow(Component parent, Window window, int horizontalAlignment) { final int DISTANCE = 2; if (null == parent) throw new IllegalArgumentException("parent null"); if (null == window) throw new IllegalArgumentException("parent null"); if (!((SwingConstants.LEADING == horizontalAlignment) || (SwingConstants.TRAILING == horizontalAlignment) || (SwingConstants.CENTER == horizontalAlignment) || (SwingConstants.SOUTH == horizontalAlignment))) { throw new IllegalArgumentException("Illegal horizontal alignment " + horizontalAlignment + " should be either SwingConstants.LEADING or " + "SwingConstants.TRAILING or SwingConstants.CENTER"); }// w w w . jav a2s.com window.pack(); Dimension windowSize = window.getPreferredSize(); Dimension parentSize = parent.getSize(); Point loc = parent.getLocationOnScreen(); int newX; if ((SwingConstants.CENTER == horizontalAlignment) || (SwingConstants.SOUTH == horizontalAlignment)) { newX = (parentSize.width - windowSize.width) / 2 + loc.x; } else if (SwingConstants.TRAILING == horizontalAlignment) { newX = loc.x + parentSize.width - windowSize.width; } else { newX = loc.x; } window.setLocation(newX, (loc.y + parentSize.height + DISTANCE)); window.setVisible(true); return window; }
From source file:Main.java
protected void createComponents() { if (orientation == SwingConstants.VERTICAL) { setLayout(new GridLayout(2, 1)); incrementButton = new BasicArrowButton(SwingConstants.NORTH); decrementButton = new BasicArrowButton(SwingConstants.SOUTH); add(incrementButton);/*from w w w . j a v a2 s.c om*/ add(decrementButton); } else if (orientation == SwingConstants.HORIZONTAL) { setLayout(new GridLayout(1, 2)); incrementButton = new BasicArrowButton(SwingConstants.EAST); decrementButton = new BasicArrowButton(SwingConstants.WEST); add(decrementButton); add(incrementButton); } }
From source file:Main.java
public static Point arrangeWithin(final Shape shapeToArrange, final Rectangle window, final int arrangement, Insets padding) {/*w ww .j a v a 2 s .c o m*/ if (shapeToArrange == null) throw new IllegalArgumentException("Parameter 'shapeToArrange' must not be null!"); if (window == null) throw new IllegalArgumentException("Parameter 'window' must not be null!"); if (padding == null) padding = new Insets(0, 0, 0, 0); final Rectangle bounds = shapeToArrange.getBounds(); switch (arrangement) { case SwingConstants.NORTH: return new Point((window.width - bounds.width) / 2, padding.top); case SwingConstants.NORTH_EAST: return new Point(window.width - padding.right, padding.top); case SwingConstants.EAST: return new Point(window.width - padding.right, (window.height - bounds.height) / 2); case SwingConstants.SOUTH_EAST: return new Point(window.width - padding.right, window.height - padding.bottom); case SwingConstants.SOUTH: return new Point((window.width - bounds.width) / 2, window.height - padding.bottom); case SwingConstants.SOUTH_WEST: return new Point(padding.left, window.height - padding.bottom); case SwingConstants.WEST: return new Point(padding.left, (window.height - bounds.height) / 2); case SwingConstants.NORTH_WEST: return new Point(padding.left, padding.top); case SwingConstants.CENTER: return new Point((window.width - bounds.width) / 2, (window.height - bounds.height) / 2); default: throw new IllegalArgumentException("Illegal arrangement key, expected one of the SwingConstants keys"); } }
From source file:PaintUtils.java
/** Uses translucent shades of white and black to draw highlights * and shadows around a rectangle, and then frames the rectangle * with a shade of gray (120).//from w ww . j a va2 s . c om * <P>This should be called to add a finishing touch on top of * existing graphics. * @param g the graphics to paint to. * @param r the rectangle to paint. */ public static void drawBevel(Graphics g, Rectangle r) { drawColors(blacks, g, r.x, r.y + r.height, r.x + r.width, r.y + r.height, SwingConstants.SOUTH); drawColors(blacks, g, r.x + r.width, r.y, r.x + r.width, r.y + r.height, SwingConstants.EAST); drawColors(whites, g, r.x, r.y, r.x + r.width, r.y, SwingConstants.NORTH); drawColors(whites, g, r.x, r.y, r.x, r.y + r.height, SwingConstants.WEST); g.setColor(new Color(120, 120, 120)); g.drawRect(r.x, r.y, r.width, r.height); }
From source file:Main.java
public Dimension getMinimumSize() { return new Dimension( arrowSize * (direction == SwingConstants.EAST || direction == SwingConstants.WEST ? arrowCount : 3) + getBorder().getBorderInsets(this).left + getBorder().getBorderInsets(this).right, arrowSize/* ww w.j av a 2 s. c om*/ * (direction == SwingConstants.NORTH || direction == SwingConstants.SOUTH ? arrowCount : 3) + getBorder().getBorderInsets(this).top + getBorder().getBorderInsets(this).bottom); }
From source file:PaintUtils.java
private static void drawColors(Color[] colors, Graphics g, int x1, int y1, int x2, int y2, int direction) { for (int a = 0; a < colors.length; a++) { g.setColor(colors[colors.length - a - 1]); if (direction == SwingConstants.SOUTH) { g.drawLine(x1, y1 - a, x2, y2 - a); } else if (direction == SwingConstants.NORTH) { g.drawLine(x1, y1 + a, x2, y2 + a); } else if (direction == SwingConstants.EAST) { g.drawLine(x1 - a, y1, x2 - a, y2); } else if (direction == SwingConstants.WEST) { g.drawLine(x1 + a, y1, x2 + a, y2); }//from ww w . j a v a 2s .co m } }
From source file:SortedTableModel.java
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component text;/*from w ww. j av a 2s.c om*/ JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); if (textRenderer != null) { text = textRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } else { text = new JLabel((String) value, JLabel.CENTER); LookAndFeel.installColorsAndFont((JComponent) text, "TableHeader.background", "TableHeader.foreground", "TableHeader.font"); } panel.add(text, BorderLayout.CENTER); if (column == sortColumn) { BasicArrowButton bab = new BasicArrowButton( (sortAscending ? SwingConstants.NORTH : SwingConstants.SOUTH)); panel.add(bab, BorderLayout.WEST); } LookAndFeel.installBorder(panel, "TableHeader.cellBorder"); return panel; }
From source file:mondrian.gui.Workbench.java
/** * This method is called from within the constructor to * initialize the form.//from w w w. j a v a 2s .c o m */ private void initComponents() { desktopPane = new javax.swing.JDesktopPane(); jToolBar1 = new javax.swing.JToolBar(); jToolBar2 = new javax.swing.JToolBar(); toolbarNewPopupMenu = new JPopupMenu(); toolbarNewButton = new javax.swing.JButton(); toolbarOpenButton = new javax.swing.JButton(); toolbarSaveButton = new javax.swing.JButton(); toolbarSaveAsButton = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); toolbarPreferencesButton = new javax.swing.JButton(); requireSchemaCheckboxMenuItem = new javax.swing.JCheckBoxMenuItem(); menuBar = new javax.swing.JMenuBar(); fileMenu = new javax.swing.JMenu(); newMenu = new javax.swing.JMenu(); newSchemaMenuItem = new javax.swing.JMenuItem(); newQueryMenuItem = new javax.swing.JMenuItem(); newJDBCExplorerMenuItem = new javax.swing.JMenuItem(); newSchemaMenuItem2 = new javax.swing.JMenuItem(); newQueryMenuItem2 = new javax.swing.JMenuItem(); newJDBCExplorerMenuItem2 = new javax.swing.JMenuItem(); openMenuItem = new javax.swing.JMenuItem(); preferencesMenuItem = new javax.swing.JMenuItem(); lastUsed1MenuItem = new javax.swing.JMenuItem(); lastUsed2MenuItem = new javax.swing.JMenuItem(); lastUsed3MenuItem = new javax.swing.JMenuItem(); lastUsed4MenuItem = new javax.swing.JMenuItem(); saveMenuItem = new javax.swing.JMenuItem(); saveAsMenuItem = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JSeparator(); jSeparator2 = new javax.swing.JSeparator(); jSeparator3 = new javax.swing.JSeparator(); exitMenuItem = new javax.swing.JMenuItem(); windowMenu = new javax.swing.JMenu(); helpMenu = new javax.swing.JMenu(); editMenu = new javax.swing.JMenu(); cutMenuItem = new javax.swing.JMenuItem(new DefaultEditorKit.CutAction()); copyMenuItem = new javax.swing.JMenuItem(new DefaultEditorKit.CopyAction()); pasteMenuItem = new javax.swing.JMenuItem(new DefaultEditorKit.PasteAction()); deleteMenuItem = new javax.swing.JMenuItem( new AbstractAction(getResourceConverter().getString("workbench.menu.delete", "Delete")) { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { JInternalFrame jf = desktopPane.getSelectedFrame(); if (jf != null && jf.getContentPane().getComponent(0) instanceof SchemaExplorer) { SchemaExplorer se = (SchemaExplorer) jf.getContentPane().getComponent(0); TreePath tpath = se.tree.getSelectionPath(); se.delete(tpath); } } }); aboutMenuItem = new javax.swing.JMenuItem(); toolsMenu = new javax.swing.JMenu(); viewMenu = new javax.swing.JMenu(); viewXmlMenuItem = new javax.swing.JCheckBoxMenuItem(); setTitle(getResourceConverter().getString("workbench.panel.title", "Schema Workbench")); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { storeWorkbenchProperties(); storeDatabaseMeta(); closeAllSchemaFrames(true); } }); getContentPane().add(desktopPane, java.awt.BorderLayout.CENTER); newSchemaMenuItem2.setText(getResourceConverter().getString("workbench.menu.newSchema", "Schema")); newSchemaMenuItem2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { newSchemaMenuItemActionPerformed(evt); } }); newQueryMenuItem2.setText(getResourceConverter().getString("workbench.menu.newQuery", "MDX Query")); newQueryMenuItem2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { newQueryMenuItemActionPerformed(evt); } }); newJDBCExplorerMenuItem2 .setText(getResourceConverter().getString("workbench.menu.newJDBC", "JDBC Explorer")); newJDBCExplorerMenuItem2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { newJDBCExplorerMenuItemActionPerformed(evt); } }); toolbarNewPopupMenu.add(newSchemaMenuItem2); toolbarNewPopupMenu.add(newQueryMenuItem2); toolbarNewPopupMenu.add(newJDBCExplorerMenuItem2); jPanel2.setLayout(new java.awt.BorderLayout()); jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jPanel2.setMaximumSize(new java.awt.Dimension(50, 28)); toolbarNewButton.setIcon( new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("new")))); toolbarNewButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.new", "New")); toolbarNewButton.setBorderPainted(false); toolbarNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { toolbarNewPopupMenu.show(jPanel2, 0, jPanel2.getSize().height); } }); jToolBar2.setFloatable(false); jToolBar2.add(toolbarNewButton); jPanel2.add(jToolBar2, java.awt.BorderLayout.CENTER); toolbarNewArrowButton = new BasicArrowButton(SwingConstants.SOUTH); toolbarNewArrowButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.newArrow", "New")); toolbarNewArrowButton.setBorderPainted(false); toolbarNewArrowButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { toolbarNewPopupMenu.show(jPanel2, 0, jPanel2.getSize().height); } }); jPanel2.add(toolbarNewArrowButton, java.awt.BorderLayout.EAST); jToolBar1.add(jPanel2, 0); toolbarOpenButton.setIcon( new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("open")))); toolbarOpenButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.open", "Open")); toolbarOpenButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { openMenuItemActionPerformed(evt); } }); jToolBar1.add(toolbarOpenButton); toolbarSaveButton.setIcon( new javax.swing.ImageIcon(getClass().getResource(getResourceConverter().getGUIReference("save")))); toolbarSaveButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.save", "Save")); toolbarSaveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveMenuItemActionPerformed(evt); } }); jToolBar1.add(toolbarSaveButton); toolbarSaveAsButton.setIcon(new javax.swing.ImageIcon( getClass().getResource(getResourceConverter().getGUIReference("saveAs")))); toolbarSaveAsButton.setToolTipText(getResourceConverter().getString("workbench.toolbar.saveAs", "Save As")); toolbarSaveAsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveAsMenuItemActionPerformed(evt); } }); jToolBar1.add(toolbarSaveAsButton); jPanel1.setMaximumSize(new java.awt.Dimension(8, 8)); jToolBar1.add(jPanel1); toolbarPreferencesButton.setIcon(new javax.swing.ImageIcon( getClass().getResource(getResourceConverter().getGUIReference("preferences")))); toolbarPreferencesButton .setToolTipText(getResourceConverter().getString("workbench.toolbar.connection", "Connection")); toolbarPreferencesButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { connectionButtonActionPerformed(evt); } }); jToolBar1.add(toolbarPreferencesButton); getContentPane().add(jToolBar1, java.awt.BorderLayout.NORTH); fileMenu.setText(getResourceConverter().getString("workbench.menu.file", "File")); fileMenu.setMnemonic(KeyEvent.VK_F); newMenu.setText(getResourceConverter().getString("workbench.menu.new", "New")); newSchemaMenuItem.setText(getResourceConverter().getString("workbench.menu.newSchema", "Schema")); newSchemaMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { newSchemaMenuItemActionPerformed(evt); } }); newMenu.add(newSchemaMenuItem); newQueryMenuItem.setText(getResourceConverter().getString("workbench.menu.newQuery", "MDX Query")); newQueryMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { newQueryMenuItemActionPerformed(evt); } }); newMenu.add(newQueryMenuItem); newJDBCExplorerMenuItem .setText(getResourceConverter().getString("workbench.menu.newJDBC", "JDBC Explorer")); newJDBCExplorerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { newJDBCExplorerMenuItemActionPerformed(evt); } }); newMenu.add(newJDBCExplorerMenuItem); fileMenu.add(newMenu); openMenuItem.setText(getResourceConverter().getString("workbench.menu.open", "Open")); openMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { openMenuItemActionPerformed(evt); } }); fileMenu.add(openMenuItem); saveMenuItem.setText(getResourceConverter().getString("workbench.menu.save", "Save")); saveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveMenuItemActionPerformed(evt); } }); fileMenu.add(saveMenuItem); saveAsMenuItem.setText(getResourceConverter().getString("workbench.menu.saveAsDot", "Save As ...")); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveAsMenuItemActionPerformed(evt); } }); fileMenu.add(saveAsMenuItem); // add last used fileMenu.add(jSeparator2); lastUsed1MenuItem.setText(getWorkbenchProperty("lastUsed1")); lastUsed1MenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { lastUsed1MenuItemActionPerformed(evt); } }); fileMenu.add(lastUsed1MenuItem); lastUsed2MenuItem.setText(getWorkbenchProperty("lastUsed2")); lastUsed2MenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { lastUsed2MenuItemActionPerformed(evt); } }); fileMenu.add(lastUsed2MenuItem); lastUsed3MenuItem.setText(getWorkbenchProperty("lastUsed3")); lastUsed3MenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { lastUsed3MenuItemActionPerformed(evt); } }); fileMenu.add(lastUsed3MenuItem); lastUsed4MenuItem.setText(getWorkbenchProperty("lastUsed4")); lastUsed4MenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { lastUsed4MenuItemActionPerformed(evt); } }); fileMenu.add(lastUsed4MenuItem); updateLastUsedMenu(); fileMenu.add(jSeparator1); exitMenuItem.setText(getResourceConverter().getString("workbench.menu.exit", "Exit")); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { exitMenuItemActionPerformed(evt); } }); fileMenu.add(exitMenuItem); menuBar.add(fileMenu); editMenu.setText(getResourceConverter().getString("workbench.menu.edit", "Edit")); editMenu.setMnemonic(KeyEvent.VK_E); cutMenuItem.setText(getResourceConverter().getString("workbench.menu.cut", "Cut")); editMenu.add(cutMenuItem); copyMenuItem.setText(getResourceConverter().getString("workbench.menu.copy", "Copy")); editMenu.add(copyMenuItem); pasteMenuItem.setText(getResourceConverter().getString("workbench.menu.paste", "Paste")); editMenu.add(pasteMenuItem); editMenu.add(deleteMenuItem); menuBar.add(editMenu); viewMenu.setText(getResourceConverter().getString("workbench.menu.view", "View")); viewMenu.setMnemonic(KeyEvent.VK_V); viewXmlMenuItem.setText(getResourceConverter().getString("workbench.menu.viewXML", "View XML")); viewXmlMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { viewXMLMenuItemActionPerformed(evt); } }); viewMenu.add(viewXmlMenuItem); menuBar.add(viewMenu); toolsMenu.setText(getResourceConverter().getString("workbench.menu.options", "Options")); toolsMenu.setMnemonic(KeyEvent.VK_O); preferencesMenuItem.setText(getResourceConverter().getString("workbench.menu.connection", "Connection")); preferencesMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { connectionButtonActionPerformed(evt); } }); toolsMenu.add(preferencesMenuItem); requireSchemaCheckboxMenuItem .setText(getResourceConverter().getString("workbench.menu.requireSchema", "Require Schema")); requireSchemaCheckboxMenuItem.setSelected(requireSchema); requireSchemaCheckboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { requireSchemaActionPerformed(e); } }); toolsMenu.add(requireSchemaCheckboxMenuItem); menuBar.add(toolsMenu); windowMenu.setText(getResourceConverter().getString("workbench.menu.windows", "Windows")); windowMenu.setMnemonic(KeyEvent.VK_W); cascadeMenuItem = new javax.swing.JMenuItem(); cascadeMenuItem .setText(getResourceConverter().getString("workbench.menu.cascadeWindows", "Cascade Windows")); cascadeMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { cascadeMenuItemActionPerformed(evt); } }); tileMenuItem = new javax.swing.JMenuItem(); tileMenuItem.setText(getResourceConverter().getString("workbench.menu.tileWindows", "Tile Windows")); tileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { tileMenuItemActionPerformed(evt); } }); closeAllMenuItem = new javax.swing.JMenuItem(); closeAllMenuItem.setText(getResourceConverter().getString("workbench.menu.closeAll", "Close All")); closeAllMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { closeAllMenuItemActionPerformed(evt); } }); minimizeMenuItem = new javax.swing.JMenuItem(); minimizeMenuItem.setText(getResourceConverter().getString("workbench.menu.minimizeAll", "Minimize All")); minimizeMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { minimizeMenuItemActionPerformed(evt); } }); maximizeMenuItem = new javax.swing.JMenuItem(); maximizeMenuItem.setText(getResourceConverter().getString("workbench.menu.maximizeAll", "Maximize All")); maximizeMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { maximizeMenuItemActionPerformed(evt); } }); menuBar.add(windowMenu); aboutMenuItem.setText(getResourceConverter().getString("workbench.menu.about", "About")); aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutMenuItemActionPerformed(evt); } }); helpMenu.add(aboutMenuItem); helpMenu.setText(getResourceConverter().getString("workbench.menu.help", "Help")); helpMenu.setMnemonic(KeyEvent.VK_H); menuBar.add(helpMenu); setJMenuBar(menuBar); pack(); }
From source file:DateTimeEditor.java
protected void createComponents() { if (m_orientation == SwingConstants.VERTICAL) { setLayout(new GridLayout(2, 1)); m_incrementButton = new BasicArrowButton(SwingConstants.NORTH); m_decrementButton = new BasicArrowButton(SwingConstants.SOUTH); add(m_incrementButton);//from w ww .j a v a 2s. com add(m_decrementButton); } else if (m_orientation == SwingConstants.HORIZONTAL) { setLayout(new GridLayout(1, 2)); m_incrementButton = new BasicArrowButton(SwingConstants.EAST); m_decrementButton = new BasicArrowButton(SwingConstants.WEST); add(m_decrementButton); add(m_incrementButton); } }