• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Painter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.java.swing.Painter的典型用法代码示例。如果您正苦于以下问题:Java Painter类的具体用法?Java Painter怎么用?Java Painter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Painter类属于com.sun.java.swing包,在下文中一共展示了Painter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getType

import com.sun.java.swing.Painter; //导入依赖的package包/类
static Type getType(Object obj) {
        if (obj instanceof Color) {
                return Color;
        } else if (obj instanceof Painter<?>) {
                return Painter;
        } else if (obj instanceof Insets) {
                return Insets;
        } else if (obj instanceof Font) {
                return Font;
        } else if (obj instanceof Boolean) {
                return Boolean;
        } else if (obj instanceof Integer) {
                return Integer;
        } else if (obj instanceof Icon) {
                return Icon;
        } else if (obj instanceof String) {
                return String;
        } else if (obj instanceof Dimension) {
                return Dimension;
        } else {
                return Object;
        }

}
 
开发者ID:davidholiday,项目名称:ALTk,代码行数:25,代码来源:NimbusThemeCreator.java


示例2: stateChanged

import com.sun.java.swing.Painter; //导入依赖的package包/类
@Override
public void stateChanged(ChangeEvent e) {
        if (tabs.getSelectedComponent() == tablePane && table == null) {
                DefaultTableColumnModel columns = new DefaultTableColumnModel();
                TableColumn column = new TableColumn(0, 400);
                column.setHeaderValue("Key");
                columns.addColumn(column);
                column = new TableColumn(2, 50, new UIDefaultsRenderer(), null);
                columns.addColumn(column);
                column.setHeaderValue(Type.Painter.name());
                table = new Table(new UITypeTableModel(painterKeys, Type.Painter, false), columns);
                table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
                table.setRowHeight(25);
                table.setPreferredScrollableViewportSize(new Dimension(500, table.getRowHeight()*10));
                table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                table.getSelectionModel().addListSelectionListener(this);
                tablePane.getViewport().setView(table);
                tablePane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        }
}
 
开发者ID:davidholiday,项目名称:ALTk,代码行数:21,代码来源:NimbusThemeCreator.java


示例3: updateTreeClientProperties

import com.sun.java.swing.Painter; //导入依赖的package包/类
private void updateTreeClientProperties(JTree tree) {
		if (isNimbus()) {
			UIDefaults map = new UIDefaults();
            // Use raw types to allow compilation in 1.6 and 1.7
            Painter painter = new Painter() {
                @Override
                public void paint(Graphics2D g, Object object, int width, int height) {}
            };
			
			map.put("Tree:TreeCell[Enabled+Selected].backgroundPainter", painter);
			map.put("Tree:TreeCell[Focused+Selected].backgroundPainter", painter);
//			map.put("\"Tree.cellEditor\"[Enabled+Focused].backgroundPainter", painter);

			tree.putClientProperty("Nimbus.Overrides", map);
		} else {
			tree.putClientProperty("Nimbus.Overrides", null);
		}
	}
 
开发者ID:Sciss,项目名称:TreeTable,代码行数:19,代码来源:BasicTreeTableUI.java


示例4: PainterChooser

import com.sun.java.swing.Painter; //导入依赖的package包/类
@SuppressWarnings("unused")
PainterChooser() {
        tablePane = new JScrollPane();
        renderer = new UIDefaultsRenderer();
        renderer.type = Type.Painter;
        editor = new JTextArea(20, 80);
        editor.setText("Not Implemented");
        editor.setEnabled(false);
        editor.setFont(Font.decode(Font.MONOSPACED+' '+12));
        JScrollPane scroller = new JScrollPane(editor);
        JButton update = new JButton("Update");
        update.addActionListener(this);
        update.setEnabled(false);
        JButton toDialog = new JButton("Switch to Dialog");
        toDialog.addActionListener(this);
        JPanel custom = new JPanel(null);
        GroupLayout layout = new GroupLayout(custom);
        custom.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup()
                .addComponent(scroller)
                .addGroup(layout.createSequentialGroup()
                                .addComponent(update).addGap(10, 100, Short.MAX_VALUE).addComponent(toDialog)));
        layout.setVerticalGroup(layout.createSequentialGroup()
                .addComponent(scroller)
                .addGroup(layout.createBaselineGroup(false, true)
                        .addComponent(update).addComponent(toDialog)));
       
        tabs = new JTabbedPane();
        pane = new JPanel(null);
        layout = new GroupLayout(pane);
        pane.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup()
                        .addComponent(tabs)
                        .addComponent(renderer, Alignment.CENTER, 100, 100, Short.MAX_VALUE));
        layout.setVerticalGroup(layout.createSequentialGroup()
                        .addComponent(tabs).addComponent(renderer, 25, 25, 25));
        tabs.add("Custom", custom);
        tabs.add("Nimbus Painters", tablePane);
        tabs.addChangeListener(this);
}
 
开发者ID:davidholiday,项目名称:ALTk,代码行数:41,代码来源:NimbusThemeCreator.java


示例5: getPainter

import com.sun.java.swing.Painter; //导入依赖的package包/类
private Painter getPainter(TreeMap<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:8,代码来源:OpaqueNimbusStyle.java


示例6: MainPanel

import com.sun.java.swing.Painter; //导入依赖的package包/类
public MainPanel() {
    super(new BorderLayout());

    UIDefaults def = UIManager.getLookAndFeelDefaults(); //new UIDefaults();
    def.put("nimbusOrange", new Color(255, 220, 35, 200));

    UIDefaults d = new UIDefaults();
    Painter<JComponent> painter = new Painter<JComponent>() {
        @Override public void paint(Graphics2D g, JComponent c, int w, int h) {
            g.setColor(new Color(100, 250, 120, 50));
            g.fillRect(0, 0, w, h);
            g.setColor(new Color(100, 250, 120, 150));
            g.fillRect(3, h / 2, w - 6, h / 2 - 2);
        }
    };
    d.put("ProgressBar[Enabled].foregroundPainter", painter);
    d.put("ProgressBar[Enabled+Finished].foregroundPainter", painter);

    BoundedRangeModel model = new DefaultBoundedRangeModel(0, 0, 0, 100);
    JProgressBar progressBar1 = new JProgressBar(model);
    JProgressBar progressBar2 = new JProgressBar(model);

    progressBar2.putClientProperty("Nimbus.Overrides", d);

    JPanel p = new JPanel();
    p.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16));
    p.add(progressBar1);
    p.add(progressBar2);

    JButton button = new JButton("Test start");
    button.addActionListener(e -> {
        if (Objects.nonNull(worker) && !worker.isDone()) {
            worker.cancel(true);
        }
        worker = new BackgroundTask();
        worker.addPropertyChangeListener(new ProgressListener(progressBar1));
        worker.execute();
    });

    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    box.add(button);
    box.add(Box.createHorizontalStrut(5));

    addHierarchyListener(this);
    add(p);
    add(box, BorderLayout.SOUTH);
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setPreferredSize(new Dimension(320, 240));
}
 
开发者ID:aterai,项目名称:java-swing-tips,代码行数:51,代码来源:MainPanel.java


示例7: paintComponent

import com.sun.java.swing.Painter; //导入依赖的package包/类
protected void paintComponent(Graphics g) {
        if (selected) {
                g.setColor(UIManager.getColor("Table[Enabled+Selected].textBackground"));
                g.fillRect(0, 0, getWidth(), getHeight());
        } else if (row%2==0) {
                g.setColor(UIManager.getColor("Table.alternateRowColor"));
                g.fillRect(0, 0, getWidth(), getHeight());
        }
        switch (type) {
        case Color: {
                Color col = (Color)value;
                g.setColor(col);
                Graphics2D g2 = (Graphics2D)g;
                g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                g2.fillRoundRect(2, 2, getWidth()-4, getHeight()-4, 10, 10);
        } break;
        case Painter: {
                Painter<JComponent> painter = (Painter<JComponent>)value;
                g.translate((getWidth()-getHeight())/2, 0);
                painter.paint((Graphics2D)g, this, getHeight(), getHeight());
        } break;
        case Insets: {
                Insets in = (Insets)value;
                g.setColor(Color.BLACK);
                g.drawRect(2, 2, getWidth()-4, getHeight()-4);
                g.setColor(Color.GRAY);
                g.drawRect(3+in.left, 3+in.top, getWidth()-6-in.right-in.left, getHeight()-6-in.bottom-in.top);
        } break;
        case Font: {
                Font font = (Font)value;
                drawString(g, font.getFamily(), font);
        } break;
        case Boolean:
                drawString(g, value.toString(), BOOLEAN_FONT);
                break;
        case Integer: case String:
                drawString(g, value.toString(), getFont());
                break;
        case Icon: {
                Icon icn = (Icon)value;
                int x = (getWidth()-icn.getIconWidth())/2;
                int y = (getHeight()-icn.getIconHeight())/2;
                icn.paintIcon(this, g, x, y);
        } break;
        case Dimension: {
                Dimension d = (Dimension)value;
                if (d.width < getWidth()-2 && d.height < getHeight()-2) {
                        g.setColor(Color.GRAY);
                        g.drawRect((getWidth()-d.width)/2, (getHeight()-d.height)/2, d.width, d.height);
                } else {
                        drawString(g, d.width+" x "+d.height, getFont());
                }
        } break;
        case Object: {
                System.out.println(value.getClass());
        } break;
        }
}
 
开发者ID:davidholiday,项目名称:ALTk,代码行数:59,代码来源:NimbusThemeCreator.java



注:本文中的com.sun.java.swing.Painter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XPathContext类代码示例发布时间:2022-05-22
下一篇:
Java CanRollBackResponseProto类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap