@Override protected void changeBorder() { int flags; Border empty = BorderFactory.createEmptyBorder(); int iInsets = bSmallTitle ? 0 : 2; if (getOrientation().isHorizontal()) { flags = CEclipseBorder.TOP_RIGHT | CEclipseBorder.BOTTOM_RIGHT; empty = new EmptyBorder(iInsets, 2, iInsets, 4); } else { flags = CEclipseBorder.BOTTOM_LEFT | CEclipseBorder.BOTTOM_RIGHT; empty = new EmptyBorder(2, iInsets, 4, iInsets); } Border border = new CEclipseBorder(getOrigin().getController(), 6, flags); Insets ins = getOutsideInsets(); Border b = new CompoundBorder( BorderFactory.createEmptyBorder(ins.top, ins.left, ins.bottom, ins.right), new CompoundBorder(border, empty)); setBorder(ThemeManager.BORDER_MODIFIER + ".title.eclipse.button.flat", b); }
public FileNameRenderer(JTable table) { Border b = UIManager.getBorder("Table.noFocusBorder"); if (Objects.isNull(b)) { // Nimbus??? Insets i = focusCellHighlightBorder.getBorderInsets(textLabel); b = BorderFactory.createEmptyBorder(i.top, i.left, i.bottom, i.right); } noFocusBorder = b; p.setOpaque(false); panel.setOpaque(false); // http://www.icongalore.com/ XP Style Icons - Windows Application Icon, Software XP Icons nicon = new ImageIcon(getClass().getResource("wi0063-16.png")); sicon = new ImageIcon( p.createImage( new FilteredImageSource(nicon.getImage().getSource(), new SelectedImageFilter()))); iconLabel = new JLabel(nicon); iconLabel.setBorder(BorderFactory.createEmptyBorder()); p.add(iconLabel, BorderLayout.WEST); p.add(textLabel); panel.add(p, BorderLayout.WEST); Dimension d = iconLabel.getPreferredSize(); dim.setSize(d); table.setRowHeight(d.height); }
private Qizi() { isDead = false; this.setBorder(BorderFactory.createRaisedBevelBorder()); this.setBorderPainted(false); this.setOpaque(false); this.setVisible(false); }
public MainPanel() { super(new BorderLayout()); initComboBox(combo01); int g = 5; JPanel p = new JPanel(new GridLayout(2, 2, g, g)); p.add(combo00); p.add(new JLabel("<- default")); p.add(combo01); p.add(new JLabel("<- RightPopupMenuListener")); setBorder(BorderFactory.createEmptyBorder(g, g, g, g)); add(p, BorderLayout.NORTH); setPreferredSize(new Dimension(320, 240)); }
private static JComponent makeUI() { // final JProgressBar progressBar = new JProgressBar(SwingConstants.VERTICAL); final JProgressBar progressBar = new JProgressBar(); progressBar.setOpaque(false); progressBar.setUI(new GradientPalletProgressBarUI()); GridBagConstraints c = new GridBagConstraints(); JPanel p = new JPanel(new GridBagLayout()); p.setBorder(BorderFactory.createEmptyBorder(32, 8, 0, 8)); c.gridheight = 1; c.gridwidth = 1; c.gridy = 0; c.gridx = 0; c.insets = new Insets(0, 0, 0, 4); c.weightx = 1d; c.fill = GridBagConstraints.HORIZONTAL; p.add(progressBar, c); c.gridx = 1; c.weightx = 0d; p.add( new JButton( new AbstractAction("Start") { @Override public void actionPerformed(ActionEvent e) { final JButton b = (JButton) e.getSource(); b.setEnabled(false); SwingWorker<Void, Void> worker = new Task() { @Override public void done() { if (b.isDisplayable()) { b.setEnabled(true); } } }; worker.addPropertyChangeListener(new ProgressListener(progressBar)); worker.execute(); } }), c); return p; }
public MainPanel() { super(new GridLayout(0, 1)); orgImage = new ImageIcon(getClass().getResource("i03-10.gif")); JPanel p1 = new JPanel(new GridLayout(1, 2)); p1.add(makeLabel(makeGrayImageIcon1(orgImage.getImage()), "ColorConvertOp")); p1.add(makeLabel(makeGrayImageIcon2(orgImage.getImage()), "TYPE_BYTE_GRAY")); add(p1); add(makeLabel(makeGrayImageIcon3(orgImage.getImage()), "GrayFilter.createDisabledImage")); JPanel p3 = new JPanel(new GridLayout(1, 2)); p3.add(makeLabel(makeGrayImageIcon4(orgImage.getImage()), "GrayFilter(true, 50)")); p3.add(makeLabel(makeGrayImageIcon5(orgImage.getImage()), "GrayImageFilter")); add(p3); p1.setBackground(Color.WHITE); p3.setBackground(Color.WHITE); setBackground(Color.WHITE); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setPreferredSize(new Dimension(320, 240)); }
static void buildGUI() { // Need this size to balance axes. frame.setSize(520, 690); frame.setTitle("DrawTool"); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Container cPane = frame.getContentPane(); // Status label on top. Unused for now. statusLabel.setOpaque(true); statusLabel.setBackground(Color.white); cPane.add(statusLabel, BorderLayout.NORTH); // Build the input/output elements at the bottom. JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createLineBorder(Color.black)); panel.setBackground(inputPanelColor); panel.setLayout(new GridLayout(2, 1)); panel.add(outputLabel); JPanel bottomPanel = new JPanel(); bottomPanel.setBackground(inputPanelColor); bottomPanel.add(inputField); bottomPanel.add(new JLabel(" ")); JButton enterButton = new JButton("Enter"); enterButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent a) { hasEntered = true; } }); bottomPanel.add(enterButton); panel.add(bottomPanel); if (!sequencingOn) { cPane.add(panel, BorderLayout.SOUTH); } // Drawing in the center. drawArea = new DrawTool(); if (sequencingOn) { frame.addKeyListener( new KeyAdapter() { public void keyTyped(KeyEvent e) { handleKeyTyped(e); } }); } cPane.add(drawArea, BorderLayout.CENTER); drawArea.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { handleMouseClick(e); } public void mouseReleased(MouseEvent e) { handleMouseReleased(e); } }); drawArea.addMouseMotionListener( new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { handleMouseDragged(e); } }); }
/** Init visible components. */ private void init() { TransparentPanel panel = new TransparentPanel(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // Title label JLabel titleLabel = new JLabel(GuiActivator.getResources().getI18NString("service.gui.avatar.RECENT_ICONS")); titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD)); // fix for displaying text in menu // when using a dark OS theme (as default one in ubuntu) titleLabel.setForeground(new JMenuItem().getForeground()); panel.add(titleLabel, BorderLayout.NORTH); // Init recent images grid TransparentPanel recentImagesGrid = new TransparentPanel(); recentImagesGrid.setLayout(new GridLayout(0, IMAGES_PER_COLUMN)); Dimension thumbsize = new Dimension(THUMB_WIDTH, THUMB_HEIGHT); for (int i = 0; i < MAX_STORED_IMAGES; i++) { this.recentImagesButtons[i] = new SIPCommButton(null); this.recentImagesButtons[i].setBorder(BorderFactory.createEtchedBorder()); this.recentImagesButtons[i].setMaximumSize(thumbsize); this.recentImagesButtons[i].setMinimumSize(thumbsize); this.recentImagesButtons[i].setPreferredSize(thumbsize); this.recentImagesButtons[i].addActionListener(this); this.recentImagesButtons[i].setName("" + i); recentImagesGrid.add(this.recentImagesButtons[i]); } panel.add(recentImagesGrid, BorderLayout.CENTER); // Action buttons TransparentPanel buttonsPanel = new TransparentPanel(); buttonsPanel.setLayout(new GridLayout(0, 1)); // we use this menu item just to get its foreground color. Color linkColor = new JMenuItem().getForeground(); addActionButton( buttonsPanel, this, GuiActivator.getResources().getI18NString("service.gui.avatar.CHOOSE_ICON"), CHOSE_BUTTON_NAME, linkColor); addActionButton( buttonsPanel, this, GuiActivator.getResources().getI18NString("service.gui.avatar.REMOVE_ICON"), REMOVE_BUTTON_NAME, linkColor); addActionButton( buttonsPanel, this, GuiActivator.getResources().getI18NString("service.gui.avatar.CLEAR_RECENT"), CLEAR_BUTTON_NAME, linkColor); panel.add(buttonsPanel, BorderLayout.SOUTH); this.setLayout(new BorderLayout()); this.add(panel, BorderLayout.CENTER); }
public Display(String title) throws IOException { super(title); setLayout(new GridLayout(1, 3)); JPanel options = new JPanel(new GridLayout(5, 1)); JPanel numCircles = new JPanel((new GridLayout(1, 2))); addWindowListener(this); b = new Button("Load Image"); c = new Button("filter"); findCircles = new Button("Find"); inputCircles = new JTextField("12"); numCircles.add(inputCircles); numCircles.add(findCircles); options.add(b); options.add(c); add(options); filterBtn = new JRadioButton("Filtered"); sobelBtn = new JRadioButton("Sobel"); nonMaxBtn = new JRadioButton("Non Maximal"); accumulator = new JRadioButton("Accumulator"); whichRadius = new JSlider(JSlider.HORIZONTAL, rmin, 125, 14); whichRadius.setMajorTickSpacing(10); whichRadius.setMinorTickSpacing(1); whichRadius.setPaintTicks(true); whichRadius.setPaintLabels(true); whichRadius.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); Font font = new Font("Serif", Font.ITALIC, 6); whichRadius.setFont(font); ButtonGroup rGroup = new ButtonGroup(); rGroup.add(filterBtn); rGroup.add(sobelBtn); rGroup.add(nonMaxBtn); rGroup.add(accumulator); JPanel radioPanel = new JPanel(new GridLayout(0, 1)); radioPanel.add(filterBtn); radioPanel.add(sobelBtn); radioPanel.add(nonMaxBtn); radioPanel.add(accumulator); options.add(radioPanel); options.add(numCircles); options.add(whichRadius); loadImage(); add(lbl1); add(lbl2); b.addActionListener(this); c.addActionListener(this); filterBtn.addActionListener(this); sobelBtn.addActionListener(this); nonMaxBtn.addActionListener(this); findCircles.addActionListener(this); accumulator.addActionListener(this); whichRadius.addChangeListener(this); }
public SketchProperties(Editor e, Sketch s) { super(); editor = e; sketch = s; fields = new HashMap<String, JComponent>(); this.setPreferredSize(new Dimension(500, 400)); this.setMinimumSize(new Dimension(500, 400)); this.setMaximumSize(new Dimension(500, 400)); this.setSize(new Dimension(500, 400)); Point eLoc = editor.getLocation(); int x = eLoc.x; int y = eLoc.y; Dimension eSize = editor.getSize(); int w = eSize.width; int h = eSize.height; int cx = x + (w / 2); int cy = y + (h / 2); this.setLocation(new Point(cx - 250, cy - 200)); this.setModal(true); outer = new JPanel(new BorderLayout()); outer.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.add(outer); win = new JPanel(); win.setLayout(new BorderLayout()); outer.add(win, BorderLayout.CENTER); buttonBar = new JPanel(new FlowLayout(FlowLayout.RIGHT)); saveButton = new JButton("OK"); saveButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { save(); SketchProperties.this.dispose(); } }); cancelButton = new JButton("Cancel"); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { SketchProperties.this.dispose(); } }); buttonBar.add(saveButton); buttonBar.add(cancelButton); win.add(buttonBar, BorderLayout.SOUTH); tabs = new JTabbedPane(); overviewPane = new JPanel(); overviewPane.setLayout(new BoxLayout(overviewPane, BoxLayout.PAGE_AXIS)); overviewPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); addTextField(overviewPane, "author", "Sketch author:"); addTextArea(overviewPane, "summary", "Summary:"); addTextArea(overviewPane, "license", "Copyright / License:"); tabs.add("Overview", overviewPane); objectsPane = new JPanel(); objectsPane.setLayout(new BoxLayout(objectsPane, BoxLayout.PAGE_AXIS)); objectsPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); addTextField(objectsPane, "board", "Board:"); addTextField(objectsPane, "core", "Core:"); addTextField(objectsPane, "compiler", "Compiler:"); addTextField(objectsPane, "port", "Serial port:"); addTextField(objectsPane, "programmer", "Programmer:"); JButton setDef = new JButton("Set to current IDE values"); setDef.setMaximumSize(setDef.getPreferredSize()); setDef.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setObjectValues(); } }); objectsPane.add(Box.createVerticalGlue()); objectsPane.add(setDef); tabs.add("Objects", objectsPane); win.add(tabs, BorderLayout.CENTER); this.setTitle("Sketch Properties"); this.pack(); this.setVisible(true); }
/** Constructor to set everything up */ public TicTac() { // Set defaults before settings are changed via menus // (defaults are vs AI, play as X, with graphics on) multiPlayers = false; temp = false; currentPlayer = Symbol.X; ai = Symbol.O; difficulty = Difficulty.IMPOSSIBLE; frame = new JFrame("Tic Tac Toe"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); // Set preferred size so game fills window nicely this.setPreferredSize(new Dimension(cellSize * ROWS, cellSize * COLS)); frame.add(this); // Load images try { sword = ImageIO.read(new File("swordsBlue.png")); saber = ImageIO.read(new File("saber2.png")); skull = ImageIO.read(new File("skull.png")); ring = ImageIO.read(new File("ring.png")); smiley = ImageIO.read(new File("smiley.png")); hydra = ImageIO.read(new File("hydra.png")); finalfantasy = ImageIO.read(new File("finalfantasy.jpg")); dragon = ImageIO.read(new File("dargon.jpg")); night = ImageIO.read(new File("night.jpg")); } catch (IOException e) { System.out.println("Could not open image files, turning images off!"); useImages = false; } imageX = saber; imageO = ring; background = dragon; // Create menu bars. Each one item will need a listener menuBar = new JMenuBar(); JMenu menu = new JMenu("Mode"); JMenu menu2 = new JMenu("Side"); JMenu menu3 = new JMenu("Graphics"); JMenu menu4 = new JMenu("Other"); JMenu menu5 = new JMenu("Difficulty"); JMenu xImageMenu = new JMenu("Image for X"); JMenu oImageMenu = new JMenu("Image for O"); JMenu backgroundMenu = new JMenu("Set Background"); menuBar.add(menu); menuBar.add(menu2); menuBar.add(menu5); menuBar.add(menu3); menuBar.add(menu4); // Create checkbox menu items for choices final JCheckBoxMenuItem item = new JCheckBoxMenuItem("2 Player"); final JCheckBoxMenuItem item2 = new JCheckBoxMenuItem("VS Computer"); final JCheckBoxMenuItem item3 = new JCheckBoxMenuItem("Play as X"); final JCheckBoxMenuItem item4 = new JCheckBoxMenuItem("Play as O"); final JCheckBoxMenuItem item5 = new JCheckBoxMenuItem("On"); final JCheckBoxMenuItem item6 = new JCheckBoxMenuItem("Off"); JMenuItem item7 = new JMenuItem("Restart"); JMenuItem item8 = new JMenuItem("Exit"); final JCheckBoxMenuItem item9 = new JCheckBoxMenuItem("Easy"); final JCheckBoxMenuItem item10 = new JCheckBoxMenuItem("Hard"); final JCheckBoxMenuItem item11 = new JCheckBoxMenuItem("Impossible"); final JCheckBoxMenuItem itemSword = new JCheckBoxMenuItem("Sword"); final JCheckBoxMenuItem itemSaber = new JCheckBoxMenuItem("Sabers"); final JCheckBoxMenuItem itemSkull = new JCheckBoxMenuItem("Skull"); final JCheckBoxMenuItem itemRing = new JCheckBoxMenuItem("One Ring"); final JCheckBoxMenuItem itemSmiley = new JCheckBoxMenuItem("Red Smiley"); final JCheckBoxMenuItem itemHydra = new JCheckBoxMenuItem("Hydra"); final JCheckBoxMenuItem itemDragon = new JCheckBoxMenuItem("Dragon"); final JCheckBoxMenuItem itemFinalFantasy = new JCheckBoxMenuItem("Final Fantasy 7"); final JCheckBoxMenuItem itemNight = new JCheckBoxMenuItem("Nighttime"); // Set the initial checkboxes to true (for play vs ai, as X, with graphics on) item2.setSelected(true); item3.setSelected(true); item5.setSelected(true); item11.setSelected(true); itemSaber.setSelected(true); itemRing.setSelected(true); itemDragon.setSelected(true); // Play against friend item.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { item.setSelected(true); item2.setSelected(false); multiPlayers = true; repaint(); } }); menu.add(item); // Checkbox for Selecting to play against AI item2.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { item2.setSelected(true); item.setSelected(false); if (currentPlayer == Symbol.X) ai = Symbol.O; else ai = Symbol.X; item3.setSelected(true); item4.setSelected(false); multiPlayers = false; } }); menu.add(item2); // Play as X item3.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // use temp variable to move after assigning symbols if (item4.getState() && !multiPlayers) temp = true; item3.setSelected(true); item4.setSelected(false); currentPlayer = Symbol.X; ai = Symbol.O; if (temp) aiMove(); repaint(); temp = false; } }); menu2.add(item3); // Play as O item4.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (item3.getState() && !multiPlayers) temp = true; item4.setSelected(true); item3.setSelected(false); currentPlayer = Symbol.O; ai = Symbol.X; if (temp) aiMove(); repaint(); temp = false; } }); menu2.add(item4); // Turn Graphics on item5.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { item5.setSelected(true); item6.setSelected(false); useImages = true; repaint(); } }); menu3.add(item5); // Turn Graphics off item6.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { item5.setSelected(false); item6.setSelected(true); useImages = false; repaint(); } }); menu3.add(item6); menu3.addSeparator(); menu3.add(xImageMenu); menu3.add(oImageMenu); menu3.add(backgroundMenu); // Choose Saber for X itemSaber.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { itemSword.setSelected(false); itemSaber.setSelected(true); itemSkull.setSelected(false); imageX = saber; repaint(); } }); xImageMenu.add(itemSaber); // Choose Sword for X itemSword.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { itemSword.setSelected(true); itemSaber.setSelected(false); itemSkull.setSelected(false); imageX = sword; repaint(); } }); xImageMenu.add(itemSword); // Choose Skull for X itemSkull.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { itemSword.setSelected(false); itemSaber.setSelected(false); itemSkull.setSelected(true); imageX = skull; repaint(); } }); xImageMenu.add(itemSkull); // Choose ring for O itemRing.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { itemRing.setSelected(true); itemSmiley.setSelected(false); itemHydra.setSelected(false); imageO = ring; repaint(); } }); oImageMenu.add(itemRing); // Choose red smiley for O itemSmiley.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { itemRing.setSelected(false); itemSmiley.setSelected(true); itemHydra.setSelected(false); imageO = smiley; repaint(); } }); oImageMenu.add(itemSmiley); // Choose hydra for O itemHydra.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { itemRing.setSelected(false); itemSmiley.setSelected(false); itemHydra.setSelected(true); imageO = hydra; repaint(); } }); oImageMenu.add(itemHydra); // Set dragon as background itemDragon.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { itemDragon.setSelected(true); itemFinalFantasy.setSelected(false); itemNight.setSelected(false); background = dragon; repaint(); } }); backgroundMenu.add(itemDragon); // Set final fantasy 7 as background itemFinalFantasy.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { itemDragon.setSelected(false); itemFinalFantasy.setSelected(true); itemNight.setSelected(false); background = finalfantasy; repaint(); } }); backgroundMenu.add(itemFinalFantasy); // Set night as background itemNight.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { itemDragon.setSelected(false); itemFinalFantasy.setSelected(false); itemNight.setSelected(true); background = night; repaint(); } }); backgroundMenu.add(itemNight); // Reset game item7.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { initialize(); } }); menu4.add(item7); // Exit game item8.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); menu4.add(item8); // Difficulty easy item9.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { difficulty = Difficulty.EASY; item9.setSelected(true); item10.setSelected(false); item11.setSelected(false); } }); menu5.add(item9); // Difficulty hard item10.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { difficulty = Difficulty.HARD; item10.setSelected(true); item9.setSelected(false); item11.setSelected(false); } }); menu5.add(item10); // Difficulty impossible item11.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { difficulty = Difficulty.IMPOSSIBLE; item11.setSelected(true); item9.setSelected(false); item10.setSelected(false); } }); menu5.add(item11); // Add Whole menu bar to frame frame.setJMenuBar(menuBar); // Create statusBar (updates will take place in paintComponent) statusBar = new JLabel(" "); statusBar.setFont(new Font(Font.DIALOG_INPUT, Font.BOLD, 15)); statusBar.setBorder(BorderFactory.createEmptyBorder(2, 5, 4, 5)); // Use container variable to set layout and pack everything nicely Container cp = frame.getContentPane(); cp.setLayout(new BorderLayout()); cp.add(this, BorderLayout.CENTER); cp.add(statusBar, BorderLayout.SOUTH); frame.pack(); board = new Symbol[ROWS][COLS]; initialize(); // Add the mouse listener. Use MouseAdapter rather than implement it this.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int currentCol = e.getX() / cellSize; int currentRow = e.getY() / cellSize; if (gameStatus == GameStatus.CONTINUE) { // If valid click, and spot is empty, make the move. Then check // to see if game is won. If not, and facing AI, ai moves. // Otherwise switch X and O if (currentRow >= 0 && currentRow < ROWS && currentCol >= 0 && currentCol < COLS && board[currentRow][currentCol] == Symbol.EMPTY) { board[currentRow][currentCol] = currentPlayer; checkState(currentPlayer); if (multiPlayers) currentPlayer = (currentPlayer == Symbol.X) ? Symbol.O : Symbol.X; if (gameStatus == GameStatus.CONTINUE && !multiPlayers) aiMove(); } } else { // Game is over, so re-initialize everything initialize(); } repaint(); } }); }