public MainFrame() { Service.createAndStoreSomeObjects(); pnlContent = (JPanel) this.getContentPane(); pnlContent.setLayout(null); pnlScreen = new JPanel(); pnlContent.add(pnlScreen); pnlScreen.setSize(300, 380); pnlScreen.setLocation(10, 10); pnlScreen.setLayout(null); pnlButtons = new JPanel(); pnlContent.add(pnlButtons); pnlButtons.setSize(300, 60); pnlButtons.setLocation(10, 400); pnlButtons.setLayout(null); btnHome = new JButton("Home"); pnlButtons.add(btnHome); btnHome.setSize(70, 30); btnHome.setLocation(115, 10); btnHome.addActionListener(controller); // --------------------------------------------------------------------- Color color = new Color(99, 184, 255); // steelblue pnlMain = new MainPanel(this); pnlMain.setName("Main"); pnlMain.setBackground(color); pnlMain.setLayout(null); pnlScreen.add(pnlMain, "Main"); pnlTexts = new TextsPanel(this); pnlTexts.setName("Texts"); pnlScreen.add(pnlTexts, "Texts"); pnlTexts.setBackground(color); pnlTexts.setLayout(null); pnlCalls = new CallsPanel(this); pnlCalls.setName("Calls"); pnlScreen.add(pnlCalls, "Calls"); pnlCalls.setBackground(color); pnlCalls.setLayout(null); pnlContacts = new ContactsPanel(this); pnlContacts.setName("Contacts"); pnlScreen.add(pnlContacts, "Contacts"); pnlContacts.setBackground(color); pnlContacts.setLayout(null); showPanel("Main"); }
// Set up the quiz window Quiz() { initializeData(); setTitle("FOSS Quiz App"); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(440, 400); setLocation(300, 100); setResizable(true); Container cont = getContentPane(); cont.setLayout(null); cont.setBackground(Color.WHITE); bg = new ButtonGroup(); choice1 = new JRadioButton("Choice1", true); choice2 = new JRadioButton("Choice2", false); choice3 = new JRadioButton("Choice3", false); choice4 = new JRadioButton("Choice4", false); bg.add(choice1); bg.add(choice2); bg.add(choice3); bg.add(choice4); lblmess = new JLabel("Choose a correct anwswer"); lblmess.setForeground(Color.BLACK); lblmess.setFont(new Font("Sans_Serif", Font.BOLD, 15)); btnext = new JButton("Next"); btnext.setForeground(Color.WHITE); btnext.setFont(new Font("Sans_Serif", Font.BOLD, 17)); btnext.setBackground(Color.DARK_GRAY); btnext.addActionListener(this); panel = new JPanel(); panel.setBackground(Color.WHITE); panel.setLocation(10, 60); panel.setSize(400, 300); panel.setLayout(new GridLayout(0, 1)); title = new JPanel(); title.setBackground(Color.WHITE); title.setLocation(10, 10); title.setSize(1000, 50); title.setLayout(new GridLayout(1, 0)); title.add(lblmess); panel.add(choice1); panel.add(choice2); panel.add(choice3); panel.add(choice4); panel.add(btnext); cont.add(title); cont.add(panel); setVisible(true); quizAnswerID = 0; readQuestionAnswer(quizAnswerID); }
public void testModelPointDpConversion() { TestComponent testComponent = new TestComponent(); MyRoot nativeComponent = new MyRoot(2.0); JPanel panel = new JPanel(); panel.add(nativeComponent); nativeComponent.setLocation(15, 20); JPanel other = new JPanel(); panel.add(other); other.setLocation(5, 5); testComponent.setNativeComponent(nativeComponent); assertEquals( new Point(100, 110), testComponent.toModelDp(160, nativeComponent, new Point(100, 110))); assertEquals( new Point(100, 110), testComponent.toModelDp(160, panel, new Point(100 * 2 + 15, 110 * 2 + 20))); assertEquals( new Point(100, 110), testComponent.toModelDp(160, other, new Point(100 * 2 + 15 - 5, 110 * 2 + 20 - 5))); assertEquals( new Point(100 / 2, 110 / 2), testComponent.toModelDp(2 * 160, nativeComponent, new Point(100, 110))); assertEquals( new Point(100 / 2, 110 / 2), testComponent.toModelDp(2 * 160, panel, new Point(100 * 2 + 15, 110 * 2 + 20))); assertEquals( new Point(100 / 2, 110 / 2), testComponent.toModelDp(2 * 160, other, new Point(100 * 2 + 15 - 5, 110 * 2 + 20 - 5))); }
public void testModelDimensionDpConversion() { TestComponent testComponent = new TestComponent(); MyRoot nativeComponent = new MyRoot(2.0); JPanel panel = new JPanel(); panel.add(nativeComponent); nativeComponent.setLocation(15, 20); JPanel other = new JPanel(); panel.add(other); other.setLocation(5, 5); testComponent.setNativeComponent(nativeComponent); assertEquals( new Dimension(300, 400), testComponent.toModelDp(160, nativeComponent, new Dimension(300, 400))); assertEquals( new Dimension(300, 400), testComponent.toModelDp(160, panel, new Dimension(300 * 2, 400 * 2))); assertEquals( new Dimension(300, 400), testComponent.toModelDp(160, other, new Dimension(300 * 2, 400 * 2))); assertEquals( new Dimension(300 / 2, 400 / 2), testComponent.toModelDp(2 * 160, nativeComponent, new Dimension(300, 400))); assertEquals( new Dimension(300 / 2, 400 / 2), testComponent.toModelDp(2 * 160, panel, new Dimension(300 * 2, 400 * 2))); assertEquals( new Dimension(300 / 2, 400 / 2), testComponent.toModelDp(2 * 160, other, new Dimension(300 * 2, 400 * 2))); }
private JPanel getCrearAccionPanel() { if (crearAccionPanel == null) { accionLabel = new JLabel(); accionLabel.setFont(new Font("Dialog", Font.BOLD, 12)); accionLabel.setBounds(new Rectangle(45, 60, 97, 16)); accionLabel.setText("Nombre acción:"); categoriaLabel = new JLabel(); categoriaLabel.setLocation(new Point(75, 30)); categoriaLabel.setFont(new Font("Dialog", Font.BOLD, 12)); categoriaLabel.setText("Categoría:"); categoriaLabel.setSize(new Dimension(61, 16)); crearAccionPanel = new JPanel(); crearAccionPanel.setLayout(null); crearAccionPanel.setLocation(new Point(13, 13)); crearAccionPanel.setSize(new Dimension(441, 102)); crearAccionPanel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Acción", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51))); crearAccionPanel.add(categoriaLabel, null); crearAccionPanel.add(accionLabel, null); crearAccionPanel.add(getCategoriaTextField(), null); crearAccionPanel.add(getAccionTextField(), null); } return crearAccionPanel; }
public StudentUI(String userName) { tbar = new TitleBar(userName, frame); childp[0] = new HomePanel(); childp[1] = new MyCoursePanel(); childp[2] = new MyScorePanel(); childp[3] = new ChooseCommonPanel(); childp[4] = new ByelectPanel(); switchPane.setSize(1000, 590); switchPane.setLocation(30, 140); switchPane.setLayout(mcl); for (int i = 0; i < mBtn.length; i++) { mBtn[i] = new MenuBtn(FUNC_BTN_NAME[i], FUNC_BTN_TEXT[i]); mbar.add(mBtn[i]); childp[i].setSize(800, 490); switchPane.add(childp[i], FUNC_BTN_NAME[i]); } mbar.setLocation(30, 100); mcl.show(switchPane, FUNC_BTN_NAME[0]); mBtn[0].setSelected(true); frame.add(switchPane); frame.add(mbar); frame.add(tbar); setListener(); frame.setVisible(true); }
/** @param panel The panel containing the light box components (e.g. a wizard) */ public LightBoxPanel(JPanel panel) { Preconditions.checkNotNull(panel, "'panel' must be present"); Preconditions.checkState(panel.getWidth() > 0, "'width' must be greater than zero"); Preconditions.checkState(panel.getHeight() > 0, "'height' must be greater than zero"); this.panel = panel; // Ensure we set the opacity (platform dependent) this.setOpaque(false); // Ensure this panel covers all the available screen area and force a repaint this.setSize(Toolkit.getDefaultToolkit().getScreenSize()); // Prevent mouse events reaching through the darkened border this.addMouseListener(new ModalMouseListener()); // Add this panel to the frame's layered panel as the palette layer (directly above the default) Panels.frame.getLayeredPane().add(this, JLayeredPane.PALETTE_LAYER); // Center the light box panel in the frame int x = (Panels.frame.getWidth() - panel.getWidth()) / 2; int y = (Panels.frame.getHeight() - panel.getHeight()) / 2; panel.setLocation(x, y); // Add the light box panel to the frame as the popup layer (over everything except a drag/drop // layer) Panels.frame.getLayeredPane().add(panel, JLayeredPane.POPUP_LAYER); }
// Paints JPanel in the center of the screen private void paintPanel() { // center the dialog panel1.setLocation( (screen.getWidth() - panel1.getWidth()) / 2, (screen.getHeight() - panel1.getHeight()) / 2); // add the dialog to the "modal dialog" layer of the // screen's layered pane. Container contentPane = screen.getContentPane(); contentPane.add(panel1); }
@Override public void setLocation(int x, int y) { super.setLocation(x, y); this.x = x; this.y = y; if (patch != null) { patch.repaint(); } }
public void cambiar_vent(JPanel aux) { aux.setSize(PanelPrincipal.getSize()); aux.setLocation(PanelPrincipal.getLocation()); // aux.setLocation(5, 5); PanelPrincipal.removeAll(); PanelPrincipal.add(aux); PanelPrincipal.revalidate(); PanelPrincipal.repaint(); }
private void slideNext() { for (JPanel p : slideVec) { p.setLocation(p.getX() - PIXEL_MOVE, 0); } if (slideVec.get(counter).getX() == 0) { timer.stop(); toNext = false; } validate(); }
/** * This method initializes jContentPane * * @return javax.swing.JPanel */ private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(null); jContentPane.setSize(385, 77); jContentPane.setLocation(0, 0); jContentPane.add(getJPanel(), null); jContentPane.add(getJPanel1(), null); } return jContentPane; }
public SensorOrientationPanel(JFrame surroundingFrame, Controller controller) { if (surroundingFrame == null) { throw new IllegalArgumentException(); } this.surroundingFrame = surroundingFrame; this.controller = controller; variableGUI.setLayout(null); titlePanel = new JPanel(); titlePanel.setLayout(null); titlePanel.setLocation(0, 0); titlePanel.setSize(totalXDimensions, totalYDimensions); variableGUI.add(titlePanel); titleLabel = new JLabel("P&O - Team Groen - Ultrasonicsensor Orientation"); titleLabel.setLocation(0, 0); titleLabel.setSize(totalXDimensions, 30); titleLabel.setHorizontalAlignment(0); titleLabel.setForeground(Color.black); titlePanel.add(titleLabel); forwardButton = new JButton("Look Forward"); forwardButton.setBounds(20, 20, 200, 30); titlePanel.add(forwardButton); forwardButton.addActionListener(this); leftButton = new JButton("Look Left"); leftButton.setBounds(20, 80, 200, 30); titlePanel.add(leftButton); leftButton.addActionListener(this); rightButton = new JButton("Look Right"); rightButton.setBounds(20, 140, 200, 30); titlePanel.add(rightButton); rightButton.addActionListener(this); catapultButton = new JButton("Launch Catapult"); catapultButton.setBounds(20, 200, 200, 30); titlePanel.add(catapultButton); catapultButton.addActionListener(this); okButton = new JButton(); okButton.setBounds(20, 140, 120, 30); okButton.setText("OK"); okButton.addActionListener(this); titlePanel.add(okButton); variableGUI.setOpaque(true); }
void createButtons() { createLoginButton(); createHomeButton(); // JPanel buttonsPanel = new JPanel(new SpringLayout()); JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); buttonsPanel.setPreferredSize(new Dimension(550, 30)); buttonsPanel.setLocation(0, 270); // buttonsPanel.setLayout(null); buttonsPanel.add(loginButton); buttonsPanel.add(homeButton); // basic.add(buttonsPanel); basic.add(buttonsPanel, BorderLayout.PAGE_END); basic.setVisible(true); }
void createLoginForm() { logger.info("create login form"); createUserNameField(); createPasswordField(); createHomeText(); // JPanel loginForm = new JPanel(new FlowLayout(FlowLayout.CENTER)); JPanel loginForm = new JPanel(new SpringLayout()); loginForm.setPreferredSize(new Dimension(550, 260)); loginForm.setLocation(0, 0); loginForm.setLayout(null); loginForm.add(userNameLabel); loginForm.add(userNameField); loginForm.add(passwordLabel); loginForm.add(passwordField); // loginForm.add(homeTextArea); loginForm.add(scroll); // basic.add(loginForm); basic.add(loginForm, BorderLayout.CENTER); }
/** * This method initializes coveragesListPanel * * @return javax.swing.JPanel */ private JPanel getFeaturesListPanel() { if (coveragesListPanel == null) { coveragesListPanel = new JPanel(); coveragesListPanel.setLayout(null); coveragesListPanel.setLocation(new java.awt.Point(7, 57)); coveragesListPanel.setSize(new java.awt.Dimension(484, 313)); coveragesListPanel.add(getJScrollPane(), null); coveragesListPanel.setBorder( javax.swing.BorderFactory.createTitledBorder( null, PluginServices.getText(this, "select_features"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); } return coveragesListPanel; }
// constructor public TextView() { // setup model g = new Game(); // setup the mainframe for swing mainFrame = new JFrame("Hunt the Wumpus!"); mainFrame.setSize(316, 530); mainFrame.setLocation(400, 200); mainFrame.setVisible(true); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainFrame.setLayout(null); // layout aPanel as a JPanel to fill the mainframe aPanel = new JPanel(); aPanel.setSize(300, 530); aPanel.setLocation(0, 0); aPanel.setLayout(null); mainFrame.add(aPanel); // create and add aTextArea to aPanel to fill with the textual view of the model aTextArea = new JTextArea(g.display()); Font font1 = new Font("Consolas", Font.BOLD, 12); aTextArea.setFont(font1); aTextArea.setForeground(Color.WHITE); aTextArea.setBackground(Color.DARK_GRAY); aTextArea.setSize(300, 310); aTextArea.setLocation(0, 0); aTextArea.setEditable(false); // we don't want the hunter to mess with Mother Nature aPanel.add(aTextArea); // stick on some labels to tell user how to play deathNote.setSize(300, 40); deathNote.setLocation(0, 310); deathNote.setEditable(false); deathNote.setWrapStyleWord(true); deathNote.setLineWrap(true); aTextArea.setForeground(Color.BLACK); aTextArea.setBackground(Color.LIGHT_GRAY); aPanel.add(deathNote); moveLabel.setSize(100, 20); moveLabel.setLocation(52, 360); aPanel.add(moveLabel); shootLabel.setSize(100, 20); shootLabel.setLocation(215, 360); aPanel.add(shootLabel); // setup showButton showButton.setSize(200, 20); showButton.setLocation(60, 495); aPanel.add(showButton); // setup movement buttons moveU.setSize(45, 45); moveU.setLocation(45, 385); aPanel.add(moveU); moveD.setSize(45, 45); moveD.setLocation(45, 430); aPanel.add(moveD); moveL.setSize(45, 45); moveL.setLocation(0, 430); aPanel.add(moveL); moveR.setSize(45, 45); moveR.setLocation(90, 430); aPanel.add(moveR); // setup shooting buttons shootU.setSize(45, 45); shootU.setLocation(210, 385); aPanel.add(shootU); shootD.setSize(45, 45); shootD.setLocation(210, 430); aPanel.add(shootD); shootL.setSize(45, 45); shootL.setLocation(165, 430); aPanel.add(shootL); shootR.setSize(45, 45); shootR.setLocation(255, 430); aPanel.add(shootR); // register the listeners showButton.addActionListener(new ShowListener()); moveU.addActionListener(new MoveListener()); moveD.addActionListener(new MoveListener()); moveL.addActionListener(new MoveListener()); moveR.addActionListener(new MoveListener()); shootU.addActionListener(new ShootListener()); shootD.addActionListener(new ShootListener()); shootL.addActionListener(new ShootListener()); shootR.addActionListener(new ShootListener()); }
public JPanel createPanel() { JPanel panel = new JPanel(); panel.setLocation(450, 300); panel.setLayout(new GridLayout(2, 1)); LabeledComponent lc = null; JPanel definingPanel = new JPanel(); definingPanel.setLayout(new BorderLayout()); JLabel definingLabel = new JLabel(" Defining"); definingCheckBox = new JCheckBox(); definingCheckBox.setSelected(defining); definingCheckBox.setEnabled(definingEditable); definingPanel.add(definingCheckBox, BorderLayout.WEST); definingPanel.add(definingLabel, BorderLayout.CENTER); panel.add(definingPanel); value_field = new JTextField(""); value_field.setEditable(false); String pt = selectedCls != null ? selectedCls.getBrowserText() : ""; value_field.setText(pt); value_field.setPreferredSize(new Dimension(300, 20)); lc = new LabeledComponent("Select a superclass", value_field); Action SelectPropertyValueAction = new AbstractAction("Select a superclass...", OWLIcons.getAddIcon("PrimitiveClass")) { private static final long serialVersionUID = 123456009L; public void actionPerformed(ActionEvent e) { // java.awt.TextField textfield = new TextField(); String label = "Select a named class"; Collection clses = tab.getOWLWrapper().getSelectableRoots(); boolean ok = false; while (!ok) { final NCISelectClsesPanel p = new NCISelectClsesPanel(owlModel, clses); int result = ModalDialog.showDialog(tab, p, label, ModalDialog.MODE_OK_CANCEL); if (result == ModalDialogFactory.OPTION_OK) { Collection c = p.getSelection(); if (c != null && c.size() > 0) { Iterator it = c.iterator(); Object obj = it.next(); String clsName = ((OWLNamedClass) obj).getPrefixedName(); // tab.getOWLWrapper() // .getInternalName((Cls) obj); if (clsName.compareTo("owl:Thing") == 0) { } else { setCls((Cls) obj); ok = true; } } } else { // user cancelled ok = true; } } } }; lc.addHeaderButton(SelectPropertyValueAction); panel.add(lc); return panel; }
public void SetLocation(int x1, int y1) { super.setLocation(x1, y1); x = x1; y = y1; }
/** * This method creates the content pane that will be a part of the frame, including the JLabels, * JPanels and the JButtons INPUT (parameters): none OUTOUT (return): the main JPanel object that * includes everything */ public JPanel createContentPane() { JPanel totalGUI = new JPanel(); // the main panel totalGUI.setBackground(Color.BLACK); totalGUI.setLayout(null); printInstructions(); startNum = In.getInt(); if (startNum == 1) startGame = true; else startGame = false; while (!startGame) { System.out.println("Please enter 1 to start the game"); startNum = In.getInt(); if (startNum == 1) startGame = true; else startGame = false; } if (startGame) { titlePanel = new JPanel(); // a panel where the title will be displayed titlePanel.setLayout(null); titlePanel.setLocation(0, 0); titlePanel.setSize(1600, 150); Color titlePanelColor = new Color(238, 130, 238); titlePanel.setBackground(titlePanelColor); totalGUI.add(titlePanel); // this panel is added to the main panel gamePanel = new JPanel(); // game panel (where the cards will be displayed) gamePanel.setLayout(null); gamePanel.setLocation(0, 150); gamePanel.setSize(950, 650); gamePanel.setBackground(Color.BLACK); totalGUI.add(gamePanel); newGameButton = new JButton("Start"); // a button to start the game newGameButton.setLocation(800, 155); newGameButton.setSize(120, 30); newGameButton.addActionListener(this); gamePanel.add(newGameButton); // this button is added to the game panel endGameButton = new JButton("End Game"); // a button to end the game endGameButton.setLocation(800, 195); endGameButton.setSize(120, 30); endGameButton.addActionListener(this); gamePanel.add(endGameButton); hitButton = new JButton("Hit! (Player)"); // a hit button for the player hitButton.setLocation(800, 235); hitButton.setSize(120, 30); hitButton.addActionListener(this); gamePanel.add(hitButton); hitButton2 = new JButton("Hit! (Dealer)"); // a hit button for the dealer hitButton2.setLocation(800, 275); hitButton2.setSize(120, 30); hitButton2.addActionListener(this); gamePanel.add(hitButton2); standButton = new JButton("Stand (Player)"); // a stand button for the player standButton.setLocation(800, 315); standButton.setSize(120, 30); standButton.addActionListener(this); gamePanel.add(standButton); standButton2 = new JButton("Stand (Dealer)"); // a stand button for the dealer standButton2.setLocation(800, 355); standButton2.setSize(120, 30); standButton2.addActionListener(this); gamePanel.add(standButton2); playerTitle = new JLabel( "Player"); // label that displays the word "Player" on the screen playerTitle.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); Color playerTitleColor = new Color(0, 250, 154); playerTitle.setForeground(playerTitleColor); playerTitle.setLocation(550, 150); playerTitle.setSize(100, 30); gamePanel.add(playerTitle); dealerTitle = new JLabel("Dealer"); // label that displays the word "Dealer" on the screen dealerTitle.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); Color dealerTitleColor = new Color(0, 250, 154); dealerTitle.setForeground(dealerTitleColor); dealerTitle.setLocation(550, 350); dealerTitle.setSize(100, 30); gamePanel.add(dealerTitle); scoreLabel = new JLabel(""); // label that displays the score scoreLabel.setFont(new Font("Comic Sans MS", Font.BOLD, 30)); Color scoreLabelColor = new Color(255, 20, 147); scoreLabel.setForeground(scoreLabelColor); scoreLabel.setLocation(200, 130); scoreLabel.setSize(400, 300); gamePanel.add(scoreLabel); turnLabel = new JLabel(""); // label that informs the users whose turn it is turnLabel.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); Color turnLabelColor = new Color(255, 127, 80); turnLabel.setForeground(turnLabelColor); turnLabel.setLocation(250, 200); turnLabel.setSize(300, 100); gamePanel.add(turnLabel); score1 = new JLabel(""); score1.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); Color score1Color = new Color(255, 127, 80); score1.setForeground(score1Color); score1.setLocation(660, 135); score1.setSize(100, 60); gamePanel.add(score1); score2 = new JLabel(""); score2.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); Color score2Color = new Color(255, 127, 80); score2.setForeground(score2Color); score2.setLocation(660, 335); score2.setSize(100, 60); gamePanel.add(score2); ImageIcon titleIcon1 = new ImageIcon("BlackJack.jpg"); titlePics = new JLabel(titleIcon1); // an image for decor titlePics.setLocation(0, 0); titlePics.setSize(150, 150); titlePanel.add(titlePics); // image added to title label welcomeLabel = new JLabel("Welcome To Casino Royale!"); welcomeLabel.setFont(new Font("Monotype Corsiva", Font.BOLD, 40)); Color titleColor = new Color(0, 255, 255); // title welcomeLabel.setForeground(titleColor); welcomeLabel.setLocation(245, 0); welcomeLabel.setSize(700, 100); titlePanel.add(welcomeLabel); commandLabel = new JLabel("Please press \"Start\" to start a game of Black Jack!"); commandLabel.setFont(new Font("Comic Sans MS", Font.BOLD, 16)); Color commandColor = new Color(0, 0, 0); commandLabel.setForeground(commandColor); // instruction to user on how to start the game commandLabel.setLocation(250, 101); commandLabel.setSize(700, 44); titlePanel.add(commandLabel); ImageIcon titleIcon3 = new ImageIcon("Swirl.jpg"); titlePics = new JLabel(titleIcon3); // an image for decor titlePics.setLocation(783, 0); titlePics.setSize(150, 150); titlePanel.add(titlePics); totalGUI.setOpaque(true); return totalGUI; // return the final JPanel } return totalGUI; }
/** * setupNoLandPermPanel. * * @param p a {@link javax.swing.JPanel} object. * @param list a {@link java.util.ArrayList} object. * @param stack a boolean. */ private static void setupNoLandPermPanel(JPanel p, ArrayList<Card> list, boolean stack) { int maxY = 0; int maxX = 0; Card c; if (stack) { // add all Cards in list to the GUI, add arrows to Local Enchantments ArrayList<Card> planeswalkers = getPlaneswalkers(list); ArrayList<Card> equippedEnchantedCreatures = getEquippedEnchantedCreatures( list); // this will also fetch the equipment and/or enchantment ArrayList<Card> nonTokenCreatures = getNonTokenCreatures(list); ArrayList<Card> tokenCreatures = getTokenCreatures(list); // sort tokenCreatures by name (TODO: fix the warning message somehow) Collections.sort( tokenCreatures, new Comparator<Card>() { public int compare(Card c1, Card c2) { return c1.getName().compareTo(c2.getName()); } }); ArrayList<Card> artifacts = getNonCreatureArtifacts(list); ArrayList<Card> enchantments = getGlobalEnchantments(list); // ArrayList<Card> nonBasics = getNonBasics(list); list = new ArrayList<Card>(); list.addAll(planeswalkers); list.addAll(equippedEnchantedCreatures); list.addAll(nonTokenCreatures); list.addAll(tokenCreatures); list.addAll(artifacts); list.addAll(enchantments); int atInStack = 0; int marginX = 5; int marginY = 5; int x = marginX; int cardOffset = Constant.Runtime.stackOffset[0]; String color = ""; ArrayList<JPanel> cards = new ArrayList<JPanel>(); ArrayList<CardPanel> connectedCards = new ArrayList<CardPanel>(); boolean nextEquippedEnchanted = false; int nextXIfNotStacked = 0; Card prevCard = null; for (int i = 0; i < list.size(); i++) { JPanel addPanel; c = list.get(i); addPanel = new CardPanel(c); boolean startANewStack = false; if (!isStackable(c)) { startANewStack = true; } else { String newColor = c.getName(); // CardUtil.getColor(c); if (!newColor.equals(color)) { startANewStack = true; color = newColor; } } if (i == 0) { startANewStack = false; } if (!startANewStack && atInStack == Constant.Runtime.stackSize[0]) { startANewStack = true; } if ((c.isEquipment() || c.isAura()) && (c.isEquipping() || c.isEnchanting()) && !nextEquippedEnchanted) startANewStack = false; else if ((c.isEquipment() || c.isAura()) && (c.isEquipping() || c.isEnchanting())) { startANewStack = true; nextEquippedEnchanted = false; } if (c.isCreature() && (c.isEquipped() || c.isEnchanted())) { startANewStack = false; nextEquippedEnchanted = true; } // very hacky, but this is to ensure equipment stacking occurs correctly when a token is // equipped/enchanted, and there are more tokens of that same name else if ((prevCard != null && c.isCreature() && prevCard.isCreature() && (prevCard.isEquipped() || prevCard.isEnchanted()) && prevCard.getName().equals(c.getName()))) startANewStack = true; else if (prevCard != null && c.isCreature() && prevCard.isCreature() && !prevCard.getName().equals(c.getName())) startANewStack = true; if (((c.isAura() && c.isEnchanting()) || (c.isEquipment() && c.isEquipping())) && prevCard != null && prevCard.isPlaneswalker()) startANewStack = true; if (startANewStack) { setupConnectedCards(connectedCards); connectedCards.clear(); // Fixed distance if last was a stack, looks a bit nicer if (atInStack > 1) { x += Math.max(addPanel.getPreferredSize().width, addPanel.getPreferredSize().height) + marginX; } else { x = nextXIfNotStacked; } atInStack = 0; } else { if (i != 0) { x += cardOffset; } } nextXIfNotStacked = x + marginX + addPanel.getPreferredSize().width; int xLoc = x; int yLoc = marginY; yLoc += atInStack * cardOffset; addPanel.setLocation(new Point(xLoc, yLoc)); addPanel.setSize(addPanel.getPreferredSize()); cards.add(addPanel); connectedCards.add((CardPanel) addPanel); atInStack++; prevCard = c; } setupConnectedCards(connectedCards); connectedCards.clear(); for (int i = cards.size() - 1; i >= 0; i--) { JPanel card = cards.get(i); // maxX = Math.max(maxX, card.getLocation().x + card.getSize().width + marginX); maxY = Math.max(maxY, card.getLocation().y + card.getSize().height + marginY); p.add(card); } maxX = nextXIfNotStacked; if (maxX > 0 && maxY > 0) { // p.getSize().width || maxY > p.getSize().height) { p.setPreferredSize(new Dimension(maxX, maxY)); } } else { JPanel addPanel; for (int i = 0; i < list.size(); i++) { c = list.get(i); addPanel = new CardPanel(c); p.add(addPanel); } } } // setupPanel()
public void drawPanel() { playPanel = new JPanel(); playPanel.setBackground(Color.darkGray); playPanel.setBounds(100, 100, 600, 100); playPanel.setPreferredSize(new Dimension(475, 275)); playPanel.setLayout(null); Image cards = setImage("holder"); playPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; ImageIcon icon = new ImageIcon(cards); playPanel.add(information = new JLabel(" Dealer: Player _ ")); // spacer.setPreferredSize(new Dimension(60,80)); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 5; information.setOpaque(true); information.setBackground(Color.LIGHT_GRAY); playPanel.add(information, c); playPanel.add(spacer = new JLabel(" ")); spacer.setPreferredSize(new Dimension(60, 80)); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 4; playPanel.add(spacer, c); playPanel.add(scores = new JLabel("Team 1: 0 | Team 2: 0 ")); // spacer.setPreferredSize(new Dimension(60,80)); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; scores.setOpaque(true); scores.setBackground(Color.LIGHT_GRAY); playPanel.add(scores, c); playPanel.add(acrossText = new JLabel("Player ")); acrossText.setOpaque(true); acrossText.setBackground(Color.LIGHT_GRAY); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 10; c.gridy = 0; playPanel.add(acrossText, c); playPanel.add(across = new JLabel(icon)); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 10; c.gridy = 1; playPanel.add(across, c); playPanel.add(leftText = new JLabel("Player ")); leftText.setOpaque(true); leftText.setBackground(Color.LIGHT_GRAY); leftText.setPreferredSize(new Dimension(60, 15)); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1; c.gridy = 2; playPanel.add(leftText, c); playPanel.add(left = new JLabel(icon)); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 2; c.gridy = 2; playPanel.add(left, c); playPanel.add(rightText = new JLabel("Player ")); rightText.setOpaque(true); rightText.setBackground(Color.LIGHT_GRAY); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 12; c.gridy = 2; playPanel.add(rightText, c); playPanel.add(right = new JLabel(icon)); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 11; c.gridy = 2; playPanel.add(right, c); playPanel.add(ownText = new JLabel("Player ")); ownText.setOpaque(true); ownText.setBackground(Color.LIGHT_GRAY); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 10; c.gridy = 5; playPanel.add(ownText, c); playPanel.add(own = new JLabel(icon)); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 10; c.gridy = 4; playPanel.add(own, c); playPanel.add(spacer = new JLabel(" ")); spacer.setPreferredSize(new Dimension(60, 80)); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 12; c.gridy = 4; playPanel.add(spacer, c); Image deckImage = setImage("deck"); ImageIcon deckIcon = new ImageIcon(deckImage); playPanel.add(deck = new JLabel(deckIcon)); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 14; c.gridy = 4; playPanel.add(deck, c); playPanel.setLocation(100, 100); add(playPanel); }
/** * Centers the fake cursor (_cursorLabel) position on the coordinates specified in the parameters. */ private void moveCursor(int x, int y) { int dx = x - _cursorLabel.getWidth() / 2; int dy = y - _cursorLabel.getHeight() / 2; _cursorLabel.setLocation(dx, dy); }
public BoundaryVenditoreModificaPrenotazione() throws DAOException, MapException, SQLException, DataException, OraException, CatalogoException { this.controlloreVenditore = ControlloreVenditore.getInstance(); this.boundaryVenditoreModificaPrenotazione = this; pannelloVenditoreModificaPrenotazione = new JPanel(); pannelloVenditoreModificaPrenotazione.setSize( AABoundaryAvvio.Frame.getWidth(), AABoundaryAvvio.Frame.getHeight()); AABoundaryAvvio.Frame.add(pannelloVenditoreModificaPrenotazione); pannelloVenditoreModificaPrenotazione.setLayout(null); panelTitolo.setLayout(null); panelTitolo.setSize(AABoundaryAvvio.Frame.getWidth(), 45); panelTitolo.setLocation(5, 5); panelTitolo.add(titolo); titolo.setFont(new Font("Arial", 0, 30)); titolo.setLocation(border, border); titolo.setSize(panelTitolo.getWidth(), 35); titolo.setHorizontalAlignment(JLabel.CENTER); titolo.setVerticalAlignment(JLabel.CENTER); titolo.setText("Gestore Venditore"); pannelloVenditoreModificaPrenotazione.add(panelTitolo); labelIdOfferta = new JLabel(); prenotazione = new JTextField("", 20); // Bottone back back = new JButton("back"); back.setLocation(500, 350); back.setSize(panelTitolo.getWidth() / 4, 50); back.setFont(new Font("Arial", 0, 20)); aggiuntaBiglietti = new JButton("Aggiunta Biglietti"); aggiuntaBiglietti.setLocation(100, 150); aggiuntaBiglietti.setSize(300, 50); aggiuntaBiglietti.setFont(new Font("Arial", 0, 20)); rimozioneBiglietti = new JButton("Rimozione Biglietti"); rimozioneBiglietti.setLocation(100, 250); rimozioneBiglietti.setSize(300, 50); rimozioneBiglietti.setFont(new Font("Arial", 0, 20)); // Setting Label labelModifica.setFont(new Font("Arial", 0, 30)); labelModifica.setLocation(border, 30); labelModifica.setSize(pannelloVenditoreModificaPrenotazione.getWidth(), 35); labelModifica.setHorizontalAlignment(JLabel.CENTER); labelModifica.setVerticalAlignment(JLabel.CENTER); labelModifica.setText("Inserisci l'id dell'prenotazione da modificare."); // Setting Label labelIdOfferta.setFont(new Font("Arial", 0, 18)); labelIdOfferta.setLocation(100, 100); labelIdOfferta.setSize(150, 35); labelIdOfferta.setText("Prenotazione:"); // Setting area areaVisualizzazione = new JTextArea(); areaVisualizzazione.setLocation(10, 500); areaVisualizzazione.setSize( AABoundaryAvvio.Frame.getWidth(), AABoundaryAvvio.Frame.getHeight()); // Setting delle textBox prenotazione.setLocation(300, 100); prenotazione.setSize(200, 35); prenotazione.setFont(new Font("Arial", 0, 18)); panelButtons.setLayout(null); panelButtons.setSize(AABoundaryAvvio.Frame.getWidth(), AABoundaryAvvio.Frame.getHeight()); panelButtons.setLocation(5, altezzaTitolo); panelButtons.add(labelIdOfferta); panelButtons.add(prenotazione); panelButtons.add(labelModifica); panelButtons.add(areaVisualizzazione); panelButtons.add(aggiuntaBiglietti); panelButtons.add(rimozioneBiglietti); panelButtons.add(back); pannelloVenditoreModificaPrenotazione.add(panelButtons); // Istanziazione dei Listeners buttonsListener = new GestoreButtons(); backListener = new GestoreBack(); // Listener dei bottoni aggiuntaBiglietti.addActionListener(buttonsListener); rimozioneBiglietti.addActionListener(buttonsListener); back.addActionListener(backListener); }
public InfoBox() { // creates border and panel attributes Border border = BorderFactory.createLineBorder(Color.black); panel.setLayout(null); panel.setSize(200, 168); panel.setLocation(253, 221); panel.setBackground(Color.white); panel.setBorder(border); // labels each field JLabel litter = new JLabel("Successful Litter:"); litter.setSize(175, 13); litter.setLocation(5, 3); JLabel coopertition = new JLabel("Coopertition:"); coopertition.setSize(175, 13); coopertition.setLocation(5, 56); JLabel stackapacity = new JLabel("stackapacity:"); stackapacity.setSize(175, 13); stackapacity.setLocation(5, 100); // gives attributes to the check boxes can.setSize(40, 13); can.setLocation(7, 20); floor.setSize(50, 13); floor.setLocation(67, 20); hp.setSize(40, 13); hp.setLocation(127, 20); set.setLocation(10, 80); set.setSize(35, 13); stack.setLocation(60, 80); stack.setSize(50, 13); none.setLocation(120, 80); none.setSize(50, 13); snul.setLocation(10, 140); snul.setSize(23, 13); sone.setLocation(36, 140); sone.setSize(23, 13); stwo.setLocation(59, 140); stwo.setSize(23, 13); sthree.setLocation(82, 140); sthree.setSize(23, 13); sfour.setLocation(105, 140); sfour.setSize(23, 13); sfive.setLocation(128, 140); sfive.setSize(23, 13); ssix.setLocation(151, 140); ssix.setSize(23, 13); plus.setLocation(174, 140); plus.setSize(23, 13); panel.add(litter); panel.add(coopertition); panel.add(stackapacity); panel.add(can); panel.add(floor); panel.add(hp); panel.add(set); panel.add(stack); panel.add(none); panel.add(snul); panel.add(sone); panel.add(stwo); panel.add(sthree); panel.add(sfour); panel.add(sfive); panel.add(ssix); panel.add(plus); }
/** * setupPanel. * * @param p a {@link javax.swing.JPanel} object. * @param list a {@link java.util.ArrayList} object. * @param stack a boolean. */ private static void setupPanel(JPanel p, ArrayList<Card> list, boolean stack) { int maxY = 0; int maxX = 0; // remove all local enchantments Card c; /* for(int i = 0; i < list.size(); i++) { c = (Card)list.get(i); if(c.isLocalEnchantment()) list.remove(i); } //add local enchantments to the permanents //put local enchantments "next to" the permanent they are enchanting //the inner for loop is backward so permanents with more than one local enchantments are in the right order Card ca[]; for(int i = 0; i < list.size(); i++) { c = (Card)list.get(i); if(c.hasAttachedCards()) { ca = c.getAttachedCards(); for(int inner = ca.length - 1; 0 <= inner; inner--) list.add(i + 1, ca[inner]); } } */ if (stack) { // add all Cards in list to the GUI, add arrows to Local Enchantments ArrayList<Card> manaPools = getManaPools(list); ArrayList<Card> enchantedLands = getEnchantedLands(list); ArrayList<Card> basicBlues = getBasics(list, Constant.Color.Blue); ArrayList<Card> basicReds = getBasics(list, Constant.Color.Red); ArrayList<Card> basicBlacks = getBasics(list, Constant.Color.Black); ArrayList<Card> basicGreens = getBasics(list, Constant.Color.Green); ArrayList<Card> basicWhites = getBasics(list, Constant.Color.White); ArrayList<Card> badlands = getNonBasicLand(list, "Badlands"); ArrayList<Card> bayou = getNonBasicLand(list, "Bayou"); ArrayList<Card> plateau = getNonBasicLand(list, "Plateau"); ArrayList<Card> scrubland = getNonBasicLand(list, "Scrubland"); ArrayList<Card> savannah = getNonBasicLand(list, "Savannah"); ArrayList<Card> taiga = getNonBasicLand(list, "Taiga"); ArrayList<Card> tropicalIsland = getNonBasicLand(list, "Tropical Island"); ArrayList<Card> tundra = getNonBasicLand(list, "Tundra"); ArrayList<Card> undergroundSea = getNonBasicLand(list, "Underground Sea"); ArrayList<Card> volcanicIsland = getNonBasicLand(list, "Volcanic Island"); ArrayList<Card> nonBasics = getNonBasics(list); ArrayList<Card> moxEmerald = getMoxen(list, "Mox Emerald"); ArrayList<Card> moxJet = getMoxen(list, "Mox Jet"); ArrayList<Card> moxPearl = getMoxen(list, "Mox Pearl"); ArrayList<Card> moxRuby = getMoxen(list, "Mox Ruby"); ArrayList<Card> moxSapphire = getMoxen(list, "Mox Sapphire"); // ArrayList<Card> moxDiamond = getMoxen(list, "Mox Diamond"); list = new ArrayList<Card>(); list.addAll(manaPools); list.addAll(enchantedLands); list.addAll(basicBlues); list.addAll(basicReds); list.addAll(basicBlacks); list.addAll(basicGreens); list.addAll(basicWhites); list.addAll(badlands); list.addAll(bayou); list.addAll(plateau); list.addAll(scrubland); list.addAll(savannah); list.addAll(taiga); list.addAll(tropicalIsland); list.addAll(tundra); list.addAll(undergroundSea); list.addAll(volcanicIsland); list.addAll(nonBasics); list.addAll(moxEmerald); list.addAll(moxJet); list.addAll(moxPearl); list.addAll(moxRuby); list.addAll(moxSapphire); // list.addAll(moxDiamond); int atInStack = 0; int marginX = 5; int marginY = 5; int x = marginX; int cardOffset = Constant.Runtime.stackOffset[0]; String color = ""; ArrayList<JPanel> cards = new ArrayList<JPanel>(); ArrayList<CardPanel> connectedCards = new ArrayList<CardPanel>(); boolean nextEnchanted = false; Card prevCard = null; int nextXIfNotStacked = 0; for (int i = 0; i < list.size(); i++) { JPanel addPanel; c = list.get(i); addPanel = new CardPanel(c); boolean startANewStack = false; if (!isStackable(c)) { startANewStack = true; } else { String newColor = c.getName(); // CardUtil.getColor(c); if (!newColor.equals(color)) { startANewStack = true; color = newColor; } } if (i == 0) { startANewStack = false; } if (!startANewStack && atInStack == Constant.Runtime.stackSize[0]) { startANewStack = true; } if (c.isAura() && c.isEnchanting() && !nextEnchanted) startANewStack = false; else if (c.isAura() && c.isEnchanting()) { startANewStack = true; nextEnchanted = false; } if (c.isLand() && c.isEnchanted()) { startANewStack = false; nextEnchanted = true; } // very hacky, but this is to ensure enchantment stacking occurs correctly when a land is // enchanted, and there are more lands of that same name else if ((prevCard != null && c.isLand() && prevCard.isLand() && prevCard.isEnchanted() && prevCard.getName().equals(c.getName()))) startANewStack = true; else if (prevCard != null && c.isLand() && prevCard.isLand() && !prevCard.getName().equals(c.getName())) startANewStack = true; /* if (c.getName().equals("Squirrel Nest")) { startANewStack = true; System.out.println("startANewStack: " + startANewStack); } */ if (c.isAura() && c.isEnchanting() && prevCard != null && prevCard instanceof ManaPool) startANewStack = true; if (c instanceof ManaPool && prevCard instanceof ManaPool && prevCard.isSnow()) startANewStack = false; if (startANewStack) { setupConnectedCards(connectedCards); connectedCards.clear(); // Fixed distance if last was a stack, looks a bit nicer if (atInStack > 1) { x += Math.max(addPanel.getPreferredSize().width, addPanel.getPreferredSize().height) + marginX; } else { x = nextXIfNotStacked; } atInStack = 0; } else { if (i != 0) { x += cardOffset; } } nextXIfNotStacked = x + marginX + addPanel.getPreferredSize().width; int xLoc = x; int yLoc = marginY; yLoc += atInStack * cardOffset; addPanel.setLocation(new Point(xLoc, yLoc)); addPanel.setSize(addPanel.getPreferredSize()); cards.add(addPanel); connectedCards.add((CardPanel) addPanel); atInStack++; prevCard = c; } setupConnectedCards(connectedCards); connectedCards.clear(); for (int i = cards.size() - 1; i >= 0; i--) { JPanel card = cards.get(i); // maxX = Math.max(maxX, card.getLocation().x + card.getSize().width + marginX); maxY = Math.max(maxY, card.getLocation().y + card.getSize().height + marginY); p.add(card); } maxX = nextXIfNotStacked; // System.out.println("x:" + maxX + ", y:" + maxY); if (maxX > 0 && maxY > 0) { // p.getSize().width || maxY > p.getSize().height) { // p.setSize(new Dimension(maxX, maxY)); p.setPreferredSize(new Dimension(maxX, maxY)); } } else { // add all Cards in list to the GUI, add arrows to Local Enchantments JPanel addPanel; for (int i = 0; i < list.size(); i++) { c = list.get(i); /*if(c.isLocalEnchantment()) addPanel = getCardPanel(c, "<< " +c.getName()); else addPanel = getCardPanel(c); */ addPanel = new CardPanel(c); p.add(addPanel); } } } // setupPanel()
public NouveauWindow2( JRadioButton deuxj2, JRadioButton troisj2, JRadioButton quatrej2, JTextField jaune2, JTextField rouge2, JTextField bleu2, JTextField vert2) { this.setTitle("Rail Roadie"); this.setResizable(false); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.setUndecorated(true); this.setSize(1000, 750); this.setLocationRelativeTo(null); this.setVisible(true); this.setContentPane(new Fond()); this.setLayout(null); ButtonGroup grp = new ButtonGroup(); JRadioButton deuxj = deuxj2; JRadioButton troisj = troisj2; JRadioButton quatrej = quatrej2; JPanel nbjoueurs = new JPanel(); nbjoueurs.setLayout(new GridLayout(1, 3)); nbjoueurs.add(deuxj); grp.add(deuxj); nbjoueurs.add(troisj); grp.add(troisj); nbjoueurs.add(quatrej); grp.add(quatrej); this.add(nbjoueurs); nbjoueurs.setPreferredSize(new Dimension(250, 30)); nbjoueurs.setLocation(375, 150); nbjoueurs.setBounds(375, 150, 625, 180); nbjoueurs.setSize(new Dimension(250, 30)); JPanel a = new JPanel(); JLabel b = new JLabel("Nombre de joueurs", JLabel.CENTER); a.add(b); this.add(a); a.setPreferredSize(new Dimension(250, 30)); a.setLocation(375, 120); a.setBounds(375, 120, 625, 150); a.setSize(new Dimension(250, 30)); int nb = -1; if (deuxj.isSelected()) nb = 2; if (troisj.isSelected()) nb = 3; if (quatrej.isSelected()) nb = 4; JPanel joueurs = new JPanel(); JTextField jaune = jaune2; JTextField rouge = rouge2; JTextField bleu = bleu2; JTextField vert = vert2; deuxj.setEnabled(false); troisj.setEnabled(false); quatrej.setEnabled(false); jaune.setEditable(false); rouge.setEditable(false); bleu.setEditable(false); vert.setEditable(false); joueurs.setLayout(new GridLayout(nb, 2)); for (int i = 0; i < nb; i++) { if (i == 0) { joueurs.add(new JLabel("Nom du joueur jaune", JLabel.CENTER)); joueurs.add(jaune); } if (i == 1) { joueurs.add(new JLabel("Nom du joueur rouge", JLabel.CENTER)); joueurs.add(rouge); } if (i == 2) { joueurs.add(new JLabel("Nom du joueur bleu", JLabel.CENTER)); joueurs.add(bleu); } if (i == 3) { joueurs.add(new JLabel("Nom du joueur vert", JLabel.CENTER)); joueurs.add(vert); } } this.add(joueurs); joueurs.setPreferredSize(new Dimension(300, nb * 30)); joueurs.setLocation(350, 250); joueurs.setBounds(350, 250, 650, 250 + nb * 30); joueurs.setSize(new Dimension(300, nb * 30)); PiocheD piocheD = new PiocheD(); ArrayList<CarteD> tmp = new ArrayList<CarteD>(); ArrayList<CarteD> tmp2 = new ArrayList<CarteD>(); ArrayList<CarteD> tmp3 = new ArrayList<CarteD>(); ArrayList<CarteD> tmp4 = new ArrayList<CarteD>(); ArrayList<JCheckBox> box1 = new ArrayList<JCheckBox>(); ArrayList<JCheckBox> box2 = new ArrayList<JCheckBox>(); ArrayList<JCheckBox> box3 = new ArrayList<JCheckBox>(); ArrayList<JCheckBox> box4 = new ArrayList<JCheckBox>(); for (int j = 0; j < 3; j++) { tmp.add(piocheD.piocher(6)); } int random = (int) (Math.random() * (6 - 0)); tmp.add(piocheD.piocher(random)); JCheckBox j1carteD1 = new JCheckBox(tmp.get(0).getVille1() + " - " + tmp.get(0).getVille2()); JCheckBox j1carteD2 = new JCheckBox(tmp.get(1).getVille1() + " - " + tmp.get(1).getVille2()); JCheckBox j1carteD3 = new JCheckBox(tmp.get(2).getVille1() + " - " + tmp.get(2).getVille2()); JCheckBox j1carteD4 = new JCheckBox(tmp.get(3).getVille1() + " - " + tmp.get(3).getVille2()); box1.add(j1carteD1); box1.add(j1carteD2); box1.add(j1carteD2); box1.add(j1carteD4); JLabel j1 = new JLabel("Cartes Destination de Jaune"); JPanel cartesj1 = new JPanel(); cartesj1.setLayout(new GridLayout(1, 5)); cartesj1.add(j1); cartesj1.add(j1carteD1); cartesj1.add(j1carteD2); cartesj1.add(j1carteD3); cartesj1.add(j1carteD4); this.add(cartesj1); cartesj1.setPreferredSize(new Dimension(850, 30)); cartesj1.setLocation(75, 400); cartesj1.setBounds(75, 400, 925, 430); cartesj1.setSize(new Dimension(850, 30)); for (int j = 0; j < 3; j++) { tmp2.add(piocheD.piocher(6)); } random = (int) (Math.random() * (6 - 0)); tmp2.add(piocheD.piocher(random)); JCheckBox j2carteD1 = new JCheckBox(tmp2.get(0).getVille1() + " - " + tmp2.get(0).getVille2()); JCheckBox j2carteD2 = new JCheckBox(tmp2.get(1).getVille1() + " - " + tmp2.get(1).getVille2()); JCheckBox j2carteD3 = new JCheckBox(tmp2.get(2).getVille1() + " - " + tmp2.get(2).getVille2()); JCheckBox j2carteD4 = new JCheckBox(tmp2.get(3).getVille1() + " - " + tmp2.get(3).getVille2()); box2.add(j2carteD1); box2.add(j2carteD2); box2.add(j2carteD2); box2.add(j2carteD4); JLabel j2 = new JLabel("Cartes Destination de Rouge"); JPanel cartesj2 = new JPanel(); cartesj2.setLayout(new GridLayout(1, 5)); cartesj2.add(j2); cartesj2.add(j2carteD1); cartesj2.add(j2carteD2); cartesj2.add(j2carteD3); cartesj2.add(j2carteD4); this.add(cartesj2); cartesj2.setPreferredSize(new Dimension(850, 30)); cartesj2.setLocation(75, 400 + 30 * 1); cartesj2.setBounds(75, 400 + 30 * 1, 925, 430 + 30 * 1); cartesj2.setSize(new Dimension(850, 30)); if (nb >= 3) { for (int j = 0; j < 3; j++) { tmp3.add(piocheD.piocher(6)); } random = (int) (Math.random() * (6 - 0)); tmp3.add(piocheD.piocher(random)); JCheckBox j3carteD1 = new JCheckBox(tmp3.get(0).getVille1() + " - " + tmp3.get(0).getVille2()); JCheckBox j3carteD2 = new JCheckBox(tmp3.get(1).getVille1() + " - " + tmp3.get(1).getVille2()); JCheckBox j3carteD3 = new JCheckBox(tmp3.get(2).getVille1() + " - " + tmp3.get(2).getVille2()); JCheckBox j3carteD4 = new JCheckBox(tmp3.get(3).getVille1() + " - " + tmp3.get(3).getVille2()); box3.add(j3carteD1); box3.add(j3carteD2); box3.add(j3carteD2); box3.add(j3carteD4); JLabel j3 = new JLabel("Cartes Destination de Bleu"); JPanel cartesj3 = new JPanel(); cartesj3.setLayout(new GridLayout(1, 5)); cartesj3.add(j3); cartesj3.add(j3carteD1); cartesj3.add(j3carteD2); cartesj3.add(j3carteD3); cartesj3.add(j3carteD4); this.add(cartesj3); cartesj3.setPreferredSize(new Dimension(850, 30)); cartesj3.setLocation(75, 400 + 30 * 2); cartesj3.setBounds(75, 400 + 30 * 2, 925, 430 + 30 * 2); cartesj3.setSize(new Dimension(850, 30)); } if (nb == 4) { for (int j = 0; j < 3; j++) { tmp4.add(piocheD.piocher(6)); } random = (int) (Math.random() * (6 - 0)); tmp4.add(piocheD.piocher(random)); JCheckBox j4carteD1 = new JCheckBox(tmp4.get(0).getVille1() + " - " + tmp4.get(0).getVille2()); JCheckBox j4carteD2 = new JCheckBox(tmp4.get(1).getVille1() + " - " + tmp4.get(1).getVille2()); JCheckBox j4carteD3 = new JCheckBox(tmp4.get(2).getVille1() + " - " + tmp4.get(2).getVille2()); JCheckBox j4carteD4 = new JCheckBox(tmp4.get(3).getVille1() + " - " + tmp4.get(3).getVille2()); box4.add(j4carteD1); box4.add(j4carteD2); box4.add(j4carteD2); box4.add(j4carteD4); JLabel j4 = new JLabel("Cartes Destination de Vert"); JPanel cartesj4 = new JPanel(); cartesj4.setLayout(new GridLayout(1, 5)); cartesj4.add(j4); cartesj4.add(j4carteD1); cartesj4.add(j4carteD2); cartesj4.add(j4carteD3); cartesj4.add(j4carteD4); this.add(cartesj4); cartesj4.setPreferredSize(new Dimension(850, 30)); cartesj4.setLocation(75, 400 + 30 * 3); cartesj4.setBounds(75, 400 + 30 * 3, 925, 430 + 30 * 3); cartesj4.setSize(new Dimension(850, 30)); } JButton terminer = new JButton("Terminer"); this.add(terminer); terminer.setPreferredSize(new Dimension(100, 30)); terminer.setLocation(450, 550); terminer.setBounds(450, 550, 550, 580); terminer.setSize(new Dimension(100, 30)); terminer.addActionListener( new NouveauListener2(nb, tmp, tmp2, tmp3, tmp4, box1, box2, box3, box4, piocheD, this)); }
public Sale() { // 计算销售公司的总销售额和各销售员的佣金。 // 设置字体 button1.setFont(f2); button1.setBounds(350, 50, 150, 50); button2.setFont(f2); button2.setBounds(550, 50, 150, 50); text1.setText("00"); text2.setText("00"); text3.setText("00"); ta1.setLocation(20, 20); ta1.setSize(300, 200); ta1.setText(" 输出结果!"); ta1.setVisible(true); // text4.setEditable(false); ta1.setEnabled(false); ta2.setLocation(20, 20); ta2.setSize(300, 200); // ta2.setForeground(Color.red); ta2.setText( "各销售员每月至少需售出 白酒50瓶, 红酒30瓶, 啤酒300瓶。\n每月的最高供应量:白酒为5000瓶,红酒为3000瓶,啤酒为30000瓶。\n白酒、红酒和啤酒的单价分别为168元/瓶、 120元/瓶、5元/瓶。"); ta2.setVisible(true); // text4.setEditable(false); ta2.setEnabled(false); // 确定 button1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // 判断是否是按钮 if (e.getSource() == button1) { // 添加正则表达式 验证输入数据是否满足 XXXX-XX-XX的日期格式 // 字符转整形?? text1.setText(text1.getText()); text2.setText(text2.getText()); text3.setText(text3.getText()); str1 = text1.getText(); str2 = text2.getText(); str3 = text3.getText(); ta1.setText(ta1.getText()); str4 = ta1.getText(); if (((Integer.parseInt(str1) >= b1) && (Integer.parseInt(str1) <= a1)) && ((Integer.parseInt(str2) >= b2) && (Integer.parseInt(str2) <= a2)) && ((Integer.parseInt(str3) >= b3) && (Integer.parseInt(str3) <= a3))) { c1 = Integer.parseInt(str1) * x1; c2 = Integer.parseInt(str2) * x2; c3 = Integer.parseInt(str3) * x3; c4 = c1 + c2 + c3; str4 = ":" + c4; // 分别计算利润 if (c4 < w1) { str5 = "" + (c4 * 0.04); } else if ((c4 > w1) && (c4 < w2)) { str5 = "" + (((c4 - 20000) * 0.01) + (20000 * 0.04)); } else { str5 = "" + (((c4 - 45000) * 0.005) + (25000 * 0.01) + (20000 * 0.04)); } ta1.setFont(f2); ta1.setText( "利润结果统计表:" + "\n\t白酒销售额:" + c1 + "\n\t红酒销售额:" + c2 + "\n\t啤酒销售额:" + c3 + "\n总销售额:" + str4 + "\n总利润:" + str5); } else { str4 = "出错了!"; if (!((Integer.parseInt(str1) >= b1) && (Integer.parseInt(str1) <= a1))) { text1.setText(str4); } if (!((Integer.parseInt(str2) >= b2) && (Integer.parseInt(str2) <= a2))) { text2.setText(str4); } if (!((Integer.parseInt(str3) >= b3) && (Integer.parseInt(str3) <= a3))) { text3.setText(str4); } ta1.setFont(f2); ta1.setText(str4); } } } }); // 确定 button2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // 判断是否是按钮 if (e.getSource() == button2) { // 添加正则表达式 验证输入数据是否满足 XXXX-XX-XX的日期格式 // 字符转整形?? text1.setText(""); text2.setText(""); text3.setText(""); ta1.setText("请输入数据!"); } } }); frame1.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(1); } }); // 创建布局 // GridLayout gl1 = new GridLayout(2, 3);// 设置网格布局(h,v) FlowLayout fl1 = new FlowLayout(FlowLayout.CENTER, 20, 12); // 对齐,H间距,V间距{设置流式布局(panel默认布局)从左到右 // 依次} // 现在所有的内容都加入到了JPanel1之中 panel1.add(label1); panel1.add(text1); panel1.add(label2); panel1.add(text2); panel1.add(label3); panel1.add(text3); panel1.add(ta2); panel1.setSize(770, 300); // panel1.setBounds(0, 0, 200, 100); panel1.setLocation(10, 10); panel1.setBackground(Color.green); panel1.setLayout(fl1); panel2.add(label4); panel2.add(ta1); panel2.add(button1); panel2.add(button2); panel2.setSize(770, 300); panel2.setLayout(null); panel2.setLocation(10, 320); // panel2.setBackground(Color.blue); // panel2.setLayout(fl1); frame1.setResizable(false); frame1.add(panel1); // 将面板加入到窗体之上 frame1.add(panel2); // 将面板加入到窗体之上 // 设置属性 frame1.setLayout(null); // 参数null可以取消frame布局,使用绝对布局 frame1.setBounds(200, 30, 800, 670); // 绝对布局 frame1.setFont(font2); frame1.setBackground(Color.RED); // 设置窗体的背景颜色?//frame1.setForeground(Color.BLUE);将前景色设置成蓝色 frame1.setVisible(true); // 让组件可见 }
void setupGUI() { taDictionary = new TextArea(); taDictionary.setLocation(0, 0); taDictionary.setSize(106, 567); taDictionary.setBackground(new Color(-1)); taDictionary.setText(""); taDictionary.setRows(5); taDictionary.setColumns(1); getContentPane().add(taDictionary); tfSourc = new TextField(); tfSourc.setLocation(224, 90); tfSourc.setSize(266, 25); tfSourc.setBackground(new Color(-1)); tfSourc.setText(""); tfSourc.setColumns(10); getContentPane().add(tfSourc); lblSourc = new Label(); lblSourc.setLocation(106, 90); lblSourc.setSize(119, 25); lblSourc.setText("Source Word:"); getContentPane().add(lblSourc); /* lblDestinatio = new Label(); lblDestinatio.setLocation(106,97); lblDestinatio.setSize(119,25); lblDestinatio.setText("Destination Wor"); getContentPane().add(lblDestinatio); */ lblDestinatio = new Label(); lblDestinatio.setLocation(106, 120); lblDestinatio.setSize(119, 25); lblDestinatio.setText("Destination Word:"); getContentPane().add(lblDestinatio); lblWordSize = new Label(); lblWordSize.setLocation(106, 27); // 106,120 lblWordSize.setSize(119, 25); lblWordSize.setText("Word Size:"); getContentPane().add(lblWordSize); tfWordSize = new TextField(); tfWordSize.setLocation(224, 27); // 224,120 tfWordSize.setSize(263, 25); tfWordSize.setBackground(new Color(-1)); tfWordSize.setText("5"); tfWordSize.setColumns(10); getContentPane().add(tfWordSize); tfSourc_6 = new TextField(); tfSourc_6.setLocation(226, 120); tfSourc_6.setSize(263, 25); tfSourc_6.setBackground(new Color(-1)); tfSourc_6.setText(""); tfSourc_6.setColumns(10); getContentPane().add(tfSourc_6); lblFileNam = new Label(); lblFileNam.setLocation(104, 0); lblFileNam.setSize(119, 25); lblFileNam.setText("FilePath:"); getContentPane().add(lblFileNam); tfFilePat = new TextField(); tfFilePat.setLocation(224, 0); tfFilePat.setSize(266, 25); tfFilePat.setBackground(new Color(-1)); // OS Detection if (System.getProperty("os.name").startsWith("Windows")) { // includes: Windows 2000, Windows 95, Windows 98, Windows NT, Windows Vista, Windows XP tfFilePat.setText("c:\\ics340\\words.txt"); System.out.println("Detected Windows: " + System.getProperty("os.name")); } else { tfFilePat.setText("/Users/jasonedstrom/ics340/d1.txt"); System.out.println("Detected Mac OS X: " + System.getProperty("os.name")); } tfFilePat.setColumns(10); getContentPane().add(tfFilePat); btLoadTextFiel = new JButton(); btLoadTextFiel.setLocation(108, 50); // 108,27 btLoadTextFiel.setSize(198, 32); btLoadTextFiel.setText("Load Words from Text Field"); getContentPane().add(btLoadTextFiel); btLoadFil = new JButton(); btLoadFil.setLocation(306, 50); // 306,27 btLoadFil.setSize(183, 32); btLoadFil.setText("Load Words from File"); getContentPane().add(btLoadFil); btFindPat = new JButton(); btFindPat.setLocation(106, 160); btFindPat.setSize(384, 38); btFindPat.setText("Find Path"); getContentPane().add(btFindPat); lblDictCoun = new JLabel(); lblDictCoun.setLocation(108, 513); lblDictCoun.setSize(300, 27); lblDictCoun.setForeground(new Color(-65536)); lblDictCoun.setText("Words in Dictionary = 0 words"); getContentPane().add(lblDictCoun); lblIndexing1 = new JLabel(); lblIndexing1.setLocation(107, 454); lblIndexing1.setSize(130, 27); lblIndexing1.setForeground(new Color(-16777216)); lblIndexing1.setText(""); getContentPane().add(lblIndexing1); lblFindPat = new JLabel(); lblFindPat.setLocation(108, 540); lblFindPat.setSize(250, 27); lblFindPat.setForeground(new Color(-14646771)); lblFindPat.setText("Time to find Path: 0 milliseconds"); getContentPane().add(lblFindPat); lblCos = new JLabel(); lblCos.setLocation(360, 540); lblCos.setSize(175, 27); lblCos.setForeground(new Color(-16777216)); lblCos.setText("Cost of Path: 0.0"); getContentPane().add(lblCos); lblProgres = new JLabel(); lblProgres.setLocation(108, 484); lblProgres.setSize(371, 26); lblProgres.setForeground(new Color(-14646771)); lblProgres.setText("Time to Build Graph: 0 milliseconds"); getContentPane().add(lblProgres); testpanel = new JPanel(); testpanel.setLocation(106, 200); testpanel.setSize(350, 200); testpanel.setForeground(new Color(-14646771)); // testpanel.setText("Test Location"); getContentPane().add(testpanel); btClear = new JButton(); btClear.setLocation(355, 513); btClear.setSize(125, 25); btClear.setText("Clear Results"); getContentPane().add(btClear); // add actionlisteners to buttons btFindPat.addActionListener(this); btLoadTextFiel.addActionListener(this); btLoadFil.addActionListener(this); btClear.addActionListener(this); setTitle("WordLadderGUI"); setSize(500, 600); setVisible(true); setResizable(false); }
/** Create the dialog. */ public Normalize(ArrayList<RelationCheckBox> relList, final int proccess) { switch (proccess) { case 1: setTitle("Normalizaci\u00F3n hasta 3FN"); break; case 2: setTitle("Normalizaci\u00F3n hasta FNBC"); break; default: setTitle("Normalizaci\u00F3n hasta 4FN"); break; } setBounds(100, 100, 601, 360); getContentPane().setLayout(null); final ArrayList<RelationCheckBox> rList = new ArrayList<>(relList); final ButtonGroup rdGroup = new ButtonGroup(); JPanel panel = new JPanel(); panel.setLocation(0, 0); panel.setSize(584, 347); panel.setLayout(null); getContentPane().add(panel); final JTextArea textArea = new JTextArea(); textArea.setBounds(120, 155, 310, 161); JScrollPane scroll = new JScrollPane(textArea); scroll.setBounds(120, 155, 310, 161); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); panel.add(scroll); JLabel lblNewLabel = new JLabel("Resultado:"); lblNewLabel.setBounds(10, 155, 60, 24); panel.add(lblNewLabel); final JLabel info = new JLabel(""); info.setBounds(10, 130, 400, 25); panel.add(info); JButton btnNewButton = new JButton("Normalizar"); btnNewButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { Relation r1 = new Relation(); for (RelationCheckBox rel : rList) { if (rel.getRdButton().isSelected()) { r1 = new Relation(rel.getRelation().getAttrJoint(), rel.getRelation().getDFJoint()); r1.setName(rel.getRelation().getName()); } } rdGroup.clearSelection(); ArrayList<Relation> result; switch (proccess) { case 1: result = Normalization.normalize3NF(r1, true); break; case 2: result = Normalization.normalizeBCNF(r1, true); break; default: result = Normalization.normalize4NF(r1, true); break; } textArea.setText(null); int i = 0; for (Relation r : result) { int j = i + 1; textArea.append( "R" + j + ": " + '\n' + r.getAttrJoint().toString() + '\n' + r.getDFJoint().toString() + '\n'); i++; } info.setText("Normalizaci\u00F3n de la relaci\u00F3n " + '"' + r1.getName() + '"'); } }); btnNewButton.setBounds(460, 155, 100, 25); panel.add(btnNewButton); for (int i = 0; i < rList.size(); i++) { JSeparator sep = new JSeparator(); sep.setBounds(0, 9 + 90 * i, 850, 1); sep.setForeground(Color.BLACK); rList.get(i).getRdButton().setBounds(5, 10 + 90 * i, 450, 25); JLabel attrJoint = new JLabel("Atributos: " + rList.get(i).getRelation().getAttrJoint().toString()); attrJoint.setBounds(5, 40 + 90 * i, 450, 20); attrJoint.setFont(new Font("Tahoma", Font.PLAIN, 12)); JLabel dfJoint = new JLabel("Dependencias: " + rList.get(i).getRelation().getDFJoint().toString()); dfJoint.setBounds(5, 70 + 90 * i, 450, 20); dfJoint.setFont(new Font("Tahoma", Font.PLAIN, 12)); panel.add(sep); panel.add(rList.get(i).getRdButton()); panel.add(attrJoint); panel.add(dfJoint); rdGroup.add(rList.get(i).getRdButton()); } }