@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); }
/** * Constructs a button panel. * * @param title the title shown in the border * @param options an array of radio button labels */ public ButtonPanel(String title, String... options) { setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), title)); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); group = new ButtonGroup(); // make one radio button for each option for (String option : options) { JRadioButton b = new JRadioButton(option); b.setActionCommand(option); add(b); group.add(b); b.setSelected(option == options[0]); } }
private Qizi() { isDead = false; this.setBorder(BorderFactory.createRaisedBevelBorder()); this.setBorderPainted(false); this.setOpaque(false); this.setVisible(false); }
/** * Creates and returns a map of attributes to be used as defaults for vertex attributes. * * @return a map of attributes to be used as defaults for vertex attributes. */ public static AttributeMap createDefaultVertexAttributes() { AttributeMap map = new AttributeMap(); Color c = Color.decode("#FF9900"); GraphConstants.setBounds(map, new Rectangle2D.Double(50, 50, 90, 30)); GraphConstants.setBorder(map, BorderFactory.createRaisedBevelBorder()); GraphConstants.setBackground(map, c); GraphConstants.setForeground(map, Color.white); GraphConstants.setFont(map, GraphConstants.DEFAULTFONT.deriveFont(Font.BOLD, 12)); GraphConstants.setOpaque(map, true); return map; }
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; }
private JPanel getUIPanel() { JButton button = new JButton("change data"); JRadioButton[] rbs = new JRadioButton[5]; final ButtonGroup group = new ButtonGroup(); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { int index = Integer.parseInt(group.getSelection().getActionCommand()); double xMin = -MAX, xMax = MAX, yMin = -MAX, yMax = MAX; switch (index) { case 0: xMax = -5; break; case 1: xMin = 5; break; case 2: break; case 3: yMax = -5; break; case 4: yMin = 5; } double[] x = getData(xMin, xMax); double[] y = getData(yMin, yMax); plotPanel.setData(x, y); } }); JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); String minus = "<html>\u2013"; String[] ids = {"<html>\u2013x", "+x", "<html>+/\u2013x&y", "<html>\u2013y", "+y"}; for (int i = 0; i < rbs.length; i++) { rbs[i] = new JRadioButton(ids[i], i == 2); rbs[i].setActionCommand(String.valueOf(i)); group.add(rbs[i]); panel.add(rbs[i], gbc); } panel.setBorder(BorderFactory.createEtchedBorder()); gbc.weightx = 1.0; panel.add(button, gbc); return panel; }
public PlayButton(String name) { super(name); myBorder = BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.black), BorderFactory.createLineBorder(Color.blue)), BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.cyan), BorderFactory.createLineBorder(Color.white))); addMouseListener( new MouseAdapter() { public void mouseEntered(MouseEvent e) { setBorder(myBorder); } public void mouseExited(MouseEvent e) { setBorder(null); } }); }
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); } }); }
/** * inti the UI and some params * * @param none */ public void initUI() { // cNextBlockDC.setLayout(new BorderLayout()); getContentPane().setLayout(null); // the total panel JPanel outer = new JPanel(); getContentPane().add(outer); outer.setBounds(4, 4, frameWeight - 20, frameHeight - 50); outer.setBorder(BorderFactory.createTitledBorder("Game DC")); outer.setLayout(null); JPanel rightPanel = new JPanel(); rightPanel.setLayout(null); // the panel to show next block JPanel tipNext = new JPanel(); tipNext.setBounds(10, 30, 130, 80); tipNext.setBorder(BorderFactory.createTitledBorder("Next Block")); tipNext.setLayout(null); cNextBlockDC.setBounds(25, 20, 48, 48); tipNext.add(cNextBlockDC); rightPanel.add(tipNext); // the panel to show the score JPanel playerScore = new JPanel(); playerScore.setBounds(10, 110, 130, 40); playerScore.setBorder(BorderFactory.createTitledBorder("Score")); playerScore.setLayout(null); m_lTotalScore.setBounds(40, 15, 100, 20); playerScore.add(m_lTotalScore); rightPanel.add(playerScore); // the panel to show the button JPanel buttonArea = new JPanel(); buttonArea.setBounds(10, 160, 130, 170); buttonArea.setBorder(BorderFactory.createTitledBorder("Game Control")); buttonArea.setLayout(null); m_bGameHalt.setBounds(10, 30, 110, 30); buttonArea.add(m_bGameHalt); m_bGameStart.setBounds(10, 62, 110, 30); buttonArea.add(m_bGameStart); m_bGameOver.setBounds(10, 94, 110, 30); buttonArea.add(m_bGameOver); m_bVoiceControl.setBounds(10, 126, 110, 30); buttonArea.add(m_bVoiceControl); rightPanel.add(buttonArea); // the Panel to show the tips for the game JPanel gameTip = new JPanel(); gameTip.setBounds(10, 330, 130, 160); gameTip.setBorder(BorderFactory.createTitledBorder("Game Tip")); gameTip.setLayout(null); m_lGameTip.setBounds(10, 20, 130, 100); Font fnt = new Font("楷体_GB2312", Font.ITALIC, 15); m_lGameTip.setText( "<html><body>" + "<font style='color:#2f4f4f;size:10px;'>" + "1.由方向键控制游戏<br/>,向上有变形;<br/>2." + "语音控制命令见配<br/>置文件;<br/>3.Author:"); // the link for blog JLabel linkForBlog = new JLabel("<html><body><a style='color:#00755e;' href ='#'>kymo</a></body></html>"); linkForBlog.setCursor(new Cursor(Cursor.HAND_CURSOR)); linkForBlog.setBounds(20, 113, 130, 15); // add mouse event linkForBlog.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { //// System.out.println("click !"); try { Desktop.getDesktop().browse(new java.net.URI(kymoBlog)); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (URISyntaxException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); // the link to open voice xml file JLabel linkForXml = new JLabel( "<html><body><a style='color:#00755e;' href ='#'>open voice xml</a></body></html>"); linkForXml.setCursor(new Cursor(Cursor.HAND_CURSOR)); linkForXml.setBounds(20, 128, 130, 15); // add mouse event linkForXml.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { // JLabel xmlFileContent = new JLabel(); try { Runtime.getRuntime() .exec("cmd /c start " + System.getProperty("user.dir") + "\\voice.xml"); } catch (IOException ex) { //// System.out.println(ex); } } }); gameTip.add(linkForBlog); gameTip.add(linkForXml); gameTip.add(m_lGameTip); rightPanel.add(gameTip); // pack(); rightPanel.setBounds(340, 30, 150, 500); rightPanel.setBorder(BorderFactory.createTitledBorder("Game Control&Tips")); outer.add(rightPanel); cGameDc = new DrawComponent(this, cTetrisBlock); cGameDc.setBounds(30, 30, 300, 500); outer.add(cGameDc); setVisible(true); setResizable(false); pack(); this.setSize(frameWeight, frameHeight); this.setLocation(frameLocaX, frameLocaY); m_bGameHalt.addActionListener((ActionListener) this); m_bGameStart.addActionListener((ActionListener) this); m_bGameOver.addActionListener((ActionListener) this); m_bVoiceControl.addActionListener((ActionListener) this); // if the windows is close ,the game thread will end this.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { isGameOver = true; System.exit(0); } }); // the listen of the keyboard Toolkit.getDefaultToolkit() .addAWTEventListener( new AWTEventListener() { @Override public void eventDispatched(AWTEvent event) { // TODO Auto-generated method stub if (((KeyEvent) event).getID() == KeyEvent.KEY_RELEASED) isKeyPressed = false; if (((KeyEvent) event).getID() == KeyEvent.KEY_PRESSED) { // 放入自己的键盘监听事件 // ((KeyEvent) event).getKeyCode();// 获取按键的code // ((KeyEvent) event).getKeyChar();// // 获取按键的字符////System.out.println(e.getKeyCode()); if (!isGameHalt && isGameStart) { if (((KeyEvent) event).getKeyCode() == KeyEvent.VK_RIGHT) { if (!isCoordinateLock) { isKeyPressed = true; if (!isRightToEnd(cTetrisBlock.m_blockRightX)) cTetrisBlock.setCoordinateXY( cTetrisBlock.getTetrisCoordinateX() + 20, cTetrisBlock.getTetrisCoordinateY()); cGameDc.repaint(); } } else if (((KeyEvent) event).getKeyCode() == KeyEvent.VK_LEFT) { if (!isCoordinateLock) { isKeyPressed = true; /* for(int j = 0; j < 4; j ++) //System.out.print(cTetrisBlock.m_blockLeftX[j] + " "); */ //// System.out.println(); if (!isLeftToEnd(cTetrisBlock.m_blockLeftX)) cTetrisBlock.setCoordinateXY( cTetrisBlock.getTetrisCoordinateX() - 20, cTetrisBlock.getTetrisCoordinateY()); cGameDc.repaint(); } } else if (((KeyEvent) event).getKeyCode() == KeyEvent.VK_DOWN) { if (!isCoordinateLock) { isKeyPressed = true; if (!isToEnd(cTetrisBlock.m_blockBottomY)) cTetrisBlock.setCoordinateXY( cTetrisBlock.getTetrisCoordinateX(), cTetrisBlock.getTetrisCoordinateY() + 20); cGameDc.repaint(); } } else if (((KeyEvent) event).getKeyCode() == KeyEvent.VK_UP) { if (!isCoordinateLock) { isKeyPressed = true; isTransforStart = true; cTetrisBlock.tetrisBlockShapeTransformation(m_blockGrid); cGameDc.repaint(); isTransforStart = false; } } } } } }, AWTEvent.KEY_EVENT_MASK); }
public void jbInit() throws Exception { this.setLayout(null); fContractPriceTextField.setFont(new java.awt.Font("Dialog", 1, 11)); fContractPriceTextField.setDisabledTextColor(Color.black); fContractPriceTextField.setEditable(false); fContractPriceTextField.setHorizontalAlignment(SwingConstants.RIGHT); fContractPriceTextField.setBounds(new java.awt.Rectangle(285, 182, 55, 21)); fContractVolumeTextField.setFont(new java.awt.Font("Dialog", 1, 11)); fContractVolumeTextField.setDisabledTextColor(Color.black); fContractVolumeTextField.setEditable(false); fContractVolumeTextField.setHorizontalAlignment(SwingConstants.RIGHT); fContractVolumeTextField.setBounds(new java.awt.Rectangle(285, 238, 55, 21)); fContractVolumeLabel.setText(fRb.getString("CONTRACT_VOLUME")); fContractVolumeLabel.setForeground(Color.black); fContractVolumeLabel.setBounds(new java.awt.Rectangle(272, 218, 99, 17)); fContractPriceLabel.setBounds(new java.awt.Rectangle(272, 160, 92, 17)); fContractPriceLabel.setText(fRb.getString("CONTRACT_PRICE")); fContractPriceLabel.setForeground(Color.black); fBoardGraph.setLayout(borderLayout1); fDay.setBounds(new java.awt.Rectangle(337, 87, 42, 21)); fDayLabel.setText(fRb.getString("DAY") + ":"); fDayLabel.setForeground(Color.black); fDayLabel.setBounds(new java.awt.Rectangle(267, 89, 67, 17)); fBoardLabel.setText(fRb.getString("SESSION") + ":"); fBoardLabel.setForeground(Color.black); fBoardLabel.setBounds(new java.awt.Rectangle(267, 121, 68, 17)); fBoard.setBounds(new java.awt.Rectangle(337, 119, 42, 22)); fPreviousBoardLabel.setFont(new java.awt.Font("Dialog", 1, 12)); fPreviousBoardLabel.setText(fRb.getString("PREVIOUS_PRICING")); fPreviousBoardLabel.setForeground(Color.black); fPreviousBoardLabel.setBounds(new java.awt.Rectangle(85, 4, 99, 17)); fXYToggleButton.setBorder(BorderFactory.createRaisedBevelBorder()); fXYToggleButton.setText("Exchange X-Y"); fXYToggleButton.setBounds(new java.awt.Rectangle(268, 43, 114, 25)); fXYToggleButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { fIsExchangeXY = fXYToggleButton.isSelected(); fIsUpdated = true; gUpdate(); } }); this.setBorder(BorderFactory.createEtchedBorder()); this.setBounds(new java.awt.Rectangle(325, 7, 387, 283)); this.setLayout(null); fBoardGraph.setBorder(BorderFactory.createEtchedBorder()); fBoardGraph.setBounds(new java.awt.Rectangle(5, 26, 257, 243)); fBoardGraph.getGraph().add(new UGraphData(fSellName, fSellColor)); fBoardGraph.getGraph().add(new UGraphData(fBuyName, fBuyColor)); fBoardGraph.setLeftMargin(60); this.add(fBoardGraph, null); this.add(fContractVolumeTextField, null); this.add(fContractVolumeLabel, null); this.add(fContractPriceTextField, null); this.add(fContractPriceLabel, null); this.add(fBoardLabel, null); this.add(fDayLabel, null); this.add(fXYToggleButton, null); this.add(fPreviousBoardLabel, null); this.add(fDay, null); this.add(fBoard, null); fBoardGraph.setBackground(Color.white); fBoardGraph.setNumOfHorizontalLine(0); fBoardGraph.setNumOfVerticalLine(0); fBoardGraph.setFixedMaxX(1); fBoardGraph.setFixedMinX(0); fBoardGraph.setFixedMaxY(1); fBoardGraph.setFixedMinY(0); addComponentListener( new ComponentAdapter() { public void componentShown(ComponentEvent ce) { gUpdate(); } }); }