if (medium != null) { asCurrent.add(medium); } } if (medium != null) { if (medium instanceof MediaSizeName) { MediaSizeName ms = (MediaSizeName)medium; cbSize.setSelectedIndex(sizes.indexOf(ms)); } else if (medium instanceof MediaTray) { MediaTray mt = (MediaTray)medium; cbSource.setSelectedIndex(sources.indexOf(mt) + 1); } } else { cbSize.setSelectedIndex(sizes.size() > 0 ? 0 : -1); cbSource.setSelectedIndex(0); } SunAlternateMedia alt = (SunAlternateMedia)asCurrent.get(amCategory); if (alt != null) { Media md = alt.getMedia(); if (md instanceof MediaTray) { MediaTray mt = (MediaTray)md; cbSource.setSelectedIndex(sources.indexOf(mt) + 1); } } int selIndex = cbSize.getSelectedIndex(); if ((selIndex >= 0) && (selIndex < sizes.size())) { asCurrent.add((MediaSizeName)sizes.get(selIndex)); } selIndex = cbSource.getSelectedIndex(); if ((selIndex >= 1) && (selIndex < (sources.size()+1))) { MediaTray mt = (MediaTray)sources.get(selIndex-1); if (medium instanceof MediaTray) { asCurrent.add(mt); } else { asCurrent.add(new SunAlternateMedia(mt)); } } } cbSize.addItemListener(this); cbSource.addItemListener(this); } } private class OrientationPanel extends JPanel implements ActionListener { private final String strTitle = getMsg("border.orientation"); private IconRadioButton rbPortrait, rbLandscape, rbRevPortrait, rbRevLandscape; private MarginsPanel pnlMargins = null; public OrientationPanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); setBorder(BorderFactory.createTitledBorder(strTitle)); c.fill = GridBagConstraints.BOTH; c.insets = compInsets; c.weighty = 1.0; c.gridwidth = GridBagConstraints.REMAINDER; ButtonGroup bg = new ButtonGroup(); rbPortrait = new IconRadioButton("radiobutton.portrait", "orientPortrait.png", true, bg, this); rbPortrait.addActionListener(this); addToGB(rbPortrait, this, gridbag, c); rbLandscape = new IconRadioButton("radiobutton.landscape", "orientLandscape.png", false, bg, this); rbLandscape.addActionListener(this); addToGB(rbLandscape, this, gridbag, c); rbRevPortrait = new IconRadioButton("radiobutton.revportrait", "orientRevPortrait.png", false, bg, this); rbRevPortrait.addActionListener(this); addToGB(rbRevPortrait, this, gridbag, c); rbRevLandscape = new IconRadioButton("radiobutton.revlandscape", "orientRevLandscape.png", false, bg, this); rbRevLandscape.addActionListener(this); addToGB(rbRevLandscape, this, gridbag, c); } public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (rbPortrait.isSameAs(source)) { asCurrent.add(OrientationRequested.PORTRAIT); } else if (rbLandscape.isSameAs(source)) { asCurrent.add(OrientationRequested.LANDSCAPE); } else if (rbRevPortrait.isSameAs(source)) { asCurrent.add(OrientationRequested.REVERSE_PORTRAIT); } else if (rbRevLandscape.isSameAs(source)) { asCurrent.add(OrientationRequested.REVERSE_LANDSCAPE); } // orientation affects display of margins. if (pnlMargins != null) { pnlMargins.updateInfo(); } } /* This is ad hoc to keep things simple */ void addOrientationListener(MarginsPanel pnl) { pnlMargins = pnl; } public void updateInfo() { Class orCategory = OrientationRequested.class; boolean pSupported = false; boolean lSupported = false; boolean rpSupported = false; boolean rlSupported = false; if (isAWT) { pSupported = true; lSupported = true; } else if (psCurrent.isAttributeCategorySupported(orCategory)) { Object values = psCurrent.getSupportedAttributeValues(orCategory, docFlavor, asCurrent); if (values instanceof OrientationRequested[]) { OrientationRequested[] ovalues = (OrientationRequested[])values; for (int i = 0; i < ovalues.length; i++) { OrientationRequested value = ovalues[i]; if (value == OrientationRequested.PORTRAIT) { pSupported = true; } else if (value == OrientationRequested.LANDSCAPE) { lSupported = true; } else if (value == OrientationRequested.REVERSE_PORTRAIT) { rpSupported = true; } else if (value == OrientationRequested.REVERSE_LANDSCAPE) { rlSupported = true; } } } } rbPortrait.setEnabled(pSupported); rbLandscape.setEnabled(lSupported); rbRevPortrait.setEnabled(rpSupported); rbRevLandscape.setEnabled(rlSupported); OrientationRequested or = (OrientationRequested)asCurrent.get(orCategory); if (or == null || !psCurrent.isAttributeValueSupported(or, docFlavor, asCurrent)) { or = (OrientationRequested)psCurrent.getDefaultAttributeValue(orCategory); // need to validate if default is not supported if ((or != null) && !psCurrent.isAttributeValueSupported(or, docFlavor, asCurrent)) { or = null; Object values = psCurrent.getSupportedAttributeValues(orCategory, docFlavor, asCurrent); if (values instanceof OrientationRequested[]) { OrientationRequested[] orValues = (OrientationRequested[])values; if (orValues.length > 1) { // get the first in the list or = orValues[0]; } } } if (or == null) { or = OrientationRequested.PORTRAIT; } asCurrent.add(or); } if (or == OrientationRequested.PORTRAIT) { rbPortrait.setSelected(true); } else if (or == OrientationRequested.LANDSCAPE) { rbLandscape.setSelected(true); } else if (or == OrientationRequested.REVERSE_PORTRAIT) { rbRevPortrait.setSelected(true); } else { // if (or == OrientationRequested.REVERSE_LANDSCAPE) rbRevLandscape.setSelected(true); } } } /** * The "Appearance" tab. Includes the controls for Chromaticity, * PrintQuality, JobPriority, JobName, and other related job attributes. */ private class AppearancePanel extends JPanel { private ChromaticityPanel pnlChromaticity; private QualityPanel pnlQuality; private JobAttributesPanel pnlJobAttributes; private SidesPanel pnlSides; public AppearancePanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); c.fill = GridBagConstraints.BOTH; c.insets = panelInsets; c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = GridBagConstraints.RELATIVE; pnlChromaticity = new ChromaticityPanel(); addToGB(pnlChromaticity, this, gridbag, c); c.gridwidth = GridBagConstraints.REMAINDER; pnlQuality = new QualityPanel(); addToGB(pnlQuality, this, gridbag, c); c.gridwidth = 1; pnlSides = new SidesPanel(); addToGB(pnlSides, this, gridbag, c); c.gridwidth = GridBagConstraints.REMAINDER; pnlJobAttributes = new JobAttributesPanel(); addToGB(pnlJobAttributes, this, gridbag, c); } public void updateInfo() { pnlChromaticity.updateInfo(); pnlQuality.updateInfo(); pnlSides.updateInfo(); pnlJobAttributes.updateInfo(); } } private class ChromaticityPanel extends JPanel implements ActionListener { private final String strTitle = getMsg("border.chromaticity"); private JRadioButton rbMonochrome, rbColor; public ChromaticityPanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); setBorder(BorderFactory.createTitledBorder(strTitle)); c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 1.0; ButtonGroup bg = new ButtonGroup(); rbMonochrome = createRadioButton("radiobutton.monochrome", this); rbMonochrome.setSelected(true); bg.add(rbMonochrome); addToGB(rbMonochrome, this, gridbag, c); rbColor = createRadioButton("radiobutton.color", this); bg.add(rbColor); addToGB(rbColor, this, gridbag, c); } public void actionPerformed(ActionEvent e) { Object source = e.getSource(); // REMIND: use isSameAs if we move to a IconRB in the future if (source == rbMonochrome) { asCurrent.add(Chromaticity.MONOCHROME); } else if (source == rbColor) { asCurrent.add(Chromaticity.COLOR); } } public void updateInfo() { Class chCategory = Chromaticity.class; boolean monoSupported = false; boolean colorSupported = false; if (isAWT) { monoSupported = true; colorSupported = true; } else if (psCurrent.isAttributeCategorySupported(chCategory)) { Object values = psCurrent.getSupportedAttributeValues(chCategory, docFlavor, asCurrent); if (values instanceof Chromaticity[]) { Chromaticity[] cvalues = (Chromaticity[])values; for (int i = 0; i < cvalues.length; i++) { Chromaticity value = cvalues[i]; if (value == Chromaticity.MONOCHROME) { monoSupported = true; } else if (value == Chromaticity.COLOR) { colorSupported = true; } } } } rbMonochrome.setEnabled(monoSupported); rbColor.setEnabled(colorSupported); Chromaticity ch = (Chromaticity)asCurrent.get(chCategory); if (ch == null) { ch = (Chromaticity)psCurrent.getDefaultAttributeValue(chCategory); if (ch == null) { ch = Chromaticity.MONOCHROME; } } if (ch == Chromaticity.MONOCHROME) { rbMonochrome.setSelected(true); } else { // if (ch == Chromaticity.COLOR) rbColor.setSelected(true); } } } private class QualityPanel extends JPanel implements ActionListener { private final String strTitle = getMsg("border.quality"); private JRadioButton rbDraft, rbNormal, rbHigh; public QualityPanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); setBorder(BorderFactory.createTitledBorder(strTitle)); c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 1.0; ButtonGroup bg = new ButtonGroup(); rbDraft = createRadioButton("radiobutton.draftq", this); bg.add(rbDraft); addToGB(rbDraft, this, gridbag, c); rbNormal = createRadioButton("radiobutton.normalq", this); rbNormal.setSelected(true); bg.add(rbNormal); addToGB(rbNormal, this, gridbag, c); rbHigh = createRadioButton("radiobutton.highq", this); bg.add(rbHigh); addToGB(rbHigh, this, gridbag, c); } public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == rbDraft) { asCurrent.add(PrintQuality.DRAFT); } else if (source == rbNormal) { asCurrent.add(PrintQuality.NORMAL); } else if (source == rbHigh) { asCurrent.add(PrintQuality.HIGH); } } public void updateInfo() { Class pqCategory = PrintQuality.class; boolean draftSupported = false; boolean normalSupported = false; boolean highSupported = false; if (isAWT) { draftSupported = true; normalSupported = true; highSupported = true; } else if (psCurrent.isAttributeCategorySupported(pqCategory)) { Object values = psCurrent.getSupportedAttributeValues(pqCategory, docFlavor, asCurrent); if (values instanceof PrintQuality[]) { PrintQuality[] qvalues = (PrintQuality[])values; for (int i = 0; i < qvalues.length; i++) { PrintQuality value = qvalues[i]; if (value == PrintQuality.DRAFT) { draftSupported = true; } else if (value == PrintQuality.NORMAL) { normalSupported = true; } else if (value == PrintQuality.HIGH) { highSupported = true; } } } } rbDraft.setEnabled(draftSupported); rbNormal.setEnabled(normalSupported); rbHigh.setEnabled(highSupported); PrintQuality pq = (PrintQuality)asCurrent.get(pqCategory); if (pq == null) { pq = (PrintQuality)psCurrent.getDefaultAttributeValue(pqCategory); if (pq == null) { pq = PrintQuality.NORMAL; } } if (pq == PrintQuality.DRAFT) { rbDraft.setSelected(true); } else if (pq == PrintQuality.NORMAL) { rbNormal.setSelected(true); } else { // if (pq == PrintQuality.HIGH) rbHigh.setSelected(true); } } } private class SidesPanel extends JPanel implements ActionListener { private final String strTitle = getMsg("border.sides"); private IconRadioButton rbOneSide, rbTumble, rbDuplex; public SidesPanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); setBorder(BorderFactory.createTitledBorder(strTitle)); c.fill = GridBagConstraints.BOTH; c.insets = compInsets; c.weighty = 1.0; c.gridwidth = GridBagConstraints.REMAINDER; ButtonGroup bg = new ButtonGroup(); rbOneSide = new IconRadioButton("radiobutton.oneside", "oneside.png", true, bg, this); rbOneSide.addActionListener(this); addToGB(rbOneSide, this, gridbag, c); rbTumble = new IconRadioButton("radiobutton.tumble", "tumble.png", false, bg, this); rbTumble.addActionListener(this); addToGB(rbTumble, this, gridbag, c); rbDuplex = new IconRadioButton("radiobutton.duplex", "duplex.png", false, bg, this); rbDuplex.addActionListener(this); c.gridwidth = GridBagConstraints.REMAINDER; addToGB(rbDuplex, this, gridbag, c); } public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (rbOneSide.isSameAs(source)) { asCurrent.add(Sides.ONE_SIDED); } else if (rbTumble.isSameAs(source)) { asCurrent.add(Sides.TUMBLE); } else if (rbDuplex.isSameAs(source)) { asCurrent.add(Sides.DUPLEX); } } public void updateInfo() { Class sdCategory = Sides.class; boolean osSupported = false; boolean tSupported = false; boolean dSupported = false; Lines 2001–2500 of 2839. Previous lines Load more
if (medium != null) { asCurrent.add(medium); } } if (medium != null) { if (medium instanceof MediaSizeName) { MediaSizeName ms = (MediaSizeName)medium; cbSize.setSelectedIndex(sizes.indexOf(ms)); } else if (medium instanceof MediaTray) { MediaTray mt = (MediaTray)medium; cbSource.setSelectedIndex(sources.indexOf(mt) + 1); } } else { cbSize.setSelectedIndex(sizes.size() > 0 ? 0 : -1); cbSource.setSelectedIndex(0); } SunAlternateMedia alt = (SunAlternateMedia)asCurrent.get(amCategory); if (alt != null) { Media md = alt.getMedia(); if (md instanceof MediaTray) { MediaTray mt = (MediaTray)md; cbSource.setSelectedIndex(sources.indexOf(mt) + 1); } } int selIndex = cbSize.getSelectedIndex(); if ((selIndex >= 0) && (selIndex < sizes.size())) { asCurrent.add((MediaSizeName)sizes.get(selIndex)); } selIndex = cbSource.getSelectedIndex(); if ((selIndex >= 1) && (selIndex < (sources.size()+1))) { MediaTray mt = (MediaTray)sources.get(selIndex-1); if (medium instanceof MediaTray) { asCurrent.add(mt); } else { asCurrent.add(new SunAlternateMedia(mt)); } } } cbSize.addItemListener(this); cbSource.addItemListener(this); } } private class OrientationPanel extends JPanel implements ActionListener { private final String strTitle = getMsg("border.orientation"); private IconRadioButton rbPortrait, rbLandscape, rbRevPortrait, rbRevLandscape; private MarginsPanel pnlMargins = null; public OrientationPanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); setBorder(BorderFactory.createTitledBorder(strTitle)); c.fill = GridBagConstraints.BOTH; c.insets = compInsets; c.weighty = 1.0; c.gridwidth = GridBagConstraints.REMAINDER; ButtonGroup bg = new ButtonGroup(); rbPortrait = new IconRadioButton("radiobutton.portrait", "orientPortrait.png", true, bg, this); rbPortrait.addActionListener(this); addToGB(rbPortrait, this, gridbag, c); rbLandscape = new IconRadioButton("radiobutton.landscape", "orientLandscape.png", false, bg, this); rbLandscape.addActionListener(this); addToGB(rbLandscape, this, gridbag, c); rbRevPortrait = new IconRadioButton("radiobutton.revportrait", "orientRevPortrait.png", false, bg, this); rbRevPortrait.addActionListener(this); addToGB(rbRevPortrait, this, gridbag, c); rbRevLandscape = new IconRadioButton("radiobutton.revlandscape", "orientRevLandscape.png", false, bg, this); rbRevLandscape.addActionListener(this); addToGB(rbRevLandscape, this, gridbag, c); } public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (rbPortrait.isSameAs(source)) { asCurrent.add(OrientationRequested.PORTRAIT); } else if (rbLandscape.isSameAs(source)) { asCurrent.add(OrientationRequested.LANDSCAPE); } else if (rbRevPortrait.isSameAs(source)) { asCurrent.add(OrientationRequested.REVERSE_PORTRAIT); } else if (rbRevLandscape.isSameAs(source)) { asCurrent.add(OrientationRequested.REVERSE_LANDSCAPE); } // orientation affects display of margins. if (pnlMargins != null) { pnlMargins.updateInfo(); } } /* This is ad hoc to keep things simple */ void addOrientationListener(MarginsPanel pnl) { pnlMargins = pnl; } public void updateInfo() { Class orCategory = OrientationRequested.class; boolean pSupported = false; boolean lSupported = false; boolean rpSupported = false; boolean rlSupported = false; if (isAWT) { pSupported = true; lSupported = true; } else if (psCurrent.isAttributeCategorySupported(orCategory)) { Object values = psCurrent.getSupportedAttributeValues(orCategory, docFlavor, asCurrent); if (values instanceof OrientationRequested[]) { OrientationRequested[] ovalues = (OrientationRequested[])values; for (int i = 0; i < ovalues.length; i++) { OrientationRequested value = ovalues[i]; if (value == OrientationRequested.PORTRAIT) { pSupported = true; } else if (value == OrientationRequested.LANDSCAPE) { lSupported = true; } else if (value == OrientationRequested.REVERSE_PORTRAIT) { rpSupported = true; } else if (value == OrientationRequested.REVERSE_LANDSCAPE) { rlSupported = true; } } } } rbPortrait.setEnabled(pSupported); rbLandscape.setEnabled(lSupported); rbRevPortrait.setEnabled(rpSupported); rbRevLandscape.setEnabled(rlSupported); OrientationRequested or = (OrientationRequested)asCurrent.get(orCategory); if (or == null || !psCurrent.isAttributeValueSupported(or, docFlavor, asCurrent)) { or = (OrientationRequested)psCurrent.getDefaultAttributeValue(orCategory); // need to validate if default is not supported if ((or != null) && !psCurrent.isAttributeValueSupported(or, docFlavor, asCurrent)) { or = null; Object values = psCurrent.getSupportedAttributeValues(orCategory, docFlavor, asCurrent); if (values instanceof OrientationRequested[]) { OrientationRequested[] orValues = (OrientationRequested[])values; if (orValues.length > 1) { // get the first in the list or = orValues[0]; } } } if (or == null) { or = OrientationRequested.PORTRAIT; } asCurrent.add(or); } if (or == OrientationRequested.PORTRAIT) { rbPortrait.setSelected(true); } else if (or == OrientationRequested.LANDSCAPE) { rbLandscape.setSelected(true); } else if (or == OrientationRequested.REVERSE_PORTRAIT) { rbRevPortrait.setSelected(true); } else { // if (or == OrientationRequested.REVERSE_LANDSCAPE) rbRevLandscape.setSelected(true); } } } /** * The "Appearance" tab. Includes the controls for Chromaticity, * PrintQuality, JobPriority, JobName, and other related job attributes. */ private class AppearancePanel extends JPanel { private ChromaticityPanel pnlChromaticity; private QualityPanel pnlQuality; private JobAttributesPanel pnlJobAttributes; private SidesPanel pnlSides; public AppearancePanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); c.fill = GridBagConstraints.BOTH; c.insets = panelInsets; c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = GridBagConstraints.RELATIVE; pnlChromaticity = new ChromaticityPanel(); addToGB(pnlChromaticity, this, gridbag, c); c.gridwidth = GridBagConstraints.REMAINDER; pnlQuality = new QualityPanel(); addToGB(pnlQuality, this, gridbag, c); c.gridwidth = 1; pnlSides = new SidesPanel(); addToGB(pnlSides, this, gridbag, c); c.gridwidth = GridBagConstraints.REMAINDER; pnlJobAttributes = new JobAttributesPanel(); addToGB(pnlJobAttributes, this, gridbag, c); } public void updateInfo() { pnlChromaticity.updateInfo(); pnlQuality.updateInfo(); pnlSides.updateInfo(); pnlJobAttributes.updateInfo(); } } private class ChromaticityPanel extends JPanel implements ActionListener { private final String strTitle = getMsg("border.chromaticity"); private JRadioButton rbMonochrome, rbColor; public ChromaticityPanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); setBorder(BorderFactory.createTitledBorder(strTitle)); c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 1.0; ButtonGroup bg = new ButtonGroup(); rbMonochrome = createRadioButton("radiobutton.monochrome", this); rbMonochrome.setSelected(true); bg.add(rbMonochrome); addToGB(rbMonochrome, this, gridbag, c); rbColor = createRadioButton("radiobutton.color", this); bg.add(rbColor); addToGB(rbColor, this, gridbag, c); } public void actionPerformed(ActionEvent e) { Object source = e.getSource(); // REMIND: use isSameAs if we move to a IconRB in the future if (source == rbMonochrome) { asCurrent.add(Chromaticity.MONOCHROME); } else if (source == rbColor) { asCurrent.add(Chromaticity.COLOR); } } public void updateInfo() { Class chCategory = Chromaticity.class; boolean monoSupported = false; boolean colorSupported = false; if (isAWT) { monoSupported = true; colorSupported = true; } else if (psCurrent.isAttributeCategorySupported(chCategory)) { Object values = psCurrent.getSupportedAttributeValues(chCategory, docFlavor, asCurrent); if (values instanceof Chromaticity[]) { Chromaticity[] cvalues = (Chromaticity[])values; for (int i = 0; i < cvalues.length; i++) { Chromaticity value = cvalues[i]; if (value == Chromaticity.MONOCHROME) { monoSupported = true; } else if (value == Chromaticity.COLOR) { colorSupported = true; } } } } rbMonochrome.setEnabled(monoSupported); rbColor.setEnabled(colorSupported); Chromaticity ch = (Chromaticity)asCurrent.get(chCategory); if (ch == null) { ch = (Chromaticity)psCurrent.getDefaultAttributeValue(chCategory); if (ch == null) { ch = Chromaticity.MONOCHROME; } } if (ch == Chromaticity.MONOCHROME) { rbMonochrome.setSelected(true); } else { // if (ch == Chromaticity.COLOR) rbColor.setSelected(true); } } } private class QualityPanel extends JPanel implements ActionListener { private final String strTitle = getMsg("border.quality"); private JRadioButton rbDraft, rbNormal, rbHigh; public QualityPanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); setBorder(BorderFactory.createTitledBorder(strTitle)); c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 1.0; ButtonGroup bg = new ButtonGroup(); rbDraft = createRadioButton("radiobutton.draftq", this); bg.add(rbDraft); addToGB(rbDraft, this, gridbag, c); rbNormal = createRadioButton("radiobutton.normalq", this); rbNormal.setSelected(true); bg.add(rbNormal); addToGB(rbNormal, this, gridbag, c); rbHigh = createRadioButton("radiobutton.highq", this); bg.add(rbHigh); addToGB(rbHigh, this, gridbag, c); } public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == rbDraft) { asCurrent.add(PrintQuality.DRAFT); } else if (source == rbNormal) { asCurrent.add(PrintQuality.NORMAL); } else if (source == rbHigh) { asCurrent.add(PrintQuality.HIGH); } } public void updateInfo() { Class pqCategory = PrintQuality.class; boolean draftSupported = false; boolean normalSupported = false; boolean highSupported = false; if (isAWT) { draftSupported = true; normalSupported = true; highSupported = true; } else if (psCurrent.isAttributeCategorySupported(pqCategory)) { Object values = psCurrent.getSupportedAttributeValues(pqCategory, docFlavor, asCurrent); if (values instanceof PrintQuality[]) { PrintQuality[] qvalues = (PrintQuality[])values; for (int i = 0; i < qvalues.length; i++) { PrintQuality value = qvalues[i]; if (value == PrintQuality.DRAFT) { draftSupported = true; } else if (value == PrintQuality.NORMAL) { normalSupported = true; } else if (value == PrintQuality.HIGH) { highSupported = true; } } } } rbDraft.setEnabled(draftSupported); rbNormal.setEnabled(normalSupported); rbHigh.setEnabled(highSupported); PrintQuality pq = (PrintQuality)asCurrent.get(pqCategory); if (pq == null) { pq = (PrintQuality)psCurrent.getDefaultAttributeValue(pqCategory); if (pq == null) { pq = PrintQuality.NORMAL; } } if (pq == PrintQuality.DRAFT) { rbDraft.setSelected(true); } else if (pq == PrintQuality.NORMAL) { rbNormal.setSelected(true); } else { // if (pq == PrintQuality.HIGH) rbHigh.setSelected(true); } } } private class SidesPanel extends JPanel implements ActionListener { private final String strTitle = getMsg("border.sides"); private IconRadioButton rbOneSide, rbTumble, rbDuplex; public SidesPanel() { super(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); setBorder(BorderFactory.createTitledBorder(strTitle)); c.fill = GridBagConstraints.BOTH; c.insets = compInsets; c.weighty = 1.0; c.gridwidth = GridBagConstraints.REMAINDER; ButtonGroup bg = new ButtonGroup(); rbOneSide = new IconRadioButton("radiobutton.oneside", "oneside.png", true, bg, this); rbOneSide.addActionListener(this); addToGB(rbOneSide, this, gridbag, c); rbTumble = new IconRadioButton("radiobutton.tumble", "tumble.png", false, bg, this); rbTumble.addActionListener(this); addToGB(rbTumble, this, gridbag, c); rbDuplex = new IconRadioButton("radiobutton.duplex", "duplex.png", false, bg, this); rbDuplex.addActionListener(this); c.gridwidth = GridBagConstraints.REMAINDER; addToGB(rbDuplex, this, gridbag, c); } public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (rbOneSide.isSameAs(source)) { asCurrent.add(Sides.ONE_SIDED); } else if (rbTumble.isSameAs(source)) { asCurrent.add(Sides.TUMBLE); } else if (rbDuplex.isSameAs(source)) { asCurrent.add(Sides.DUPLEX); } } public void updateInfo() { Class sdCategory = Sides.class; boolean osSupported = false; boolean tSupported = false; boolean dSupported = false;