public void update() { graphicPanel.removeAll(); graphicPanel.add(title); graphicPanel.add(mainMenuButton); graphicPanel.add(refreshButton); graphicPanel.add(logoutButton); graphicPanel.setLayout(new FlowLayout()); JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL); separator.setPreferredSize(new Dimension(600, 10)); graphicPanel.add(separator); if (page.matches("main")) { graphicPanel.add(reportLocationButton); graphicPanel.add(loadShipmentButton); } else if (page.matches("reportloc")) { locationComboBox = new JComboBox(driver.getLocation().getNeighbours().toArray()); graphicPanel.add(locationComboBox); graphicPanel.add(reportButton); } else if (page.matches("loadShipment")) { shipmentList = new ArrayList<Shipment>(); for (int i = 0; i < driverService.getAssignedShipments().size(); ++i) { if (driverService.canPickup(driver, driverService.getAssignedShipments().get(i))) { shipmentList.add(driverService.getAssignedShipments().get(i)); } } Object[][] tableContent = new Object[shipmentList.size()][shipmentTableColumnTitles.length]; for (int i = 0; i < shipmentList.size(); ++i) { tableContent[i][0] = shipmentList.get(i).getType(); tableContent[i][1] = shipmentList.get(i).getApproximateWeight(); tableContent[i][2] = shipmentList.get(i).getDueDate(); tableContent[i][3] = shipmentList.get(i).getDestination(); } shipmentTable = new JTable(tableContent, shipmentTableColumnTitles); shipmentTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane tablePane = new JScrollPane(shipmentTable); tablePane.setPreferredSize(new Dimension(550, 250)); graphicPanel.add(tablePane); graphicPanel.add(pickupButton); } graphicPanel.validate(); graphicPanel.repaint(); }
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { int labelX = x + outsideInsets.left; int labelY = y + outsideInsets.top; TitledSeparator titledSeparator = getTitledSeparator(c); JLabel label = titledSeparator.getLabel(); Dimension labelSize = label.getPreferredSize(); label.setSize(labelSize); g.translate(labelX, labelY); label.paint(g); int separatorX = labelX + labelSize.width + TitledSeparator.SEPARATOR_LEFT_INSET; int separatorY = labelY + (UIUtil.isUnderAquaLookAndFeel() ? 2 : labelSize.height / 2 - 1); int separatorW = Math.max(0, width - separatorX - TitledSeparator.SEPARATOR_RIGHT_INSET); int separatorH = 2; JSeparator separator = titledSeparator.getSeparator(); separator.setSize(separatorW, separatorH); g.translate(separatorX - labelX, separatorY - labelY); separator.paint(g); g.translate(-separatorX, -separatorY); }
public void show(Component invoker, int x, int y) { ViperViewMediator mediator = getMediator(); Point pnt = new Point(x, y); EnhancedTable tab = getTable(); int row = tab.rowAtPoint(pnt); desc = getCurrentModel().getDescriptorAtRow(row); int col = tab.columnAtPoint(pnt); Object cellValue = tab.getValueAt(row, col); if (cellValue instanceof Attribute) { attr = (Attribute) cellValue; // hide the "Occlusions..." option when we're not dealing with a Textline object boolean isTextline = attr.getAttrConfig().getAttrType().endsWith("textline"); occlusions.setVisible(isTextline); occSeparator.setVisible(isTextline); Instant now = mediator.getCurrentFrame(); if (now == null) { mediator.getDisplayWRTManager().setAttribute(null, null); wrt.setEnabled(false); wrt.setSelected(false); } else { boolean isDwrt = attr == mediator.getDisplayWRTManager().getAttribute(); boolean dwrtable = (attr.getAttrValueAtInstant(now) instanceof HasCentroid && attr.getDescriptor().getValidRange().contains(now)); wrt.setEnabled(dwrtable); wrt.setSelected(isDwrt); } } else { attr = null; wrt.setEnabled(false); wrt.setSelected(false); } if (null != desc) { PropagateInterpolateModule proper = getMediator().getPropagator(); p.setSelected(proper.isPropagatingThis(desc)); v.setSelected(mediator.isThisValidNow(desc)); resetMarks(); super.show(invoker, x, y); } }
@Override public Object get(SynthContext context, Object key) { // See if this is a class specific value. String classKey = CLASS_SPECIFIC_MAP.get(key); if (classKey != null) { Object value = getClassSpecificValue(classKey); if (value != null) { return value; } } // Is it a specific value ? if (key == "ScrollPane.viewportBorderInsets") { return getThicknessInsets(context, new Insets(0, 0, 0, 0)); } else if (key == "Slider.tickColor") { return getColorForState(context, ColorType.FOREGROUND); } else if (key == "ScrollBar.minimumThumbSize") { int len = getClassSpecificIntValue(context, "min-slider-length", 21); JScrollBar sb = (JScrollBar) context.getComponent(); if (sb.getOrientation() == JScrollBar.HORIZONTAL) { return new DimensionUIResource(len, 0); } else { return new DimensionUIResource(0, len); } } else if (key == "Separator.thickness") { JSeparator sep = (JSeparator) context.getComponent(); if (sep.getOrientation() == JSeparator.HORIZONTAL) { return getYThickness(); } else { return getXThickness(); } } else if (key == "ToolBar.separatorSize") { int size = getClassSpecificIntValue(WidgetType.TOOL_BAR, "space-size", 12); return new DimensionUIResource(size, size); } else if (key == "ScrollBar.buttonSize") { JScrollBar sb = (JScrollBar) context.getComponent().getParent(); boolean horiz = (sb.getOrientation() == JScrollBar.HORIZONTAL); WidgetType wt = horiz ? WidgetType.HSCROLL_BAR : WidgetType.VSCROLL_BAR; int sliderWidth = getClassSpecificIntValue(wt, "slider-width", 14); int stepperSize = getClassSpecificIntValue(wt, "stepper-size", 14); return horiz ? new DimensionUIResource(stepperSize, sliderWidth) : new DimensionUIResource(sliderWidth, stepperSize); } else if (key == "ArrowButton.size") { String name = context.getComponent().getName(); if (name != null && name.startsWith("Spinner")) { // Believe it or not, the size of a spinner arrow button is // dependent upon the size of the spinner's font. These // calculations come from gtkspinbutton.c (version 2.8.20), // spin_button_get_arrow_size() method. String pangoFontName; synchronized (sun.awt.UNIXToolkit.GTK_LOCK) { pangoFontName = nativeGetPangoFontName(WidgetType.SPINNER.ordinal()); } int arrowSize = (pangoFontName != null) ? PangoFonts.getFontSize(pangoFontName) : 10; return (arrowSize + (getXThickness() * 2)); } // For all other kinds of arrow buttons (e.g. combobox arrow // buttons), we will simply fall back on the value of // ArrowButton.size as defined in the UIDefaults for // GTKLookAndFeel when we call UIManager.get() below... } else if ("CheckBox.iconTextGap".equals(key) || "RadioButton.iconTextGap".equals(key)) { // The iconTextGap value needs to include "indicator-spacing" // and it also needs to leave enough space for the focus line, // which falls between the indicator icon and the text. // See getRadioInsets() and 6489585 for more details. int indicatorSpacing = getClassSpecificIntValue(context, "indicator-spacing", 2); int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1); int focusPad = getClassSpecificIntValue(context, "focus-padding", 1); return indicatorSpacing + focusSize + focusPad; } // Is it a stock icon ? GTKStockIcon stockIcon = null; synchronized (ICONS_MAP) { stockIcon = ICONS_MAP.get(key); } if (stockIcon != null) { return stockIcon; } // Is it another kind of value ? if (key != "engine") { // For backward compatibility we'll fallback to the UIManager. // We don't go to the UIManager for engine as the engine is GTK // specific. Object value = UIManager.get(key); if (key == "Table.rowHeight") { int focusLineWidth = getClassSpecificIntValue(context, "focus-line-width", 0); if (value == null && focusLineWidth > 0) { value = Integer.valueOf(16 + 2 * focusLineWidth); } } return value; } // Don't call super, we don't want to pick up defaults from // SynthStyle. return null; }
/** this method is used to design Main UI of Rack manager */ private void initComponents() { label2 = new JLabel(); panel1 = new JPanel(); label1 = new JLabel(); separator1 = new JSeparator(); comboBox1 = new JComboBox<Object>(); textField1 = new JTextField(); label4 = new JLabel(); label3 = new JLabel(); scrollPane1 = new JScrollPane(); textArea1 = new JTextArea(); button1 = new JButton(); button2 = new JButton(); button3 = new JButton(); button4 = new JButton(); button5 = new JButton(); button6 = new JButton(); scrollPane2 = new JScrollPane(); tableModel = new DefaultTableModel(); table1 = new JTable(tableModel); // ======== this ======== setResizable(false); Container contentPane = getContentPane(); contentPane.setLayout(null); // ======== panel1 ======== { panel1.setLayout(null); // ---- label1 ---- label1.setText("Manage Rack"); label1.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 30)); panel1.add(label1); label1.setBounds(200, 10, 400, 50); panel1.add(separator1); separator1.setBounds(0, 100, 600, 5); // ---- label2 ---- label2.setText("Select Store"); panel1.add(label2); label2.setBounds(100, 120, 150, 20); panel1.add(comboBox1); comboBox1.setBounds(250, 120, 200, 20); comboBox1.addItemListener(this); // ---- label3 ---- label3.setText("<html>Rack Name <font color='red'><b>*</b></font></html>"); panel1.add(label3); label3.setBounds(100, 160, 160, 20); panel1.add(textField1); textField1.setBounds(250, 160, 200, 20); // ---- label4 ---- label4.setText("Description"); panel1.add(label4); label4.setBounds(100, 200, 150, 20); // ======== scrollPane1 ======== { scrollPane1.setViewportView(textArea1); } panel1.add(scrollPane1); scrollPane1.setBounds(250, 200, 200, 100); // ---- button1 ---- button1.setText("Save"); panel1.add(button1); button1.setBounds(100, 350, 100, 30); button1.addActionListener(this); // ---- button2 ---- button2.setText("Refresh"); panel1.add(button2); button2.setBounds(250, 350, 100, 30); button2.addActionListener(this); // ---- button3 ---- button3.setText("Exit"); panel1.add(button3); button3.setBounds(400, 350, 100, 30); button3.addActionListener(this); // ---- button4 ---- button4.setText("View"); panel1.add(button4); button4.setBounds(100, 400, 100, 30); button4.addActionListener(this); // ---- button5 ---- button5.setText("Update"); panel1.add(button5); button5.setBounds(250, 400, 100, 30); button5.addActionListener(this); // ---- button6 ---- button6.setText("Delete"); panel1.add(button6); button6.setBounds(400, 400, 100, 30); button6.addActionListener(this); tableModel.addColumn("Sr. No."); tableModel.addColumn("Rack Name"); // ======== scrollPane2 ======== { scrollPane2.setViewportView(table1); } panel1.add(scrollPane2); scrollPane2.setBounds(50, 460, 500, 170); } contentPane.add(panel1); panel1.setBounds(0, 0, 600, 700); setTitle("Rack Manager"); setDefaultCloseOperation(DISPOSE_ON_CLOSE); pack(); setVisible(true); // setLocationRelativeTo(getOwner()); setLocation(100, 10); setSize(600, 700); }
private void initComponents() { panel1 = new JPanel(); label1 = new JLabel(); separator1 = new JSeparator(); button3 = new JButton(); button4 = new JButton(); button5 = new JButton(); scrollPane2 = new JScrollPane(); tableModel1 = new DefaultTableModel(); table1 = new JTable(tableModel1); panel2 = new JPanel(); label5 = new JLabel(); textField1 = new JTextField(); label2 = new JLabel(); label3 = new JLabel(); textField2 = new JTextField(); textField3 = new JTextField(); button1 = new JButton(); button2 = new JButton(); // ======== this ======== setResizable(false); Container contentPane = getContentPane(); contentPane.setLayout(null); // ======== panel1 ======== { panel1.setLayout(null); // ---- label1 ---- label1.setText("Manage Vat %"); panel1.add(label1); label1.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 30)); label1.setBounds(200, 10, 400, 50); panel1.add(separator1); separator1.setBounds(0, 100, 600, 5); // ======== panel2 ======== { panel2.setBorder(UIManager.getBorder("TitledBorder.border")); panel2.setLayout(null); // ---- label3 ---- label3.setText("<html>Year : <font color='red'><b>*</b></font></html>"); panel2.add(label3); label3.setBounds(new Rectangle(new Point(25, 25), label3.getPreferredSize())); panel2.add(textField1); textField1.setBounds(95, 25, 100, textField1.getPreferredSize().height); // ---- label5 ---- label5.setText("<html>To : <font color='red'><b>*</b></font></html>"); panel2.add(label5); label5.setBounds(new Rectangle(new Point(250, 25), label5.getPreferredSize())); panel2.add(textField2); textField2.setBounds(310, 25, 100, textField2.getPreferredSize().height); // ---- label2 ---- label2.setText("<html>Vat % : <font color='red'><b>*</b></font></html>"); panel2.add(label2); label2.setBounds(new Rectangle(new Point(25, 85), label2.getPreferredSize())); panel2.add(textField3); textField3.setBounds(95, 85, 315, textField3.getPreferredSize().height); // ---- button1 ---- button1.setText("Add"); panel2.add(button1); button1.setBounds(70, 150, 100, 30); button1.addActionListener(this); // ---- button2 ---- button2.setText("Clear"); panel2.add(button2); button2.setBounds(280, 150, 100, 30); button2.addActionListener(this); } panel1.add(panel2); panel2.setBounds(50, 125, 500, 200); tableModel1.addColumn("Sr. No."); tableModel1.addColumn("vat %"); tableModel1.addColumn("Year From"); tableModel1.addColumn("Year To"); // ======== scrollPane2 ======== { scrollPane2.setViewportView(table1); } panel1.add(scrollPane2); scrollPane2.setBounds(50, 340, 500, 250); // ---- button3 ---- button3.setText("Delete"); panel1.add(button3); button3.setBounds(50, 610, 150, 30); button3.addActionListener(this); // ---- button4 ---- button4.setText("Update"); panel1.add(button4); button4.setBounds(225, 610, 150, 30); button4.addActionListener(this); button4.setEnabled(false); // ---- button5 ---- button5.setText("Refresh"); panel1.add(button5); button5.setBounds(400, 610, 150, 30); button5.addActionListener(this); } contentPane.add(panel1); panel1.setBounds(0, 0, 600, 700); pack(); setVisible(true); setLocation(200, 10); setSize(600, 700); }
public CAMenuControl(RuleSet[] rules, String[] files) { super(); // buttons randomB = new JButton("Create Simulation"); randomB.addActionListener(handler); loadFileB = new JButton("Load Simulation"); loadFileB.addActionListener(handler); helpB = new JButton("Help"); helpB.addActionListener(handler); exitB = new JButton("Exit"); exitB.addActionListener(handler); // comboboxes Integer[] populations = {10, 20, 30, 40, 50, 60, 70, 80, 90}; populationCB = new JComboBox<Integer>(populations); rulesetCB = new JComboBox<RuleSet>(rules); rulesetCB.addActionListener(handler); filenameCB = new JComboBox<String>(files); // labels Font title = new Font("Ariel", Font.BOLD, 14); randomL = new JLabel("Create a simulation:", JLabel.CENTER); randomL.setFont(title); populationL = new JLabel("Population (%): ", JLabel.RIGHT); rulesetL = new JLabel("Ruleset to use: ", JLabel.RIGHT); loadL = new JLabel("Load simulation from xml file:", JLabel.CENTER); loadL.setFont(title); pathL = new JLabel("Select file: ", JLabel.RIGHT); sep1 = new JSeparator(JSeparator.HORIZONTAL); sep1.setPreferredSize(new Dimension(50, 5)); sep1.setBackground(Color.DARK_GRAY); sep2 = new JSeparator(JSeparator.HORIZONTAL); sep2.setPreferredSize(new Dimension(50, 5)); sep2.setBackground(Color.DARK_GRAY); buttonP = new JPanel(); buttonP.setLayout(new GridLayout(1, 2, 1, 1)); buttonP.add(helpB); buttonP.add(exitB); setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.weighty = 1.0; c.gridx = 0; c.gridy = 0; // row1 c.gridwidth = 2; add(randomL, c); // row2 c.gridwidth = 1; c.gridy = 1; c.gridx = 0; add(rulesetL, c); c.gridx = 1; add(rulesetCB, c); // row3 c.gridwidth = 1; c.gridy++; c.gridx = 0; add(populationL, c); c.gridx++; add(populationCB, c); c.gridy++; c.gridx = 1; add(randomB, c); // sep c.gridy++; c.gridx = 0; c.gridwidth = 2; add(sep1, c); // row4 c.gridwidth = 2; c.gridy++; c.gridx = 0; add(loadL, c); // row5 c.gridwidth = 1; c.gridy++; c.gridx = 0; add(pathL, c); c.gridx = 1; add(filenameCB, c); c.gridy++; c.gridx = 1; add(loadFileB, c); // sep c.gridy++; c.gridx = 0; c.gridwidth = 3; add(sep2, c); // row6 c.gridy++; c.gridx = 0; c.gridwidth = 3; add(buttonP, c); setSize(500, 300); setLocationRelativeTo(null); setDefaultCloseOperation(EXIT_ON_CLOSE); setVisible(true); }